0

I have this sample code from a FLIR:

video_input = videoinput('gige'); %connect to the first gige camera
source = video_input.Source; %get the source object

%To get temperature linear data, the following GenICam registers needs
%to be set
source.SensorGainMode = 'HighGainMode';
source.TemperatureLinearMode = 'On';
source.TemperatureLinearResolution = 'High';


%start the video acquisition
start(video_input);

%MATLAB will receive data in uint16 format, the camera streams in 14bit
%therefor we have to remove the two most significant bits (2^14 and 2^15)
temp_linear = double(getdata(video_input, 1, 'uint16'));
temp_linear_stripped = temp_linear -(2^15) - (2^14); %removing the 2 MSB

%the temperature is linear in this format: T = Signal * 0.04
temp_data_kelvin = temp_linear_stripped * 0.04;
%we get the data in Kelvin, so it needs to be converted
temp_data_celcius = temp_data_kelvin - 273.15;

%displaying the temperature in pixel(100,100)
%disp(temp_data_celcius(100,100));

%to display the image, we can use imagesc
imagesc(temp_data_celcius);

stop(video_input);
imaqreset;

the output from imagesc is what I would like as a jpg. But id also like the temperature data associated with it. Is there a way to do this in matlab?

I tried imwrite(temp_data_celcius, 'image.jpg') but all it gives me is a blank image. My guess it is because imwrite writes a dynamic range of [0,1] but I am afraid I do not know what this means. I would like to save the (greyscale is fine) with the temperature data embedded. so If I open the image at a later time I still have the temperature data.

thanks for the help!!

Dario Cimmino
  • 163
  • 2
  • 8
  • 3
    What is your range? Can't you normalise to [0-1]? Image formats are for image. First, I suggest png as it will maintain quality (as opposed to jpg), but if you want to save *data* you should not use image formats. – Ander Biguri Sep 20 '17 at 14:14
  • Hi @Ander Biguri,thanks for the comment. When I use a portable flir thermal cam, it saves images in jpg format and I can read the temperature data in flir tools. Is it possible to achieve this in Matlab? – Dario Cimmino Sep 20 '17 at 14:21
  • 2
    As an aside, I'm concerned about how you're dealing with those 2 extra bits. I would expect that they are already set to 0 after the call to `getdata`, which means you're shifting the values downward by a large amount when subtracting. If those bits *could* be set, the best way to remove them would be *before* converting to double using `bitand` like so: `bitand(getdata(video_input, 1, 'uint16'), 2^14-1)` – gnovice Sep 20 '17 at 14:27
  • @DarioCimmino "Matlab can even make your dinner, if you know how to use it". Yes it is possible. However, I repeat, jpg is a lossy format, you loose part of the data by just saving it in jpg – Ander Biguri Sep 20 '17 at 14:28
  • @gnovice Thank you for you input. I will look into that. Matlab is way beyond my expertise and Combining Data and images is not my forte. – Dario Cimmino Dec 12 '17 at 15:16

0 Answers0