I used the following code to get the x and y coordinates of this image
I =double(imread('F:\01.jpg'));
[ROWS,COLUMNS] = ndgrid(1:size(I,1),1:size(I,2));
ROWS = ROWS(:);
COLUMNS = COLUMNS(:);
A = [ROWS COLUMNS]
I want to get the another column in A stating the pixel value of each pixel point. The purpose is to get the x and y coordinates of the black pixels only in the shortest possible path order

 採用された回答

thitch
thitch 2018 年 3 月 21 日

1 投票

You could use the following:
ind = 1:size(A,1);
A(:,3) = arrayfun(@(x) I(A(x,1),A(x,2)), ind)';

1 件のコメント

Mech Stud
Mech Stud 2018 年 3 月 22 日
編集済み: Mech Stud 2018 年 3 月 22 日
Thanks much.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeImages についてさらに検索

質問済み:

2018 年 3 月 21 日

編集済み:

2018 年 3 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by