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!