Skip to content

Commit 03bbee3

Browse files
Roman DonchenkoOpenCV Buildbot
authored andcommitted
Merge pull request opencv#1486 from nzjrs:cv2-logpolar
2 parents f68b73f + 5134173 commit 03bbee3

File tree

3 files changed

+56
-8
lines changed

3 files changed

+56
-8
lines changed

modules/imgproc/include/opencv2/imgproc.hpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,15 @@ enum { MORPH_RECT = 0,
7676
};
7777

7878
//! interpolation algorithm
79-
enum { INTER_NEAREST = 0, //!< nearest neighbor interpolation
80-
INTER_LINEAR = 1, //!< bilinear interpolation
81-
INTER_CUBIC = 2, //!< bicubic interpolation
82-
INTER_AREA = 3, //!< area-based (or super) interpolation
83-
INTER_LANCZOS4 = 4, //!< Lanczos interpolation over 8x8 neighborhood
84-
85-
INTER_MAX = 7, //!< mask for interpolation codes
86-
WARP_INVERSE_MAP = 16
79+
enum { INTER_NEAREST = 0, //!< nearest neighbor interpolation
80+
INTER_LINEAR = 1, //!< bilinear interpolation
81+
INTER_CUBIC = 2, //!< bicubic interpolation
82+
INTER_AREA = 3, //!< area-based (or super) interpolation
83+
INTER_LANCZOS4 = 4, //!< Lanczos interpolation over 8x8 neighborhood
84+
85+
INTER_MAX = 7, //!< mask for interpolation codes
86+
WARP_FILL_OUTLIERS = 8,
87+
WARP_INVERSE_MAP = 16
8788
};
8889

8990
enum { INTER_BITS = 5,
@@ -1227,6 +1228,14 @@ CV_EXPORTS_W Mat getAffineTransform( InputArray src, InputArray dst );
12271228
CV_EXPORTS_W void getRectSubPix( InputArray image, Size patchSize,
12281229
Point2f center, OutputArray patch, int patchType = -1 );
12291230

1231+
//! computes the log polar transform
1232+
CV_EXPORTS_W void logPolar( InputArray src, OutputArray dst,
1233+
Point2f center, double M, int flags );
1234+
1235+
//! computes the linear polar transform
1236+
CV_EXPORTS_W void linearPolar( InputArray src, OutputArray dst,
1237+
Point2f center, double maxRadius, int flags );
1238+
12301239
//! computes the integral image
12311240
CV_EXPORTS_W void integral( InputArray src, OutputArray sum, int sdepth = -1 );
12321241

modules/imgproc/src/imgwarp.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4327,6 +4327,14 @@ cvLogPolar( const CvArr* srcarr, CvArr* dstarr,
43274327
cvRemap( src, dst, mapx, mapy, flags, cvScalarAll(0) );
43284328
}
43294329

4330+
void cv::logPolar( InputArray _src, OutputArray _dst,
4331+
Point2f center, double M, int flags )
4332+
{
4333+
Mat src = _src.getMat();
4334+
_dst.create( src.size(), src.type() );
4335+
CvMat c_src = src, c_dst = _dst.getMat();
4336+
cvLogPolar( &c_src, &c_dst, center, M, flags );
4337+
}
43304338

43314339
/****************************************************************************************
43324340
Linear-Polar Transform
@@ -4422,5 +4430,13 @@ void cvLinearPolar( const CvArr* srcarr, CvArr* dstarr,
44224430
cvRemap( src, dst, mapx, mapy, flags, cvScalarAll(0) );
44234431
}
44244432

4433+
void cv::linearPolar( InputArray _src, OutputArray _dst,
4434+
Point2f center, double maxRadius, int flags )
4435+
{
4436+
Mat src = _src.getMat();
4437+
_dst.create( src.size(), src.type() );
4438+
CvMat c_src = src, c_dst = _dst.getMat();
4439+
cvLinearPolar( &c_src, &c_dst, center, maxRadius, flags );
4440+
}
44254441

44264442
/* End of file. */

samples/python2/logpolar.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
import cv2
3+
4+
if __name__ == '__main__':
5+
import sys
6+
try:
7+
fn = sys.argv[1]
8+
except:
9+
fn = '../cpp/fruits.jpg'
10+
11+
img = cv2.imread(fn)
12+
if img is None:
13+
print 'Failed to load image file:', fn
14+
sys.exit(1)
15+
16+
img2 = cv2.logPolar(img, (img.shape[0]/2, img.shape[1]/2), 40, cv2.WARP_FILL_OUTLIERS)
17+
img3 = cv2.linearPolar(img, (img.shape[0]/2, img.shape[1]/2), 40, cv2.WARP_FILL_OUTLIERS)
18+
19+
cv2.imshow('before', img)
20+
cv2.imshow('logpolar', img2)
21+
cv2.imshow('linearpolar', img3)
22+
23+
cv2.waitKey(0)

0 commit comments

Comments
 (0)