SKRogers
SKRogers

Reputation: 141

Why is OpenCV's polarWarp introducing artifacts into some images?

I have some small (typically about 60x60 orless) BGR images for which I'm generating polar projections using OpenCV's warpPolar. Most of the time it works fine, but occasionally I get an image (from that same camera source as the images that worked OK) that has a scattering of artifacts within it. Three different interpolation methods all produce artifacts. I did find that increasing the polar radius eliminates the artifacts, but could someone explain why that would make a difference?

Here is code representative of the call to warpPolar:

Mat m = imread( "image.png", IMREAD_COLOR);
Moments mom = moments( m);
int len = //... semi-major axis*2 for ellipse fit
warpPolar( m, polar, Size(), Point( mom.m10/mom.m00, mom.m01/mom.m00) , len, INTER_LINEAR);

Here is an image that works OK:

Source blob #1 --[warpPolar]--> Blob #1 Polar Projection

Here is an image that resulted in a rainbow of artifacts about a quarter of the way down and a band of grayish at the bottom, using NEAREST, LINEAR, and LANCZOS4 respectively:

Source blob #2 --[warpPolar]-> enter image description here enter image description here enter image description here

...and then with longer radius...

enter image description here

Upvotes: 0

Views: 424

Answers (1)

SKRogers
SKRogers

Reputation: 141

The answer to the question is that the warpPolar( ) call needs an additional flag specifying how to fill in pixels outside of the source image. This fixed it:

warpPolar( m, polar, Size(), Point( mom.m10/mom.m00, mom.m01/mom.m00) , len, INTER_LINEAR | CV_WARP_FILL_OUTLIERS);

Upvotes: 2

Related Questions