Toolbox | Editable Source Code | IFT Kernel

ift_m

Synopsis

Prototype:
y = ift_m(f, offsets, M)
Description:
The ift_m function implements the watershed transform using the image-foresting transform. It receives an extra parameter that is the markers of the image. This parameter is an image of labels, where each label greater than zero will be used as a marker to process the IFT. The M image must have the same dimensions as f.
Definition:
IFT-WT
Exploration:
Breadth-First

Algorithm

\begin{algorithmic}[1]

\In{$im$: Grey level image with domain $D$, $S$: markers}
\Out{$lab$: Labels image}


\Statex

\Initialise
    \State $\forall p \in D, \; \done{p} \atr\ \KwFalse$
    \State $\forall p \not\in S, \; \data{$C_1$(p)} \atr\ \infty, \; \lab{p} \atr\ \mask, \; \parent{p} \atr\ \mask$
    \State $\forall p \in S, \; \data{$C_1$(p)} \atr\ \im{p}, \; \lab{p} \atr\ \lambda(p), \; \parent{p} \atr\ p$, \HeapQueuePush{p, \im{p}}
\End

\Statex

\While{\HeapQueueEmpty{} = \KwFalse}
    \State p \atr\ \HeapQueuePop{}
    \State \done{p} \atr\ \KwTrue
    \ForAll{$q \in N(p) \; | \; \done{q} = \KwFalse$}
        \State c \atr\ $max(\data{$C_1$(p)}, \im{q})$
        \If{$c < \data{$C_1$(q)}$}
            \If{\HeapQueueContains{q}}
                \State \HeapQueueRemove{q}
            \EndIf
            \State $\data{$C_1$(q)} \atr\ c$
            \State \lab{q} \atr\ \lab{p}
            \State \parent{q} \atr\ p
            \State \HeapQueuePush{q, $\data{$C_1$(q)}$}
        \EndIf
    \EndFor
\EndWhile

\end{algorithmic}

Algoritmo 1: IFT for watershed

References

Source Code

 1 from ipdp.common import *
 2 from watershed.ift_k_py import ift_k
 3 
 4 def ift_m(im, offsets, M):
 5 
 6     # initialise variables
 7     ws = wsImage(im)
 8     N, im, lab, D = ws.begin(offsets)
 9 
10     wsM = wsImage(M)
11     NM, imM, labM, DM = wsM.begin(offsets)
12 
13     # make the set
14     Mset = dict()
15     for p in D:
16         if imM[p] > 0:
17             if Mset.has_key(imM[p]):
18                 Mset[imM[p]].append(p)
19             else:
20                 Mset[imM[p]] = [p]
21 
22     ift_k(ws, im, Mset.values(), N, D, lab)
23 
24     return ws.end()

References

[LotufoFalcaoISMM2000]===> R. Lotufo and A. Falcão, ``The ordered queue and the optimality of the watershed approaches,'' in Proceedings of the 5th International Symposium on Mathematical Morphology and its Applications to Image and Signal Processing, vol. 18. Kluwer Academic Publishers, June 2000, pp. 341–350.
[FalcaoStolfiLotufoPAMI2004]===> A. X. Falcão, J. Stolfi and R. A. Lotufo, ``The image foresting transform: theory, algorithms, and applications,'' Pattern Analysis and Machine Intelligence, IEEE Transactions on, vol. 26, no. 1, pp. 19–29, 2004.