# LSM level set method vs thresholding

I am trying to understand the LSM algorithm applied to grayscale image segmentation.

There are essentially 2 things that are blocking me:

1) From my point of view - the level sets - i.e. ''moving'' the 3D surface (that is, conceptually visualizing the grayscale image (say 8 bits/pixel) as a surface whose height is given at each point (pixel $$x,y$$) by the intensity value of that pixel, through a fixed plane, or the other way around, is exactly the same as performing a thresholding from 0 to 255 (i.e. each "level set" would be all the pixels at threshold value 0,1,2 ...255)?

2) Let $$f(x,y)$$ be the image function (associating an intensity between 0 and 255 to each point $$(x,y)$$. The LSM is defined as $$\Gamma = \{(x,y) | \phi(x,y)=0\}$$

However, it does not make sense to me, (from my point of view which is probably wrong, hence my question), that $$\phi(x,y)=0$$ as as the surface has its own height at each point and it would make more sense to me to consider that the plane intersecting the surface is moving from bottom to up, i.e. I can ''accept'' better the formulation given for the level sets:

$$\Gamma = \{(x,y) | \phi(x,y)=c\}$$

and for the example I use, $$c \in [0,255]$$

Question 2 is more like a ''conceptual'' problem, but question 1 is more fundamental, since I cannot seem to see any difference with a simple thresholding.

Rephrased:

Question 1) Can we consider (loosely speaking, as indeed as the li is a set of points not a matrix) that each level curve $$l_i$$ of a level set of an image I is (in programmatic terms, Matlab syntax): li= (I==i) ? (where i is the height, in grayscale 8 bits, i is a number between 1 and 255, and as Matlab uses matrices everywhere, I is a $$n \times m$$ matrix and the operation == checks for every pixel in I if it is equal to i and the result is a binary image with 0s or 1s, i.e. this is called thresholding, hence my question is LSM the same as thresholding with operator == (and the single '=' is the assignment operation of course))

Question 2) Is it essentially (conceptually) the same to imagine moving the shape through a fixed plane, or moving a plane through a fixed 3D shape ?  What I was (in an incorrect way) trying to say is that we can visualize the level curves $$l_i$$ as the white circles on the thresholded image (although not perfect since it is discretized an maybe rounding errors/noise etc but suppose they are continuous) and ideed i do understand that the result of thresholding is a matrix so strictly speaking not equal to a lvl curve. But "loosely" speaking, visualizing the lvl curves do you agree?

• what do you think now? – Machupicchu Jan 14 '19 at 10:01

Question 1) Can we consider that each level curve $$li$$ of a level set of an image I is [...] a binary image with 0s or 1s, i.e. this is called thresholding, hence my question is LSM the same as thresholding with operator == (and the single '=' is the assignment operation of course)).

No it is not.

$$\Gamma$$ is a curve. The result of thresholding is a matrix.

$$\phi$$ is positive inside the boundary, negative outside of the boundary and $$0$$ right on the boundary.

A function that is a good candidate for $$\phi$$ would be the distance function. An alternative formulation to that, if you really wanted to represent the boundary of a closed region would be to obtain a slice via thresholding and then apply a mask such as:

$$\begin{matrix} 1 & 1 & 1 \\ 1 & -8 & 1 \\ 1 & 1 & 1 \end{matrix}$$

This would give you the pixels that are right on the boundary of the thresholded region. You still have to extract them of course and if we are talking about a curve you would also have to connect the points (otherwise a set of pixels in 2D space is not necessarily a curve) and while connecting them you would also have to select a winding (clockwise or counter-clockwise). In addition, the thresholding might return regions that are not connected in which case, you would have to decide if they are part of the same object and (optionally) use morphological operators to make sure that they are closed curves and not paths.

Question 2) Is it essentially (conceptually) the same to imagine moving the shape through a fixed plane, or moving a plane through a fixed 3D shape ?

While I do understand where this question comes from, I have to say that in this particular case it is neither, because $$\phi$$ is not the image.

The meaning of the level set as "all points for which $$\phi$$ is zero" is not the same as sliding a threshold over $$\phi$$ which is what you are trying to denote with the second formula.

Yes, you do need to slide the threshold so that you segment regions based on the way they "fill up the basins" of an image. But for each threshold you need to calculate a separate $$\phi$$.

The reason for this is because two successive $$\phi$$s (e.g. a given slice and a slice below) will inform your boundary tracking about which way to move towards, or in the level set, which pixels to try to mark as belonging to the same region. This is because, once you have your $$\phi$$ you then put a derivative on it and the derivative is the "instrument" that informs you which way the boundary is going (expanding, contracting, remaining the same).

Hope this helps.

• thank you for your nice answer. I think i understand mostly what you say. I did understand that Gamma is a curve or in other words the set of points where the function is equal to c, but i must admit that i mixed things up a bit after that ... I apologize... I will add something to my question and maybe you can react to it, but again already thanks for your answer, – Machupicchu Jan 14 '19 at 15:46