How to rescale image data ?

74 visualizaciones (últimos 30 días)
Dayangku Nur Faizah Pengiran Mohamad
Dayangku Nur Faizah Pengiran Mohamad el 30 de Jul. de 2023
Comentada: Walter Roberson el 2 de Ag. de 2023
My original image sizes is 841x482 pixels.
First step, I need to rescale these image because of my original image does not enough to crop into 512x512 pixels.
Secondly, after rescale these image, I want to crop the image into 512x512 pixels, and feed it as my input image.
How can I rescale these image? Anyone can help? Thanks. My example image as below:-

Respuesta aceptada

Walter Roberson
Walter Roberson el 30 de Jul. de 2023
You can imresize -- but you have to decide whether you want to resize directly to 512 x 512 (which will change the aspect ratio of the pixels), or if you want to resize to 841 x 512 (stretch in one direction) or to some other size such as doubling the size in each direction.
After you have resized to at least 841 x 512 then you can use imcrop() passing in the image array and the crop position and size.
You have not been clear as to what part you would like to crop out. Cropping out the dark part to the right would seem most plausible. But you might also be thinking of cropping out the words. Or perhaps you are thinking about cropping out random patches?
  6 comentarios
Dayangku Nur Faizah Pengiran Mohamad
Hello Sir. I have tried imsize codes. As you mentioned above, if using imresize() for changing image size, I want to ask, does it changing the size of the array if I using imresize()? As you can see image below, I have tried these codes. After resize it, the image resize looks like abit blurry (not distinct). Here's my codes:
>> I=imread('L RA 7200001.jpg');
>> imshow(I)
>> magnificationFactor = 1.25;
>> J = imresize(I,magnificationFactor);
>> imshowpair(I,J,method="montage")
>> imwrite(J,'xL RA 7200001.jpg');
Walter Roberson
Walter Roberson el 2 de Ag. de 2023
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1445537/image.jpeg';
I = imread(filename);
magnificationFactor = 1.25;
J = imresize(I,magnificationFactor);
size(I)
ans = 1×3
482 841 3
size(J)
ans = 1×3
603 1052 3
size(J) ./ size(I)
ans = 1×3
1.2510 1.2509 1.0000
You can see that J is indeed larger than I by approximately the magnification factor.
After resize it, the image resize looks like abit blurry
That is not uncommon, especially when you are starting with JPEG images.
The standard JPEG compression loses information, especially on vertical and near-vertical edges. In order to reduce the visual impression of what it is doing, it does "aliasing" -- fills in fake information along slopes that blend in the edges. Those changes are not easy to see visually when working with an image the original size, but the changes make it difficult to do scientific analysis of images that have undergone JPEG compression. The effects of JPEG compression become more noticable when you resize JPEG images.
But besides that, when you resize images, the resizing algorithm cannot increase the information content of the image. When you ask to resize an image to 25% larger, the effect is not the same as-if you had had a camera with a higher resolution. Instead, the resizing algorithm more or less has to take 4 adjacent pixels and "smear" them into 5 pixels. The result will, in most cases, be less sharp than the original.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Geometric Transformation and Image Registration en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by