Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Deo
Posts:
50
Registered:
2/13/08


Re: connected components in a grey scale image
Posted:
May 15, 2008 8:35 AM


"us " <us@neurol.unizh.ch> wrote in message <g0h8ao$879 $1@fred.mathworks.com>... > "Deo ": > <SNIP down to different problem... > > > 0.009 0.009 0.009 > > ... > > I like to label the image above like > > 1 1 1 > > ... > > well, this is simply reindexing a mat with unique > integers  independent of the values > now, one of the many solutions > > % the data > m=[ > 0.09 0.09 0.09 > 0.01 8.00 0.07 > 0.01 9.00 0.06 > 9.00 0.01 7.00 > ]; > % the engine > [mu,mx,mx]=unique(m); > r=reshape(mx,size(m)); > % the result > %  note: <mu> contains the unique abs value(s) > disp([m;nan(1,size(m,2));r]); > %{ > 0.09 0.09 0.09 % the original mat > 0.01 8.00 0.07 > 0.01 9.00 0.06 > 9.00 0.01 7.00 > NaN NaN NaN % visual divider > 4.00 4.00 4.00 % reindexed mat > 1.00 6.00 3.00 > 1.00 7.00 2.00 > 7.00 1.00 5.00 > %} > > us
This approach would only work in this situation but in a scenario such as this 0.09 0.09 0.09 0.01 0.01 8.00 0.07 0.01 0.01 9.00 0.06 0.1 0.09 0.01 7.00 0.7
when it is required that the output should look as CC1 CC1 CC1 CC6 CC2 CC4 CC5 CC6 CC2 CC7 CC8 CC9 CC3 CC2 CC10 CC11 where CC1  CC11 are the connected components and they can be any integer. You can see that clusters of same intensity are labeled differently when they are not connected. This what I am looking for maybe I did not express myself correctly in the prevoius thread.



