Error during Greyscale tiff image conversion to RGB tiff image
4 次查看(过去 30 天)
显示 更早的评论
Hello everyone, I need your kind help.
I'm working on my thesis regarding deep learning techniques and during the process of conversion from greyscale image to RGB image, I got an error.
I saved these images as geotiff from Snap and now I need to put them as input to Mask R-CNN.
However, Mask accepts only RGB images.
Following, the code I wrote:
%% RGB Data Conversion
d = uigetdir(pwd,'Select the Dataset Folder');
srcDir = dir(fullfile(d,'*.tif'));
for i = 1:length(srcDir)
baseFileName = srcDir(i).name;
filename = fullfile(srcDir(i).folder, baseFileName);
s1 = 'RGB';
newfilename = strcat(s1, baseFileName);
grayIm = imread(filename);
RGB = cat(3, grayIm, grayIm, grayIm);
t = Tiff(newfilename,'w');
tagstruct.ImageLength = size(RGB, 1);
tagstruct.ImageWidth = size(RGB, 2);
tagstruct.Photometric = Tiff.Photometric.RGB;
tagstruct.BitsPerSample = 8;
tagstruct.SamplesPerPixel = 3;
tagstrut.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
tagstruct.Software = 'MATLAB';
setTag(t, tagstruct);
write(t, RGB);
close(t)
end
and the error I got:
Error using tifflib
Illegal value (0) for PlanarConfiguration.
Error in Tiff/writeAllStrips (line 1938)
meta = tifflib('retrieveMetadata', obj.FileID);
Error in Tiff/write (line 1486)
obj.writeAllStrips(varargin{:});
Error in MASK_R_CNN (line 26)
write(t, RGB);
Can someone help me?
Thank you for your availability.
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!