How to change image size from 224 x 224 x 1 to 224 x 224 x 3
18 次查看(过去 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 中查找有关 Read, Write, and Modify Image 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!