How to change image size from 224 x 224 x 1 to 224 x 224 x 3
조회 수: 17 (최근 30일)
이전 댓글 표시
i have images with 224 x 224 x 1 size i want to convert it to 224 x 224 x 3
댓글 수: 0
채택된 답변
Kevin Holly
2022년 11월 4일
Img = rand(224,224,1);
imshow(Img)
new(:,:,1) = Img;
new(:,:,2) = Img;
new(:,:,3) = Img;
imshow(new)
size(Img)
size(new)
댓글 수: 2
Kevin Holly
2022년 11월 4일
편집: Kevin Holly
2022년 11월 4일
folder = uigetdir;
files = dir(fullfile(folder,'*.png'));
for ii = 1:length(files)
grayImage = imread(fullfile(folder,files(ii).name));
rgbImage = cat(3, grayImage, grayImage, grayImage);
imwrite(rgbImage,[fullfile(folder,files(ii).name) '_rgb.png'])
end
추가 답변 (1개)
Walter Roberson
2022년 11월 4일
I recommend that you consider using an imageDatastore followed by an augmentedImageDatastore -- the augmented store can automatically resize your images and can automatically convert to RGB or grayscale.
댓글 수: 2
Walter Roberson
2023년 12월 7일
unzip('MerchData.zip');
imds = imageDatastore('MerchData', ...
'IncludeSubfolders',true, ...
'LabelSource','foldernames');
augds = augmentedImageDatastore([224 224], imds, 'ColorPreprocessing', 'gray2rgb');
[imdsTrain,imdsValidation] = splitEachLabel(augds,0.7);
and so on.
참고 항목
카테고리
Help Center 및 File Exchange에서 Modify Image Colors에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!