size of image

조회 수: 17 (최근 30일)
Farjana Yeasmin
Farjana Yeasmin 2015년 1월 5일
댓글: Image Analyst 2018년 2월 11일
readImage1=imread(image_file1);
[x1,y1,z1] = size(readImage1);
what does mean by the second line of the code ?
  댓글 수: 2
nabeel raza
nabeel raza 2017년 10월 10일
the readImage1 size will be assigned to x1,y1,z1; that would be 512*512*3
Image Analyst
Image Analyst 2017년 10월 11일
Those numbers are not necessarily the size of her image. The numbers could be anything - depends on the image.
Make sure you read my answer below as to why that code is wrong, and why the accepted answer from Jorge is also wrong even though she accepted it. It's a common beginner mistake.

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

채택된 답변

Jorge
Jorge 2015년 1월 5일
Hi! The second line of the code assigns the size of the image to three variables, namely x1, y1 and z1. If the image 'image_file1' is an image stack, that is, more than one image stored in 'layers' (so to speak) or a 3-D image consisting of 3D units called voxels (ex. tomography), then z1 will be greater than 1. Otherwise, in the case of a common 2d image, only x1 and y1 will be greater than 1; and x1,y1 will account for the width and height of the picture given in pixels.
  댓글 수: 5
Jeremy Ruth
Jeremy Ruth 2018년 2월 11일
I'd just like to add for those looking into this later that the programmers did NOT make a mistake with the seemingly backwards row and col. It is intentional because images use a different axis notation. The 0,0 point is at the top left of the image, not the bottom left. This means that the x-axis for an image is actually the vertical axis, and the y-axis is actually the horizontal axis. Programs like Photoshop and most other professional graphic design programs also use this rotated formatting for the axis, and your computer monitor even references pixels via a rotated axis like this as well if I am not mistaken. Draw and label a regular x and y axis on a piece of paper, label the 0,0 point, and flip it 90 degrees to get the idea.
Image Analyst
Image Analyst 2018년 2월 11일
Jeremy, I'm not buying it. Photoshop is consistent with MATLAB and other programs. I just went into Photoshop to verify that. If you bring up the info window (F8) and mouse around, you'll see that the x is the horizontal (column) direction, just like MATLAB, and the y is the vertical (line, row) direction with y=0 (or 1) at the top line, just like MATLAB and the convention in everything else I've seen.
As far as monitors go, I don't see anywhere in Windows 10 where it says x is the vertical direction, see the Windows 10 API and you can see from this code example for the Windows API that when they move the arrow right or left the x value, not the y value, gets changed indicating that Windows definitely considers x the horizontal direction and y the vertical direction.
Sure, the y is flipped (1 at top for images, and 0 at bottom for graphs) as is the convention, but y is still the vertical direction. And x is still the horizontal direction with the 0 point always at the left for images and graphs.

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

추가 답변 (1개)

Image Analyst
Image Analyst 2015년 1월 5일
It gives the rows in x1 and columns in y1, and either the number of slices in a 3D volumetric image, or color channels in a color image.
Calling rows x1 and columns y1 is kind of backwards to the usual convention of having the vertical direction be y and the horizontal direction be x. So it should be
[y1,x1,z1] = size(readImage1);
to go along with the standard convention.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by