Hello,
I'm experimenting with structuring elements to enhance the
connectivity of linear networks extracted with image filtering. I read
somewhere in the posts that trying to implement series of asymmetric
structuring elements may yield series headaches. I can largely confirm
that and here is what came out of my headache so far...
The image is a binary array where 0s mark the extracted lines and 1s
mark the background, so I try to find 1-pixels that would serve to
connect 0-pixels using IDL MORPH_HITORMISS.
Below there are some pieces of the code to find gaps with horizontal,
vertical gaps and asymmetric neighbors but when it comes to the
diagonal case I really get confused. In the following case for example
I would like to to find the the connecting pixel in the middle.
0 1 1 0 1 1
1 1 1 -> 1 x 1
1 1 0 1 1 0
...easy it seems!
However, if for example one of the zeros already has diagonal
neighbors I would like to avoid the connection:
1 1 0 1 1
1 0 1 1 1
0 1 1 1 0
1 1 1 0 1
Only a few pixels are interesting here and ignoring the rest could
significantly reduce the number of possible combinations. I thought of
something like that:
. . 1 . . . . 1 . .
. 0 1 . . . 0 1 . .
1 1 1 1 1 -> 1 1 x 1 1
. . 1 0 . . . 1 0 .
. . 1 . . . . 1 . .
In some tutorials on hit or miss morphology the possibility to ignore
some positions ("Don't care" pixels) is given. Is there any
possibility to do so with the IDL morpholghy commands?
Thanks in advance for any suggestion
Best wishes
Andre
; horizontal gaps
miss = [[0b,0b,0b],$
[1b,0b,1b], $
[0b,0b,0b]]
hit = [[1b,1b,1b], $
[0b,1b,0b], $
[1b,1b,1b]]
matches = matches + (morph_hitormiss(binary, hit, miss))
; vertical gaps
miss = rotate(miss,1)
hit = rotate(hit,1)
matches = matches + (morph_hitormiss(binary, hit, miss))
; asymetric gaps
miss = [[1b,0b,0b],$
[0b,0b,1b], $
[0b,0b,0b]]
hit = [[0b,1b,1b], $
[1b,1b,0b], $
[1b,1b,1b]]
for i=0, 7 do begin
missi=rotate(miss, i)
hiti=rotate(hit, i)
matches= matches + (morph_hitormiss(binary, hiti, missi))
end
|