# Image Acquisition

# Reading Images

import numpy as np         #array library
import cv2

img = cv2.imread('pathto/name.png')
type(img) #numpy.ndarray


img = cv2.imread('wrongpathto/name.png')
type(img) #NoneType

1
2
3
4
5
6
7
8
9
10

# Creating Images

#creating blank images
blank_img = np.zeros(shape=(512,512,3),dtype=np.int16)

#creating blank similar size images
copy = np.zeros_like(img)   

1
2
3
4
5
6

# Retriving Images Property

row , col , dimension = img.shape()
1

# Displaying Images

cv2.imshow('name',img)
cv2.waitKey(0)
1
2

Displaying the image to our screen is handled by the cv2.imshow function. The first argument to cv2.imshow is a string containing the name of our window. This text will appear in the titlebar of the window.

If this encountered error

while True:
	cv2.imshow('name',img)
	#If we waited for atleast 1ms and pressed escape
	if cv2.waitKey(1) & 0xFF == 27:
		break
cv2.destroyALLWindows()
1
2
3
4
5
6

# Saving Images

 imwrite( "name.jpg", img );
1