Is it possible to resize image without changing its total number of pixels?

조회 수: 7 (최근 30일)
I want to reduce each pixel size upto 0.5 but I want the total number of pixels to be the same. Is this possible ?. Kindly Advise.
  댓글 수: 4
Abdul Hannan Qureshi
Abdul Hannan Qureshi 2022년 4월 19일
@Rik thank you for response. I really took the concept of pixel in a wrong way. I realized that now. My aim was to relate 1 pixel = 1 Unit (cm or m) and use "imdistline" as distance measure tool on the image. I was wrong though.
Thank you for correcting me.
Abdul Hannan Qureshi
Abdul Hannan Qureshi 2022년 4월 19일
@Adam Danz Thank you for advise. I am working on grayscale images. I will follow ur guideline to see the outcomes. Thanks again for your time. I dont have a programming background and sometimes it is lil difficult to understand such basic concepts.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2022년 4월 19일
편집: Image Analyst 2022년 4월 19일
@Abdul Hannan Qureshi if you resize the image matrix variable, it will have a different number of elements, not the same.
You can display the tick marks in real world units, such as cm or m, if you use the 'XData' and 'YData' options for imshow().
However regionprops() always measures in pixels so to get from pixels into cm you'd have to multiply by a cmPerPixel scaling/calibration factor that you computer. The attached demo walks you through that process.
  댓글 수: 1
Abdul Hannan Qureshi
Abdul Hannan Qureshi 2022년 4월 19일
Thank you, I have checked the attached file and it seems like to be helpful for me to understand this concept.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

DGM
DGM 2022년 4월 19일
편집: DGM 2022년 4월 19일
Maybe something like:
A = imread('cameraman.tif');
[h w] = size(A); % [256 256]
imshow(A,'xdata',[1 w]/2,'ydata',[1 h]/2)
hold on
plot(64,64,'yo','linewidth',2) % just for demonstration
Note that while the image is still 256x256, the image is plotted on a half-size grid. The NW pixel is now at [0.5 0.5] instead of [1 1], and the center of the image is now at [64 64]. The same can be done with image()/imagesc(). I can't really demonstrate imdistline() in the forum editor, but you should be able to use it just fine.

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by