Hi, I need to know if there is any way to find the indices of connected points. To be more specific, is there any way that to preserve those indices so that it could be used for comparison in an altered matrix( the matrix comes from a picture). Thanks for the help.

3 件のコメント

Sean de Wolski
Sean de Wolski 2012 年 1 月 23 日
Please provide a small example of inputs, the operation and outputs.
Romendra
Romendra 2012 年 1 月 23 日
My working matrix is 128x256 but as a sample
a=[1 1 0 0 0 1
1 0 0 0 1 1
0 0 0 0 0 1
0 0 0 0 0 0]
I then used bwlabeln(a) to find the connected points which gave me
a_connected=[ 1 1 0 0 0 2
1 0 0 0 2 2
0 0 0 0 0 2
0 0 0 0 0 0]
What i need to do is check this against another matrix( as i said a picture) to see if there is any difference. The connected points indicate an object of interest in the picture.
Any ideas??
Thanks
Romendra
Romendra 2012 年 1 月 23 日
Also I am doing object by object comparison. So I need to compare a set of connected points to another set in an altered matrix.

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

 採用された回答

Walter Roberson
Walter Roberson 2012 年 1 月 23 日

0 投票

regionprops() can return the indices of the points for each region.
Or more simply,
find(a==2)

11 件のコメント

Romendra
Romendra 2012 年 1 月 23 日
I am gonna give that a go. Test it out and let you know how it works. Thanks
BTW which toolbox has imageprop(). I just searched it in the help file and it does not pop up
Walter Roberson
Walter Roberson 2012 年 1 月 23 日
Sorry, I should have said regionprop()
Romendra
Romendra 2012 年 1 月 23 日
oh ok.. I will give that a go. Sorry I think i might have mis read it. I will let you know how that works
Walter Roberson
Walter Roberson 2012 年 1 月 23 日
I really did write imageprop() originally. And then I corrected it to regionprop(). But the real routine name is regionprops().
Sean de Wolski
Sean de Wolski 2012 年 1 月 23 日
Case of the Mondays?
Walter Roberson
Walter Roberson 2012 年 1 月 23 日
Dang, now I've got the storyline for an old science fiction story stuck in my head, but I cannot remember the author or title or finer details, or even the decade it was written. Oh, and it might have been in one of the boxes of books that the mice got in to a couple of years ago. Sigh.
Romendra
Romendra 2012 年 1 月 24 日
ok, so I used bwconncomp(a) to get the # of connected points and their size by PixelIdxList. But the question still remains as to how to extract the indices for the connected points. I did find(a==1), find(a==2) and so on and so forth. But if you do not know how many objects are there in an image it just looks a long tedious way as I would have to find the individual indices and them compare as soon as I find them. Does the PixelIdxList save the index info. I looked into the image processing toolbox help but the examples are not too helpful..Still looking into it but any more ideas..
Walter Roberson
Walter Roberson 2012 年 1 月 24 日
u = unique(a(:));
u(u==0) = [];
length(u) is number of objects
Romendra
Romendra 2012 年 1 月 24 日
what is on the right hand side of the second line..
u(u==0)=?
seems like a special char
cant read it..
ty
Romendra
Romendra 2012 年 1 月 25 日
I used regionprops and extracted both the linear index and value associated with it.
Thanks for help
Walter Roberson
Walter Roberson 2012 年 1 月 25 日
The [] is left-square-bracket followed by right-square-bracket. That command is there to toss out the 0's that correspond to "no object present here".

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by