downsampling an image without changing image content
이전 댓글 표시
Hi, I want to down-sample an image and produce 2 images from it like stereo. suppose I have an image with size 1000X1000 and I want to produce 2 images with size 1000X500, each image should have the content of original image (right and left image) and it should not resize from only one direction. for example if an circle exist in original image after this downsampling the circle should be see in results(not oval).please help me. Is there any solution?thanks in advance.
댓글 수: 3
Image Analyst
2016년 6월 15일
It's not possible.
John D'Errico
2016년 6월 15일
편집: John D'Errico
2016년 6월 15일
As long as pixels stay square, it is not gonna happen. Does Hogwarts Academy teach an image processing class? They may be able to do it.
답변 (1개)
Chad Greene
2016년 6월 16일
M = imread('cameraman.tif');
The cameraman image is 256x256, see:
size(M)
ans =
256 256
You can make two of the half-size images like this:
M2 = [imresize(M,0.5), imresize(M,0.5)];
size(M2)
ans =
128 256
See:
image(M2)

댓글 수: 6
Walter Roberson
2016년 6월 16일
However, this would end up as half the original height together with the same width as the original when the two halfs are put side by side; the poster wants the original height and original width after the two halfs are put together, without any content lost and without the aspect ratio being distorted.
Chad Greene
2016년 6월 16일
Ah, I see. What about this?
M = imread('cameraman.tif');
M2 = [imresize(M,[256 128]), imresize(M,[256 128])];
size(M2)
ans =
256 256
image(M2)
daspect([1 2 1])
Walter Roberson
2016년 6월 16일
cf. John's reply of "As long as pixels stay square, it is not gonna happen". That daspect() is effectively using non-square pixels.
Chad Greene
2016년 6월 17일
Who said pixels have to stay square? Embrace the loopholes, Walter!
nadia
2016년 7월 9일
Image Analyst
2016년 7월 9일
Like John and I said, it's not possible. You can't have everything you want. You can have some of the things, but not all.
For example you can't make a 1000x1000 image into a 1000x500 image without losing "content from the original image" (unless you do something strange like convert from 8 bit to 16 bit and stack the "missing" information into the upper byte). Changing the size changes the content. Subsampling will lose information. Upsampling will make up information.
And you can't reduce the width by half, but not the height, without changing the aspect ratio.
카테고리
도움말 센터 및 File Exchange에서 Blocked Images에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!