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 日

1 投票

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 日
what about imresize function with bicubic option, can we say it is the less looses of information
Guillaume
Guillaume 2020 年 5 月 10 日
It's going to depend on your definition of 'loosing information'. If you care about the **exact** value of the pixels, then I'd say 'nearest' is the less lossy, but the visual quality of the final image will probably be a lot better. 'bicubic' is going to give you the best looking image but will change a lot more pixels.
Image Analyst
Image Analyst 2020 年 5 月 10 日
編集済み: Image Analyst 2020 年 5 月 10 日
To change the format, you merely have the extension in newfilename be ".png". For example
newfilename = strrep(lower(someimagefile), '.dcm', '.png');
Why do you want to resize anyway? Are you going to plug these into a deep learning network?
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 件)

カテゴリ

ヘルプ センター および File ExchangeRead, Write, and Modify Image についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by