Image matrix dimensions flipped compared to original image

1 次查看(过去 30 天)
img1 = rgb2gray(imread('Image1.png'));
size(img1)
ans =
384 512
When I apply this command to load the image the matrix 384x512. However, the original png image has 512x384 pixels. What am I missing here that the image matrix in MATLAB looked flipped. I was expecting MATLAB to create a 512x384 matrix.

采纳的回答

Ameer Hamza
Ameer Hamza 2020-12-4
编辑:Ameer Hamza 2020-12-4
Commonly image resolution is expressed as width x height. However, in MATLAB the size() returns "number of rows (height)" x "number of columns (width)". However, it should not look flipped due to this. imshow() should show the same image as shown outside MATLAB.
  2 个评论
Punnag Chatterjee
Punnag Chatterjee 2020-12-4
Yes, when I use imshow it does show the image correctly, the problem occurs when I am indexing the individual matrix elements for some image operations.
Bjorn Gustavsson
Bjorn Gustavsson 2020-12-4
Then you'll have to "learn to accept" the matlab-indexing-notation/convention:
I_xy = Img(row_idx_y,col_idx_x);

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by