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

Using a negative offset in the dstRoi parameter of ippiRotateCenter

georgiswan
Beginner
1,333 Views
Hello,

Q: can I use a negative offset in the dstRoi parameter in ippiRotateCenter ?

When I try to do so, I get an error ( ippStsSizeErr ). However, I make sure the all pixels in the ROI (eventually used with negative index) exist and are properly allocated).

~~~~

Why do I need a negative offset?

Sorry for the long story, the followingis just to justify my need of a negative offset in the dstROI:

I am using the ippiRotateCenter function to rotate a small tile of variable size of an image : I am only interested in the tile region centerred around the center point (parameters xCenter and yCenter) after rotation.

If I understand well that function, the center point (xCenter, yCenter) will have the same coordinates in the src and destination image (we are rotating about that point). So, if I only want a small rotated tile around the center point, I need to offset my dst pointer, example:

pDst = pDst - (xCenter - dstWidth/2)- (yCenter - dstHeight/2) * dstStep ;

to have the center point at the center of my dst image (assuming a 1 channel byte image) and set a small size ROI and an offset that takes into account the center point:

dstROI = { xCenter - dstWidth/2, yCenter - dstHeight/2, dstWidth, dstHeight }

The dst image ROI is then a small rectanglewith a relatively large offset WRT image origin. However, when the desired size of the dst image grows compare to the radius of the center point, my offset in x and/or in y becomes negative and the routine returns an error.I dont see what is wrong with my usage...but there must be something wrong. ..

~~~~

Thank you!

Gilbert
0 Kudos
4 Replies
PaulF_IntelCorp
Employee
1,333 Views
I'm sorry, but I don't understand how you could supply a "negative offset in the dstRoi parameter." According to the definition of ippiRotateCenter, this parameter is an IppiRectstructure...

typedef structure _IppiRect {
	int 	x;
	int 	y;
	int 	width;
	int 	height;
}

Perhaps I have misunderstood your question...
0 Kudos
georgiswan
Beginner
1,333 Views
I may have abused the IPP notion of x and y in the IppiRect. According to the doc:



The structure IppiRect for storing the geometric position and size of a rectangle is defined as

typedef struct {
int x;
int y;
int width;
int height;
} IppiRect;

where x,y denote the coordinates of the top left corner of the rectangle that has dimensions width in the x-direction by height in the y-direction.


So, I simply entered a negative value for x and/or y to point behind the image pointer (coordinates values (x,y) of the top left corner of a ROI can be negative -- of course, width and height must be positive). That would position the ROI in the region of the space where I was interested to get the src image after rotation (after rotation, the src image can effectively cover a region of the space where you would need negative index to reach). For most functions, negative image indices dont make much sense but for a rotation, they might make sense). I had applied an offset to my dst pointer to avoid memory out of bound access: i.e. all index (even negative ones) when legal in my ROI using the pointer provided to the routine.

My approach worked for large positive indices (also way outside the original source image) but always failed for negative indices ( this can happen when the center point (x,y) is close to the origin of the source imageand I want a large destination region, larger then the radius of the center point sqrt(centerx^2 + centery^2) ).

I think that using negative x or y in IppiRect is simply blindly forbidden in IPP. So, I solved my problem by giving up rotateCenter andusing ippiRotate instead with (sometimes negative) shiftx and shifty values that give me the right view of the source image after rotation.
0 Kudos
PaulF_IntelCorp
Employee
1,333 Views
Glad to hear you found a workable solution.
0 Kudos
Kadir_Kirtac
Beginner
1,333 Views
Hello, I want to rotate my image along its center, by "angle" degrees in the clockwise direction.
ippiRotateCenter function wants me to specify the destination size. But the destination size should change based on the current "angle" value. How can I compute my destination image size using the angle value?
0 Kudos
Reply