I dont quite understand Matlab's imimposemin
function described here. According to the documentation the function modifies the grayscale mask image I using morphological reconstruction so it only has regional minima wherever binary marker image BW is nonzero.
In the example that demonstrates the function, Mathworks creates a marker which is a black image with a small white square. According to the documentation imimposemin
(if I undestand well) it should modify the array mask
so it has local minima wherever marker
is nonzero. In other words it should modify mask over that white square only and replace the corresponding values in mask
of those pixels with the regional minimum.
However we see that almost every single pixel of mask
has changed value and the image it self has become lighter. Why?
What am I missing?
it should modify mask over that white square only and replace the corresponding values in
mask
of those pixels with the regional minimum.
This would create local minima at the places indicated by marker
, but the image already had local minima elsewhere, which need to be removed.
From the docs (emphasis mine):
modifies the grayscale mask image
I
using morphological reconstruction so it only has regional minima wherever binary marker imageBW
is nonzero.
That is, the output cannot have local minima outside those specified by marker
. This means that the mask
image must be modified to remove its local minima. This is accomplished by giving the pixels in marker
the lowest possible value, and, propagating from there, pixels get either the value they already had, or the larger value from the neighbor. You should be able to draw a decreasing path from any pixel in the image to one of the pixels in marker
.
This function is typically used in combination with the watershed, which segments the image based on local minima. By imposing your own local minima, you can force the seeds of the watershed algorithm.