[scilab-Users] Finding continuous parts in a mask (ie a binary matrix)

Antoine Monmayrant antoine.monmayrant at laas.fr
Tue Mar 8 11:30:37 CET 2011


Hi Mike,

Thanks for your help.
Detecting where the edge lies is not an issue here as it is as sharp as 
it gets.
The issue is more to group "1" grains efficiently.
Otherwise I think the following could work:
1) I assume I already have a list of grains, each grain containing the 
coordinates of points that are part of the grain.
2) I scan each point in the matrix that are equals to 1 and have not 
been scanned so far.
3) For each point equals to "1", I extract the (x,y) coordinates and 
compare them to the coordinates of points in grains already found.
4) If these coordinates are touching an existing grain, I add them to 
the grain, If not, I create a new grain with the current coordinate and 
move to the next point.

My problem with the approach above is that my matrix is 2560x1920 and 
that I can get thousands of grains...

Antoine

Le 08/03/2011 11:21, Mike Page a écrit :
> Hi Antoine,
>
> You could use a Sobel transform to detect the edges where the value changes
> from 0 to 1 or 1 to 0.
>
> But maybe you were looking for something simpler?
>
> Mike.
>
>
> -----Original Message-----
> From: Antoine Monmayrant [mailto:antoine.monmayrant at laas.fr]
> Sent: 08 March 2011 09:58
> To: users at lists.scilab.org
> Subject: [scilab-Users] Finding continuous parts in a mask (ie a binary
> matrix)
>
>
> Hi everyone,
>
> I have question that is more about image filtering than scilab, but I
> haven't found any answer so far so I'm turning towards scilab users.
> I am looking for a way to determine continuous parts in a matrix made of
> 1 or 0.
> Basically, this matrix is used as a mask to filter an image and I need
> to determine the number of isolated "grains" (ie continuous parts where
> the matrix is equal to 1) in this mask.
> As an example, here is a mask:
>
> -->mask
>    mask  =
>
>       0.    0.    0.    0.    0.    0.    0.    0.    0.    0.
>       0.    0.    0.    0.    0.    0.    1.    1.    1.    0.
>       0.    0.    0.    0.    0.    0.    1.    1.    1.    0.
>       0.    0.    0.    0.    0.    0.    1.    1.    1.    0.
>       0.    1.    1.    0.    0.    0.    0.    0.    0.    0.
>       0.    1.    1.    1.    0.    0.    0.    0.    0.    0.
>       0.    0.    1.    1.    0.    0.    0.    0.    0.    0.
>       0.    0.    0.    0.    0.    0.    0.    0.    0.    0.
>       0.    0.    0.    0.    0.    0.    0.    0.    0.    0.
>       0.    0.    0.    0.    0.    0.    0.    0.    0.    0.
>
>
> It contains 2 "grains", one in the upper-right corner, and one in the
> middle-left.
> I would like to be able to isolate them in order to determine their
> position in the matrix, size,...
> Do any of you know of a good algorithm to achieve this?
> Do any of you know what are the relevant names or keywords associated to
> this kind of algorithm?
>
> Thank you in advance,
>
> Antoin
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.872 / Virus Database: 271.1.1/3488 - Release Date: 03/07/11
> 20:43:00
>


-- 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++

  Antoine Monmayrant LAAS - CNRS
  7 avenue du Colonel Roche
  31077 TOULOUSE
  Cedex 4 FRANCE

  Tel:+33 5 61 33 64 59

  email : antoine.monmayrant at laas.fr
  permanent email : antoine.monmayrant at polytechnique.org

+++++++++++++++++++++++++++++++++++++++++++++++++++++++





More information about the users mailing list