How to change image size from 224 x 224 x 1 to 224 x 224 x 3
33 ビュー (過去 30 日間)
古いコメントを表示
abdullah al-dulaimi
2022 年 11 月 4 日
コメント済み: Walter Roberson
2023 年 12 月 7 日
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!