Skip to content

Commit 993a83e

Browse files
author
Chris Greening
committed
USe greyscale image initially
1 parent fdaed49 commit 993a83e

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

IrProCapture/Camera/ImageProcessor.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,13 @@ extension CIImage {
7777
var pixelData = [UInt8](repeating: 0, count: width * height * 4)
7878
let range = max(maxTemp - minTemp, 1.0)
7979
let scaledTemperatures = vDSP.multiply(255.0 / range, vDSP.add(-minTemp, temperatures))
80-
var dstIndex = 0
8180
for index in 0..<width*height {
82-
let temp = UInt8(scaledTemperatures[index])
83-
pixelData[dstIndex] = temp
84-
pixelData[dstIndex + 1] = temp
85-
pixelData[dstIndex + 2] = temp
86-
pixelData[dstIndex + 3] = 255
87-
dstIndex += 4
81+
pixelData[index] = UInt8(scaledTemperatures[index])
8882
}
89-
let bytesPerRow = width * 4
90-
let colorSpace = CGColorSpaceCreateDeviceRGB()
83+
let bytesPerRow = width
84+
let colorSpace = CGColorSpaceCreateDeviceGray()
9185
let data = Data(bytes: pixelData, count: pixelData.count)
92-
let greyScale = CIImage(bitmapData: data, bytesPerRow: bytesPerRow, size: CGSize(width: width, height: height), format: .RGBA8, colorSpace: colorSpace)
86+
let greyScale = CIImage(bitmapData: data, bytesPerRow: bytesPerRow, size: CGSize(width: width, height: height), format: .L8, colorSpace: colorSpace)
9387

9488
// Apply color map
9589
colorMap.filter.inputImage = greyScale

0 commit comments

Comments
 (0)