Re: [mamba-image] question about segmentByP algorithm

35 views
Skip to first unread message

Serge Beucher

unread,
Sep 26, 2016, 9:25:33 AM9/26/16
to mamba...@googlegroups.com
Hi,

First of all, I recommend to read (if not done yet) this paper describing the operators defined in the hierarchies.py module:

.Towards a unification of waterfalls, standard and P algorithms

For computing the P algorithm, we need to define first a function equal to sup[gain.s0 - 1, s0], where s0 is the initial valued watershed (stored in ImIn and imWrk1). This function which can take values greater than 255 is truncated to 255 (values greater than 255 are replaced by 255) because it will be compared, during the process, to 8-bit images.
The following operations are performed:
- computing gainxS0 - 1 and storing it in imWrk5 (lines 206, 207)
- thresholding the result between 255 and maxvalue (line 208). The result is a binary mask stored in imWrk4, marking all the pixels greater than or equal to 255
- extracting the lower byte of imWrk5 and storing it in the 8-bit image imWrk0 which is now equal to imWrk5 mod 255 (line 209).
- The previous binary mask is then converted to a 8-bit image and sored in imWrk2. The white pixels take now a value equal to 255. (line 210)
- the sup operator in line 211 replaces the values of imWrk0 which correspond initially to values of imWrk5 greater than or equal to 255 by 255, whilst the pixels lowel than 256 are unchanged
- finally the sup with s0 is performed at line 212

I have uploaded on Github some corrections in the display package (float division issue). This should solve your problem with the display. I have not compiled it yet. Tell me if it works.

SB


2016-09-19 14:31 GMT+02:00 <ma...@simonhaenisch.com>:
Hi,

I have a question about the algorithm of the p algorithm (segmentByP in src/python/packages/mamba/hierarchies.py, lines 184-235):

First the input image gets multiplied with a gain and saved into a 32 bit image "imWrk5", I think because the result wouldn't fit into an 8 bit image. Then 3 lines later copyBytePlane() is used to copy the plane with index 0 to an 8 bit image. I don't understand that. The way I see it, "imWrk5" is still a gray-scale image, just with a larger range (uint32 instead of uint8).

What's the purpose of copying just the first byte of a 4 byte pixel value?

Or is this really just a conversion from 32 bit to 8 bit gray-scale? I can't read that from the doc-string however...

--
You received this message because you are subscribed to the Google Groups "Mamba Image" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mamba-image+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages