필터 지우기
필터 지우기

How can I rescale an image three dimensions (128*128*3) into 2D as (128*128) double ? please

조회 수: 6 (최근 30일)
Hi , i have set of images with dimensions (128*128*3) unit8 , i need convert them into 2D double as (128*128) double ? this code just provide me 128*128*3 !
digitDatasetPath = fullfile('C:\....\Resized dataset');
imds = imageDatastore(digitDatasetPath, ...
'IncludeSubfolders',true,'LabelSource','foldernames');
for i=1:length(imds.Labels)
img=readimage(imds,i);
img1 = imresize(img,[128 128]);
imwrite(img1,cell2mat(imds.Files(i)))
end

답변 (2개)

Matt J
Matt J 2020년 10월 30일

Walter Roberson
Walter Roberson 2020년 10월 30일
It is not possible to do that by resizing images.
You have color images, and when you want 2D output then you need to convert so they are not color. The most common conversion for that is grayscale, but there are other possibilites. For example you might want to convert to HSV saturation.
For grayscale:
imwrite( rgb2gray(img1), imds.Files{i} ) %with no imresize
However, you are overwriting your original files, which is seldom a good idea.
Have you considered using a transform data store ? https://www.mathworks.com/help/matlab/ref/matlab.io.datastore.transform.html
And pixelLabelImageStore can transform to or from rgb:

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by