- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ippiFilterBilateral_8u_C1R
But the 3 channel version (color RGB image) is missing ?
( ippiFilterBilateral_8u_C3R seems to be missing )
How can I apply bilateral image on color image using Intel IPP ?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1)
IPPAPI( Ipp8u*, ippiMalloc_8u_C1, ( int widthPixels, int heightPixels, int* pStepBytes ) ) - use 3*height here and calculate 3 pointers to P planes: P[0] == initilalpointer after allocation, P[1] = P[0] + height * stepBytes, P[2] = P[1] + height * step Bytes
then do the same for Dst
IPPAPI ( IppStatus, ippiCopy_8u_C3P3R, ( const Ipp8u* pSrc, int srcStep, Ipp8u* const pDst[3], int dstStep, IppiSize roiSize ))
then 3 times for each P[]:
IPPAPI(IppStatus,ippiFilterBilateral_8u_C1R,( const Ipp8u *pSrc, int srcStep, Ipp8u *pDst, int dstStep, IppiSize dstRoiSize, IppiSize kernelSize, IppiFilterBilateralSpec *pSpec))
and finally
IPPAPI ( IppStatus, ippiCopy_8u_P3C3R, (const Ipp8u* const pSrc[3], int srcStep, Ipp8u* pDst, int dstStep, IppiSize roiSize ))
2) think better from the performance point of view:
IPPAPI( Ipp8u*, ippiMalloc_8u_C1, ( int widthPixels, int heightPixels, int* pStepBytes ) ) - 2 times - for src & dst, or better 1 time but 2x height and use the same formula as for p[1] for temporal dst buffer pointer
then 3 times (for pSrc, pSrc+1 and pSrc+2, and for pDst, pDst+1 and pDst+2 for final copy):
IPPAPI( IppStatus, ippiCopy_8u_C3C1R,( const Ipp8u* pSrc, int srcStep,Ipp8u* pDst, int dstStep, IppiSize roiSize ))
IPPAPI(IppStatus,ippiFilterBilateral_8u_C1R,( const Ipp8u *pSrc, int srcStep, Ipp8u *pDst, int dstStep, IppiSize dstRoiSize, IppiSize kernelSize, IppiFilterBilateralSpec *pSpec))
IPPAPI( IppStatus, ippiCopy_8u_C1C3R, ( const Ipp8u* pSrc, int srcStep, Ipp8u* pDst, int dstStep, IppiSize roiSize ))
and this approach should be faster than C3 Bilateral filtering of C3 image
Regards,
Igor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for the detailed reply. I will try to implement the method you suggested.
I have one major concern, which relates to the fact that applying bilateral filter to each plane separately is ALGORITHMICALLY different than applying the filter to all planes simultaneously.
This is because each pixel value is averaged with its neighbors such that the averaging weight of the pixel with a neighbor depends on the color difference between the pixel color and the neighbor color, wherein the difference is measured in all 3 color bands simultaneously.
Lets examine the case of averaging the green component of a pixel with a neighbor which have a similar green level but very different red level.
1) If we filter each plane separately, then the neighbor will get high weight during the averaging because the green levels of the pixel and the neighbor are close.
2) If we filter all planes simultaneously, then the neighbor will get a lower weight during the averaging because even though the green channels of the pixel and the neighbor are close in value, the red levels are very different, and therefore the total RGB color (or LAB color) will have a large difference.
I assume from your response that an IPP function which calculates bilateral filter for 3 bands color image is not available, so I will try your method of averaging each plane separately, and hopefully results will not differ too much.
Thanks,
Roy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
this is the way all filters in ippIP are implemented - for C3/C4/AC4 images all channels are filtered independently
Regards,
Igor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I implemented both the IPP version which filters each channel independently, and the OpenCV 3.2.1 bilateral filter which measures color distances on all 3 bands (RGB) simultaneously.
1) Color conversion from RGB to LAB seems much faster with IPP than with OpenCV.
2) IPP bilateral filter is faster with IPP than with OpenCV. but, the result of OpenCV seems better (my subjective opinion). This is probably because OpenCV uses 3-band color distances, and not separate distance for each band. Also, it seems that OpenCV implements the distance by taking abs(R1-R2)+abs(G1-G2)+abs(B1-B2) which might give more moderate decrease in averaging weight as the color distance increases , when compared to using the square distance.
Hope Intel will develop someday a multi-channel color distance based IPP bilateral filter !
B.R.
Roy
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page