- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
it is often needed to threshold image from gray colors to black/white. There are many Threshold functions, but I can not find any which is able to do it.
For example we have 1 channel image with Ipp8u pixel size. I want do:
if [pixel] <= threshold then set it to lowValue else set it to hiValue
There is: Threshold_LTValGTVal which allows me specify two thresholds and two values, but conditions are LT and GT so when I use:
ippiThreshold_LTValGTVal_8u_C1IR(pSrcDst, srcDstStep, roiSize, 127, 0, 127, 255)
Pixels with value 127 remain unchanged, does not ?
And according to documentation I can not specify thresholdLT (128) > thresholdGT (127)
So is there any workaround or do you plan introduce new function ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use ippiCompareC to threshold to a black-and white mask. Note that the destination mask will be of type 8u, even if the source image has type 16u or 32f.
For more complicated thresholding operations of 8u or 16u images, you can also consider using ippiLUTPalette.
Regards,
Adriaan van Os
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ladislav,
It is real a problem as you said. I will submit to our developer team. Thanks.
Best regards,
Fiona
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ladislav,
If you just intend to realize the binarization but do not care about the data type or image mode, you could refer the convert function ippiGrayToBin. However the output is 1u for binary data not 8u.
Best regards,
Fiona
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Fiona,
thank you for your comments. I am aware of GrayToBin function, but it is not usable in my case. I need in-place thresholding of 8u image as I wrote: if [pixel] <= threshold then set it to lowValue else set it to hiValue
(or simplified: if [pixel] <=127 then set it to 0 else set it to 255)
I think that it is very common scenario used in binarization of gray scaled images, does not ?
Do you think that developement team will provide any feedback ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ladislav,
I already submitted your feature request, we will consider it. Right now, the simplest solution is to call Threshold_LTVal and Threshold_GTVal separately to realize the functionality.
Best regards,
Fiona
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Fiona,
For now I did it as you recommended. Please let me know if you decide implement this feature request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Sergey: but I do not need wider range. I need threshold grayscaled 8u image with 256 possible values per each pixel to 0 (black) or 255 (white). There is function: ippiThreshold_LTValGTVal_8u_C1IR, but it cannot be used as explained above.
So only workaround for now is use two calls:
ippiThreshold_LTVal_8u_C1IR(pSrcDst, srcDstStep, roiSize, AThreshold+1, 0);
ippiThreshold_GTVal_8u_C1IR(pSrcDst, srcDstStep, roiSizei, AThreshold, 255);
Which seems to me not so efficient as one call would be.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Needed here as well: threshold a grey (u8) image with px = px < threshold ? 0 : 255; etc. Now this has to be done in two steps with IPP which is a performance drawback.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use ippiCompareC to threshold to a black-and white mask. Note that the destination mask will be of type 8u, even if the source image has type 16u or 32f.
For more complicated thresholding operations of 8u or 16u images, you can also consider using ippiLUTPalette.
Regards,
Adriaan van Os
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes ippiCompareC works as expected. Thank you. I can use it also as in-line (Src=Dst):
ippiCompareC_8u_C1R(Src, Width, AThreshold, Src, Width, roiSize, ippCmpGreaterEq);

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page