.tif files not loading in correctly
Show older comments
Hi, I am loading in .tif files for my code, but the problem is when loading it in the values are changing. i.e. for my images they are 1024x1024 .tif files, and when looking at the pixel info using ImageJ, at (686,674) the value is 1.0759. Loading the image into matlab using the fitsread function and looking at (686,674) gives me 1.11037. Has anyone else experience this issue, I am using this image values to calculate temperature arrays, and as a result my arrays are usually 5-8 Kelvin less than expected, I am not sure why when loading in it is doing this. The file classes are uint16 and I have been converting them to doubles without issue. Here is my code
[images, pathname] = uigetfile( ...
{'*.tif', 'All .tif Files (*.tif)'; ...
'*.*','All Files (*.*)'},...
'Select Wind on file to Load');
handles.Calibration_ratio = importTSP_image(images, pathname);
Calibration_ratio = double(handles.Calibration_ratio.('Run9_cam4_ratio'));
function imgdata = importTSP_image(fileToRead1,pathname)
%IMPORTFILE(FILETOREAD1)
% Imports data from the specified file
% FILETOREAD1: file to read
fileToRead1 = fullfile(pathname,fileToRead1);
% Import the file
rawData1 = importdata(fileToRead1);
[~,name] = fileparts(fileToRead1);
newData1.(matlab.lang.makeValidName(name)) = rawData1;
% Create new variables in the base workspace from those fields.
vars = fieldnames(newData1);
for i = 1:length(vars)
assignin('base', vars{i}, newData1.(vars{i}));
end
imgdata = newData1;
end
8 Comments
Dean
on 21 Jul 2023
DGM
on 21 Jul 2023
To upload a TIFF file, you'd have to zip it to work around the limitations of the editor. If you're saying you can't upload it for reasons of confidentiality, then that's an obstacle.
Dean
on 21 Jul 2023
Image Analyst
on 21 Jul 2023
Edited: Image Analyst
on 21 Jul 2023
Why not? Are they bigger than 5 MB?
Are the values floating point rather than uint8 or uint16 integers?
Is it possible to at least upload any non-identifying information contained in the metadata (e.g. the output from imfinfo(filename) ? TIFF is one of the most flexible image formats, so it's possible that subtle differences could be caused by misinterpreting the file. I'm not familiar with all the edge cases and specialized uses, so I can't really intuit an explanation for the discrepancy without seeing more clues.
Dean
on 21 Jul 2023
Dean
on 21 Jul 2023
Answers (0)
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!