Advertisement
brandblox

ImgLab-2-(18-9-24)

Sep 17th, 2024
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. import numpy as np
  2. import cv2
  3.  
  4. img = cv2.imread('peter.jpg',0)
  5. cv2.imshow('Original image',img)
  6. print(img.shape)
  7. new_width = 600
  8. dim_size = (new_width, img.shape[0])
  9. horizonStretchedImg = cv2.resize(img, dim_size, interpolation = cv2.INTER_AREA)
  10.  
  11. cv2.imshow('Horizon stretched image',horizonStretchedImg)
  12. cv2.waitKey(0)
  13. cv2.destroyAllWindows()
  14.  
  15.  
  16.  
  17.  
  18. import numpy as np
  19. import cv2
  20.  
  21. img = cv2.imread('peter.jpg',0)
  22. cv2.imshow('Original image',img)
  23. print(img.shape)
  24. new_height = 600
  25. dim_size = (img.shape[1], new_height)
  26. verticallyStretchedImg = cv2.resize(img, dim_size, interpolation = cv2.INTER_AREA)
  27.  
  28. cv2.imshow('Vertically stretched image',verticallyStretchedImg)
  29. cv2.waitKey(0)
  30. cv2.destroyAllWindows()
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement