Load, Display and Save an image
This post helps you to load,display and save an image using python and openCV.
Steps:
- Load image using cv2.imread().
 - Display image using cv2.namedWindow() and cv2.imshow().
 - Save the image using cv2.imwrite().
 - Wait for keyboard button press using cv2.waitKey().
 - Destroy all windows using cv2.destroyAllWindows().
 
cv2.imread(filename[,flags])
| Parameters: | 
  | 
|---|
cv2.imwrite(filename,img[,params])
| Parameters: | 
  | 
|---|
cv2.imshow(winname,image)
| Parameters: | 
  | 
|---|
cv2.waitKey([delay])
Parameters: - delay – Delay in milliseconds. 0 is the special value that means “forever”.The function waitKey waits for a key event infinitely (when delay<=0 ) or for delay milliseconds, when it is positive.
 
Example:
----------------------
import cv2 # Load an color image in grayscale img = cv2.imread('image1.jpg',0) #Display the image cv2.namedWindow('image', cv2.WINDOW_AUTOSIZE) cv2.imshow('image',img) #Save the image cv2.imwrite('result.jpg',img) cv2.waitKey(0) cv2.destroyAllWindows()
gy697 louisvuitton-replica zf067
ReplyDelete