简体   繁体   中英

Image resizing without quality loss?

If I have for example an image of size 400 x 600 . I know how to resize it in order to be of size 80 x 80 by using the code below:

original_image = imread(my_image);
original_image_gray = rgb2gray(original_image);
Image_resized = imresize(original_image_gray, [80 80]);

But I think that imresize will resize the image with some losses in the quality. So how to resize it without any loss of the quality?

Image resizing itself will lose part of the image info, ie quality of the image.

What you can do is to choose the resizing method that fits your purpose by setting up the corresponding parameter:

[...] = imresize(...,method)
                     ^^^^^^

在此处输入图片说明

Matlab stores images as pixel array. It is impossible, to store all the information contained in a 400x600 element matrix in a 80x80 matrix, therefore quality loss is unavoidable when resizing the pixel array, which is what imresize does.

If you want to reduce the physical size of your output, you should look at the imgwrite documentation , in particular at the XResolution and YResolution parameters in the case of creating png images.

original_image = imread(my_image);
imwrite(original_image_grey,'image.png','png','ResolutionUnit','cm','XResolution',400)

The above code will create a png of the original image with a resolution of 400px/cm, resulting in an image of 1cm width. The png will still be a 400x600px Bitmap.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM