S_S
S_S

Reputation: 1402

PixelList in regionprops

I want to map the output of regionprops to the original image. What does the 'PixelList' attribute of the output of regionprops denote?

When I try to access the pixels whose locations are specified by the 'PixelList' attribute, they sometimes exceed the dimensions of the original image. Is this the correct interpretation?

Upvotes: 1

Views: 2895

Answers (2)

Shai
Shai

Reputation: 114796

Based on your comment, you must verify that the size of img1 is identical to img2 otherwise you will have to transform the pixels' locations got from PixelList to fit them on img1.

Please note that the coordinates of the pixels in PixelList are given in an X-Y order, if you want to use them to index the original matrix img1 you'll have to use row-column order:

img1( stats.PixelList(:,2), stats.PixelList(:,1) ) = 1;

Upvotes: 1

dbs
dbs

Reputation: 136

What I have understood from 'map' is you would like annotate pixels in 'PixelList' on original image. Here is a sample code:

% Your binary image
im = imread('binaryImage.png');
stats = regionprops(im,'PixelList');

figure,
imshow(im), hold on,
plot(stats.PixelList(:,1),stat.PixelList(:,2),'.y')

Or you can put up some example image for better explanation of your question.

Upvotes: 1

Related Questions