フィルターのクリア

size of image

21 ビュー (過去 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.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by