logpolar.py 772 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env python
  2. '''
  3. plots image as logPolar and linearPolar
  4. Usage:
  5. logpolar.py
  6. Keys:
  7. ESC - exit
  8. '''
  9. # Python 2/3 compatibility
  10. from __future__ import print_function
  11. import cv2
  12. if __name__ == '__main__':
  13. print(__doc__)
  14. import sys
  15. try:
  16. fn = sys.argv[1]
  17. except IndexError:
  18. fn = '../data/fruits.jpg'
  19. img = cv2.imread(fn)
  20. if img is None:
  21. print('Failed to load image file:', fn)
  22. sys.exit(1)
  23. img2 = cv2.logPolar(img, (img.shape[0]/2, img.shape[1]/2), 40, cv2.WARP_FILL_OUTLIERS)
  24. img3 = cv2.linearPolar(img, (img.shape[0]/2, img.shape[1]/2), 40, cv2.WARP_FILL_OUTLIERS)
  25. cv2.imshow('before', img)
  26. cv2.imshow('logpolar', img2)
  27. cv2.imshow('linearpolar', img3)
  28. cv2.waitKey(0)