Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Image Cropping

jameswelle
Beginner
930 Views
I would like to crop an image using IPP. My image format is 32bpp ARGB and I would like to crop the transparent pixels from the borders of the image.
Is this something that IPP could do? If so, could you point me to the functions I would call. I have looked through the documentation, but I wasn't able to find find any functions that looked like they would do what I needed.

Thanks,
James
0 Kudos
4 Replies
marrisa
Beginner
930 Views

Hi there

For me ,i 've never tried to crop an image using IPP.Because it's a little bit difficult for me.I am not so familiar with IPP.However,i usually crop the image or do other image processing issues using another .NET image SDK.It can easily crop a rectangular section from source image object and save cropped image as a new file.You can have a try.

0 Kudos
Igor_A_Intel
Employee
930 Views

Hi James,

allmost all IPP image processing functions work with ROI - so all what you need - just to define ROI that you would like to extract from your image and use ippiCopy function:

- define the top-left border between transparent and non-transparent pixels

- define the bottom-right border

set pSrc pointer to the top-left, define ROI size as {left-right,top-bottom} and srcStep as you initial image step/pitch; use this new ROI for further processing or use ippiCopy function to copy this ROI to a new one (the new one you can create with ippiMalloc function).

regards, Igor

0 Kudos
Jithin_B_
Beginner
930 Views

Hi Igor,

I just tried cropping an image (an example as shown below) as per your above information. But I am not getting the expected output. Do you know what happens here?

        IppiSize roiSize = {2,2};
        IppiPoint srcOffset = {1,1};
        int stride = pSrc.GetWidth(); //Gives me value 3
        int dstStride = pDst.GetWidth(); // Gives me value 2
        ippiCopy_32f_C1R(pSrc + srcOffset.x + srcOffset.y* stride, stride, pDst, dstStride, roiSize);

Source - pSrc

const float inputImage [1][9] = {{0.0, 0.0, 0.0,
                                              0.0, 1.0, 2.0,
                                              0.0, 3.0, 4.0}};

Expected output - pDst

const float expectedOutput [1][4]= {{1.0, 2.0,
                                                     3.0, 4.0}};

I am getting junk values here

Expected array data:
1 2 3 4

 Tested array data:
8.96831e-44 2 9.37762e-39 0

0 Kudos
Igor_A_Intel
Employee
930 Views

Hi Jithin,

 

In IPP all strides are in bytes (by definition) - so you should multiply your strides above by sizeof(float).

regards, Igor

0 Kudos
Reply