Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/samples/python/logpolar.py
16337 views
1
#!/usr/bin/env python
2
3
'''
4
plots image as logPolar and linearPolar
5
6
Usage:
7
logpolar.py
8
9
Keys:
10
ESC - exit
11
'''
12
13
# Python 2/3 compatibility
14
from __future__ import print_function
15
16
import cv2 as cv
17
18
if __name__ == '__main__':
19
print(__doc__)
20
21
import sys
22
try:
23
fn = sys.argv[1]
24
except IndexError:
25
fn = '../data/fruits.jpg'
26
27
img = cv.imread(fn)
28
if img is None:
29
print('Failed to load image file:', fn)
30
sys.exit(1)
31
32
img2 = cv.logPolar(img, (img.shape[0]/2, img.shape[1]/2), 40, cv.WARP_FILL_OUTLIERS)
33
img3 = cv.linearPolar(img, (img.shape[0]/2, img.shape[1]/2), 40, cv.WARP_FILL_OUTLIERS)
34
35
cv.imshow('before', img)
36
cv.imshow('logpolar', img2)
37
cv.imshow('linearpolar', img3)
38
39
cv.waitKey(0)
40
41