Reputation: 141
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:
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:
...and then with longer radius...
Upvotes: 0
Views: 424
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