Loading...
You are not logged-in Login/Register





  • Posts   Search Threads
  • mahanteshJuly 2, 2009 1:41 PM PDT   
    Need help on Image rotation.

    Hi,

    When we rotate image by 90 degree using ippiRotate_8u_C4R() , for MxN resolutions the output is MxN image with 2 black strips at the sides of the image. Is it possible to get rid of these black strips? Is it possible to change the size of the image to NXM ? or Is it possible to change the size of the image to MxM ?

    We are trying to remove these black strips by the calling the function ippiRotate_8u_C4R() and then ippiResizeShift_8u_C4R(), this does the trick but image get stretched and there is peformance hit in our application because of calling two functions. Is there any other way to acieve this through a single call ?

    Thanks,
    Mahantesh



    matthieu.darboisJuly 3, 2009 1:12 AM PDT
    Rate
     
    Re: Need help on Image rotation.

    Quoting - mahantesh
    Hi,

    When we rotate image by 90 degree using ippiRotate_8u_C4R() , for MxN resolutions the output is MxN image with 2 black strips at the sides of the image. Is it possible to get rid of these black strips? Is it possible to change the size of the image to NXM ? or Is it possible to change the size of the image to MxM ?

    We are trying to remove these black strips by the calling the function ippiRotate_8u_C4R() and then ippiResizeShift_8u_C4R(), this does the trick but image get stretched and there is peformance hit in our application because of calling two functions. Is there any other way to acieve this through a single call ?

    Thanks,
    Mahantesh


    Hi,
    I've never used ippiRotate_... for 90, 180, 270 degree rotations, instead I use a combination of mirror and/or transpose functions. I never had time to check if it was faster than ippiRotate but at least I'm sure to get an exact rotation (no rounding...).

    For a 90 degree rotation :
    ippiMirror_8u_C1R(pSrc, srcStep, pTempBuffer, srcStep, srcSize, ippAxsHorizontal);
    ippiTranspose_8u_C1R(pTempBuffer, srcStep, pDst, dstStep, dstSize);
    with dstSize.width = srcSize.height...

    For a 270 degree rotation :
    ippiTranspose_8u_C1R(pSrc, srcStep, pTempBuffer, dstStep, srcSize);
    ippiMirror_8u_C1R(pTempBuffer, dstStep, pDst, dstStep, dstSize, ippAxsHorizontal);

    For a 180 degree rotation :
    ippiMirror_8u_C1R(pSrc, srcStep, pDst, dstStep, roiSize, ippAxsBoth);


    Matthieu


    Ying H (Intel)July 6, 2009 12:52 AM PDT
    Rate
     
    Re: Need help on Image rotation.


    Hi Matthieu,

    Thank you for your suggestion. Yes, we recomment to use ippiMirror to do special rotation like 90,180,270.

    To mahantesh,

    if use ippiRotate, the no-intergate interpolation, round issue are unavaidable.  ippiRotate provide one parameter IPPI_SMOOTH_EDGE to make edge look better.  But the black strips may still visiable. how width of the strips in your test? does it affect your result?

    Here is small piece of code for your reference.

     IppiSize srcTempSize = {w, h};
     IppiSize dstTempSize = {h, w};

    IppiRect srcTempRect = { 0, 0,w, h };
    IppiRect dstTempRect = { 0, 0,h, w };
     double xTempShift = 0.0;
     double yTempShift = 1.0*w; // conterwise rotate 90 degree, origin (0, 0) will be (0, w) after rotation, so the y shift is w

    /* Use this function if you need to rotate an image about an arbitrary center (xCenter, yCenter) rather than the origin (0,0), we will rotate the image by 0, 0 first, so it is not necessary to call it here
    /*
    //ippiGetRotateShift(0.0, 0.0, 90.0, &xTempShift, &yTempShift);

    ippiSet_8u_C4R ( 0, (Ipp8u*) dstTemp->imageData, dstTemp->widthStep, dstTempSize );
    status=ippiRotate_8u_C4R ( (Ipp8u*) srcTemp->imageData, srcTempSize, srcTemp->widthStep, srcTempRect,
           (Ipp8u*) dstTemp->imageData, dstTemp->widthStep, dstTempRect, 90.0,
        xTempShift, yTempShift, IPPI_INTER_LINEAR|IPPI_SMOOTH_EDGE);
    //my test: the rotate operation will show 1 pixel width black line on upper of the rotated image)

    Best Regards,
    Ying
     



    mahanteshSeptember 9, 2009 5:07 PM PDT
    Rate
     
    Re: Need help on Image rotation.

    Quoting - Ying Hu (Intel)

    Hi Matthieu,

    Thank you for your suggestion. Yes, we recomment to use ippiMirror to do special rotation like 90,180,270.

    To mahantesh,

    if use ippiRotate, the no-intergate interpolation, round issue are unavaidable.  ippiRotate provide one parameter IPPI_SMOOTH_EDGE to make edge look better.  But the black strips may still visiable. how width of the strips in your test? does it affect your result?

    Here is small piece of code for your reference.

    IppiSize srcTempSize = {w, h};
    IppiSize dstTempSize = {h, w};

    IppiRect srcTempRect = { 0, 0,w, h };
    IppiRect dstTempRect = { 0, 0,h, w };
    double xTempShift = 0.0;
    double yTempShift = 1.0*w; // conterwise rotate 90 degree, origin (0, 0) will be (0, w) after rotation, so the y shift is w

    /* Use this function if you need to rotate an image about an arbitrary center (xCenter, yCenter) rather than the origin (0,0), we will rotate the image by 0, 0 first, so it is not necessary to call it here
    /*
    //ippiGetRotateShift(0.0, 0.0, 90.0, &xTempShift, &yTempShift);

    ippiSet_8u_C4R ( 0, (Ipp8u*) dstTemp->imageData, dstTemp->widthStep, dstTempSize );
    status=ippiRotate_8u_C4R ( (Ipp8u*) srcTemp->imageData, srcTempSize, srcTemp->widthStep, srcTempRect,
    (Ipp8u*) dstTemp->imageData, dstTemp->widthStep, dstTempRect, 90.0,
    xTempShift, yTempShift, IPPI_INTER_LINEAR|IPPI_SMOOTH_EDGE);
    //my test: the rotate operation will show 1 pixel width black line on upper of the rotated image)

    Best Regards,
    Ying


    Hi Ying,

    Thanks for the pointers to rotate the image. The rotation is working good for all the resolutions except for 160 x 120. Is there anything we need to take care for lower resolutions?

    Thanks,
    Mahantesh



    Ying H (Intel)September 10, 2009 11:55 PM PDT
    Rate
     
    Re: Need help on Image rotation.


    Hello Mahantesh,

    Which IPP vesion are you using?  There are some known issue regarding the ippiResize() at
    http://software.intel.com/en-us/forums/showthread.php?t=66171

    Maybe same. What is symptom when resize the 160x120?

    Best Regards,
    Ying



    mahanteshSeptember 11, 2009 3:45 PM PDT
    Rate
     
    Re: Need help on Image rotation.

    Quoting - Ying H (Intel)

    Hello Mahantesh,

    Which IPP vesion are you using?  There are some known issue regarding the ippiResize() at
    http://software.intel.com/en-us/forums/showthread.php?t=66171

    Maybe same. What is symptom when resize the 160x120?

    Best Regards,
    Ying

    Hi Ying,

    I am using IPP 6.1.1.035. For rotation i am using ippiRotate followed by ippiMirror functions to remove the mirroring effect. The image looks like folded lines for the resoltion 160 x 120.

    Thanks,
    Mahantesh


    Ying H (Intel)September 14, 2009 4:18 AM PDT
    Rate
     
    Re: Need help on Image rotation.


    Hi Mahantesh, 
    Thank you for your reply. I don't rememeber there is known issue for rotating 160x120 specially.

    could you send me a example?

    Best Regards,
    Ying


    mahanteshSeptember 15, 2009 2:20 PM PDT
    Rate
     
    Re: Need help on Image rotation.

    Quoting - Ying H (Intel)

    Hi Mahantesh, 
    Thank you for your reply. I don't rememeber there is known issue for rotating 160x120 specially.

    could you send me a example?

    Best Regards,
    Ying

    Hi Ying,

    I tested this behavior on different systems. On some systems it works good but on some other systems it is like images is turned in to roles. I tried to take print screen but it is coming blank. We are actually rotating video with the help of roation functions.

    One more problem i am facing is, on some systems the rotation along with mirroring function works fine but on some systmes we are getting mirror effect. Not able to judge when to apply mirroring functions and when not to apply. Please let me know when to use mirroring functions and when not to use.

    Thanks,
    Mahantesh




    Ying H (Intel)September 16, 2009 1:38 AM PDT
    Rate
     
    Re: Need help on Image rotation.


    Hi Mahantesh,

    Did you notice which kind of system (CPU type and OS) have the problem?  You may check your cpu type by the way I list in http://software.intel.com/en-us/forums/showthread.php?t=68333  =>item 2

    Thanks
    Ying



    j_milesSeptember 17, 2009 8:09 AM PDT
    Rate
     
    Re: Need help on Image rotation.


    Hi,
    I've never used ippiRotate_... for 90, 180, 270 degree rotations, instead I use a combination of mirror and/or transpose functions. I never had time to check if it was faster than ippiRotate but at least I'm sure to get an exact rotation (no rounding...).

    For a 90 degree rotation :
    ippiMirror_8u_C1R(pSrc, srcStep, pTempBuffer, srcStep, srcSize, ippAxsHorizontal);
    ippiTranspose_8u_C1R(pTempBuffer, srcStep, pDst, dstStep, dstSize);
    with dstSize.width = srcSize.height...

    For a 270 degree rotation :
    ippiTranspose_8u_C1R(pSrc, srcStep, pTempBuffer, dstStep, srcSize);
    ippiMirror_8u_C1R(pTempBuffer, dstStep, pDst, dstStep, dstSize, ippAxsHorizontal);

    For a 180 degree rotation :
    ippiMirror_8u_C1R(pSrc, srcStep, pDst, dstStep, roiSize, ippAxsBoth);


    Matthieu

    We have found that Transpose is faster than Rotate at the 90-degree rotations, and yes, also avoid any potential rounding artefacts. I presume most would want 90-degree rotations to be exact. You can actually improve slightly on the speed by avoiding the Mirroring-calls. This can be done by effectively flipping either the source or the destination image "during" the transposing. This can be done by setting a negative stride and also adjust the associated pointer to point at the start of the last row/line of the image.
    Otherwise, you may consider cutting down on memory use by skipping the temporary buffer and do the mirroring in-place in the 'dst' buffer.


    Regards,

    - Jay


    mahanteshSeptember 30, 2009 12:03 PM PDT
    Rate
     
    Re: Need help on Image rotation.

    Quoting - Ying H (Intel)

    Hi Matthieu,

    Thank you for your suggestion. Yes, we recomment to use ippiMirror to do special rotation like 90,180,270.

    To mahantesh,

    if use ippiRotate, the no-intergate interpolation, round issue are unavaidable.  ippiRotate provide one parameter IPPI_SMOOTH_EDGE to make edge look better.  But the black strips may still visiable. how width of the strips in your test? does it affect your result?

    Here is small piece of code for your reference.

    IppiSize srcTempSize = {w, h};
    IppiSize dstTempSize = {h, w};

    IppiRect srcTempRect = { 0, 0,w, h };
    IppiRect dstTempRect = { 0, 0,h, w };
    double xTempShift = 0.0;
    double yTempShift = 1.0*w; // conterwise rotate 90 degree, origin (0, 0) will be (0, w) after rotation, so the y shift is w

    /* Use this function if you need to rotate an image about an arbitrary center (xCenter, yCenter) rather than the origin (0,0), we will rotate the image by 0, 0 first, so it is not necessary to call it here
    /*
    //ippiGetRotateShift(0.0, 0.0, 90.0, &xTempShift, &yTempShift);

    ippiSet_8u_C4R ( 0, (Ipp8u*) dstTemp->imageData, dstTemp->widthStep, dstTempSize );
    status=ippiRotate_8u_C4R ( (Ipp8u*) srcTemp->imageData, srcTempSize, srcTemp->widthStep, srcTempRect,
    (Ipp8u*) dstTemp->imageData, dstTemp->widthStep, dstTempRect, 90.0,
    xTempShift, yTempShift, IPPI_INTER_LINEAR|IPPI_SMOOTH_EDGE);
    //my test: the rotate operation will show 1 pixel width black line on upper of the rotated image)

    Best Regards,
    Ying


    Hi Ying,

    For the rotate operation using ippiRotate_8u_C3R(), we are getting black line on the rotated image. For resolutions 160x120,176x144,320x240,352x288 the line is thicker and can be easily identified. For 640x480 and higher resolutions its very thin. Is there any way to completely remove these lines? can this be fixed from IPP library? If yes then when this will be available? or any fix can be given from the application using IPP library?

    Thanks,
    Mahantesh


Forum jump:  

Intel Software Network Forums Statistics

16,369 users have contributed to 46,341 threads and 163,954 posts to date.

In the past 24 hours, we have 18 new thread(s) 102 new posts(s), and 67 new user(s).

In the past 3 days, the most popular thread for everyone has been Formula for the intersection of straight lines The most posts were made to Take a look at John Burkhard&# The post with the most views is \"-check none\" generates error

Please welcome our newest member bikerepair8


For more complete information about compiler optimizations, see our Optimization Notice.