obtaining greyscale image as nxm matrix

2 ビュー (過去 30 日間)
Terry McGinnis
Terry McGinnis 2015 年 6 月 17 日
コメント済み: Terry McGinnis 2015 年 6 月 17 日
i have a gray scale image and wish to obtain values in matrix form.(as in an n x m matrix).This is what i have attempted :
I = imread('cameraman.tiff');
[xmax,ymax]=size(I)
for x=0:1:xmax
for y=0:1:ymax
I(x,y)
end
end
but am getting an error:
??? Subscript indices must either be real positive integers or logicals.

採用された回答

Guillaume
Guillaume 2015 年 6 月 17 日
I is already a matrix, so what do you mean by obtain values in matrix form?
Matrix indexing in matlab starts at 1, so your loops should be
for x = 1:xmax
for y = 1:ymax
%whatever you want to do
end
end
Note that if indexing started at 0, then your loop would have to terminate at xmax-1, not xmax.
Also note that indexing is in the form (row, column), so if you use the standard convention that x is horizontal and y vertical, then your indexing should be:
I(y, x)
  7 件のコメント
Guillaume
Guillaume 2015 年 6 月 17 日
It's a completely different question to your original one, so you should start a new question.
Terry McGinnis
Terry McGinnis 2015 年 6 月 17 日
thanks Guillaume

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by