How to read the pixel value

조회 수: 3 (최근 30일)
Mech Stud
Mech Stud 2018년 3월 21일
편집: Mech Stud 2018년 3월 22일
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일
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개)

카테고리

Help CenterFile Exchange에서 Modify Image Colors에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by