OpenCV  5.0.0alpha-pre
Open Source Computer Vision
Loading...
Searching...
No Matches
samples/python/snippets/logpolar.py

An example using the linearPolar and logPolar operations in python

1#!/usr/bin/env python
2
3'''
4plots image as logPolar and linearPolar
5
6Usage:
7 logpolar.py
8
9Keys:
10 ESC - exit
11'''
12
13# Python 2/3 compatibility
14from __future__ import print_function
15
16import numpy as np
17import cv2 as cv
18
19def main():
20 import sys
21 try:
22 fn = sys.argv[1]
23 except IndexError:
24 fn = 'fruits.jpg'
25
27 if img is None:
28 print('Failed to load image file:', fn)
29 sys.exit(1)
30
31 img2 = cv.logPolar(img, (img.shape[0]/2, img.shape[1]/2), 40, cv.WARP_FILL_OUTLIERS)
32 img3 = cv.linearPolar(img, (img.shape[0]/2, img.shape[1]/2), 40, cv.WARP_FILL_OUTLIERS)
33
34 cv.imshow('before', img)
35 cv.imshow('logpolar', img2)
36 cv.imshow('linearpolar', img3)
37
38 cv.waitKey(0)
39 print('Done')
40
41
42if __name__ == '__main__':
43 print(__doc__)
44 main()
cv::String findFile(const cv::String &relative_path, bool required=true, bool silentMode=false)
Try to find requested data file.
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
int waitKey(int delay=0)
Waits for a pressed key.
void destroyAllWindows()
Destroys all of the HighGUI windows.
CV_EXPORTS_W Mat imread(const String &filename, int flags=IMREAD_COLOR_BGR)
Loads an image from a file.
void linearPolar(InputArray src, OutputArray dst, Point2f center, double maxRadius, int flags)
Remaps an image to polar coordinates space.
void logPolar(InputArray src, OutputArray dst, Point2f center, double M, int flags)
Remaps an image to semilog-polar coordinates space.
int main(int argc, char *argv[])
Definition highgui_qt.cpp:3