4d Array converting RGB image into binary
古いコメントを表示
Hello, I want saved 3d images into a 4d array with following code:
for slice = 1 : length(filestrain)
filename = fullfile(foldertrain, filestrain(slice).name);
thisImage = imread(filename);
[rows, columns, numberOfColorChannels] = size(thisImage);
if numberOfColorChannels < 3
message = 'Error: Image is not RGB Color!';
uiwait(warndlg(message));
continue;
end
if rows ~= 1603 || columns ~= 1603
message = 'Error: Image is not 1603X1603!';
uiwait(warndlg(message));
continue; % Skip this image.
end
% Image is okay. Insert it.
XTrain(:,:,:,slice) = thisImage;
imshow(thisImage)
end
The images are zero padded images (1603x1603x3). The original images all have different sizes (cutted manually) and are partly very small like 321x97x3. I did this zero padding for the Input layer of a CNN.
when I am trying to display some images from the 4d Array with:
imshow(XTrain(:,:,2))
The image which is shown is like a binary image no RGB. I dont understand why. Is there a problem with the size of the images?
Thanks for your help
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!