How to read the pixel value

3 vues (au cours des 30 derniers jours)
Mech Stud
Mech Stud le 21 Mar 2018
Modifié(e) : Mech Stud le 22 Mar 2018
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

Réponse acceptée

thitch
thitch le 21 Mar 2018
You could use the following:
ind = 1:size(A,1);
A(:,3) = arrayfun(@(x) I(A(x,1),A(x,2)), ind)';
  1 commentaire
Mech Stud
Mech Stud le 22 Mar 2018
Modifié(e) : Mech Stud le 22 Mar 2018
Thanks much.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Modify Image Colors dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by