change size and format of images

조회 수: 19 (최근 30일)
Salma Hassan
Salma Hassan 2020년 5월 10일
댓글: Walter Roberson 2020년 5월 15일
I have a medical images dataset with various sizes and formats . I want to downsample all of them into 256*256 without loosing information and change all the formats into png

채택된 답변

Guillaume
Guillaume 2020년 5월 10일
Assuming all the image formats (list required!) are supported by matlab, the process for each image would be:
originalimage = imread(someimagefile);
resizedimage = imresize(originalimage, [256 256]);
imwrite(resizedimage, newfilename);
To apply that to a bunch of images, see How do I process a sequence of files.
Note that there are many image viewers that can do the conversion for you without you having to write a single line of code. For example, IrfanView has a batch conversion mode which can also resize images at the same time. All you'd have to do is select the images, turn resizing on and specify the final size and tell it to convert the images to png.
Also note:
"I want to downsample"
"without loosing information"
These two statements are incompatible. By definition, if you downsample you're voluntarily discarding information.
  댓글 수: 5
Salma Hassan
Salma Hassan 2020년 5월 10일
Is there any paper prove that "nearest" option is better than "bicubic"
Walter Roberson
Walter Roberson 2020년 5월 15일
Salma comments to Image Analyst:
yes, exactly I want to accelerate the training process

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by