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

Stéphane Mottelet stephane.mottelet at utc.fr
Tue Mar 8 13:56:59 CET 2011


Hi,

I think Matlab has such a feature in the Image processing toobox

http://www.mathworks.com/matlabcentral/newsreader/view_thread/24869

maybe does it also exists in Scilab's SIVP  toolbox ?

S.

Le 08/03/2011 13:52, Antoine Monmayrant a écrit :
> Le 08/03/2011 13:11, Samuel GOUGEON a écrit :
>>  Hello Antoine,
> Hi Samuel,
>
> To give you more details, I just need to be sure to detect correctly 
> convex shapes.
> Most of the time, the "grains" I am interested in will be disks or 
> squares.
> I won't try to detect non-convex grains.
> So I tried to answer you questions below with this application in mind.
>>
>> ----- Message d'origine -----
>> De : Antoine Monmayrant
>> Date : 08/03/2011 10:58:
>>> 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.
>>>
>> There are first a number of decisions to be taken about
>> waht you will consider being a acceptable domain:
>>
>> * Do you consider 2 domains just connected by a right wire as 
>> distincts ?
>>     0.    0.    0.    0.    0.    0.    0.    0.
>>     0.    1.    1.    0.    0.    0.    0.    0.
>>     0.    1.    1.    1.    0.    0.    0.    0.
>>     0.    0.    1.    1.    0.    0.    0.    0.
>>     0.    0.    0.    1.    0.    0.    0.    0.
>>     0.    0.    0.    1.    1.    0.    0.    0.
>>     0.    0.    1.    1.    1.    1.    0.    0.
>> Likely no. There are the same...
> No, as you said.
>>
>> * Do you consider 2 domains just connected by a diagonal wire as 
>> distincts?
>>     0.    0.    0.    0.    0.    0.    0.    0.
>>     0.    1.    1.    0.    0.    0.    0.    0.
>>     0.    1.    1.    1.    0.    0.    0.    0.
>>     0.    0.    1.    1.    0.    0.    0.    0.
>>     0.    0.    0.    0.    1.    1.    0.    0.
>>     0.    0.    0.    1.    1.    1.    0.    0.
>>     0.    0.    0.    1.    1.    1.    0.    0.
>> This is a classic neighbouring option
> Yes.
>>
>> *  Do you consider only doubly connex domains, so with no hole(s), 
>> unlike here?:
>>     0.    0.    0.    0.    0.    0.    0.    0.
>>     0.    1.    1.    1.    0.    0.    0.    0.
>>     1.    1.    0.    1.    0.    0.    0.    0.
>>     1.    1.    0.    1.    0.    0.    0.    0.
>>     0.    1.    1.    2.    0.    0.    0.    0.
>>     0.    0.    0.    0.    0.    0.    0.    0.
> Tricky one. In that case, this is one grain. This is an edge case for 
> my application so it should not occur too often.
> I can either consider the "0" inside to be part of the grain or not, 
> it does not matter that much.
>>
>> * Do you consider only un-nested domain? Counter-example:
>>     0.    1.    1.    1.    0.    1.    0.    0.
>>     0.    1.    1.    1.    1.    1.    1.    0.
>>     1.    1.    0.    0.    0.    0.    1.    0.
>>     1.    1.    0.    Z.    Z.    0.    1.    0.
>>     1.    1.    0.    0.    0.    0.    1.    0.
>>     0.    1.    1.    1.    1.    1.    1.    0.
>>     0.    0.    1.    1.    1.    1.    0.    0.
> Well, again, it should occur not too often. In this case, I can 
> consider the whole thing to be one big grain.
>>
>> IMO, it is hard to implement and discuss any algo before answering to 
>> all these cases.
> Any suggestion given my answers?
> Are there any ressource I should check to  get some examples on these 
> issues of neighbouring?
>
> Cheers,
>
> Antoine
>>
>> Regards
>> Samuel
>>
>




More information about the users mailing list