フィルターのクリア

why is the coordinate of impixel function opposite to a image matrix?

1 回表示 (過去 30 日間)
YoungTae Kwak
YoungTae Kwak 2016 年 8 月 11 日
回答済み: Image Analyst 2016 年 8 月 15 日
It's a just somple question.
a = imread('abc.tif');
a(100, 200, :) is different from impixel(a, 100, 200).
Of course, I know that the column and row are exchanged in impixel(a, c, r).
Is there any special reason why the coordinate is opposite to the matrix index?

採用された回答

Swathik Kurella Janardhan
Swathik Kurella Janardhan 2016 年 8 月 15 日
There is no special reason. In a(r,c,:) refers to indexing in a matrix whereas in impixel(a, c, r), c and r are equivalent to x, y coordinates of a plane.
Is there a specific reason for your question? Please explain.
  1 件のコメント
YoungTae Kwak
YoungTae Kwak 2016 年 8 月 15 日
Actually, I just wanted to know why the row and column in order are changed in impixel(a, c, r). But if there is no special reason, I will just follow the instruction.
Thank you for your answering, Swathik!

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2016 年 8 月 15 日
Some functions and operations in MATLAB take coordinates/indexes in row, column order, like indexing locations in an array, etc. Others take coordinates/indexes in x,y order, like plot(), etc. impixel() has other ways you can pass in input arguments and they've chosen to use the x,y form, not the row, column form. So if you're going to use x,y you need to pass in column, row since column is the x coordinate, and row is the y coordinate. Actually I think more or even most functions take and return x,y rather than row, column.
Mixing these two up is probably one of the most common beginner mistakes. I can't tell you how many times we see questions here asking why theirArray(x, y) is giving the wrong values as compared to looking in the variable editor. The answer of course is that they are indexing an array and should have row as the first item, so it should be theirArray(y,x) and not theirArray(x,y) like beginners often think.

カテゴリ

Help Center および File ExchangeSparse Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by