How to rescale image data ?
조회 수: 87 (최근 30일)
이전 댓글 표시
Dayangku Nur Faizah Pengiran Mohamad
2023년 7월 30일
댓글: Walter Roberson
2023년 8월 2일
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:-
댓글 수: 0
채택된 답변
Walter Roberson
2023년 7월 30일
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
Walter Roberson
2023년 8월 2일
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1445537/image.jpeg';
I = imread(filename);
magnificationFactor = 1.25;
J = imresize(I,magnificationFactor);
size(I)
size(J)
size(J) ./ size(I)
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.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!