#Day 1 # learning content: an image reading, display, delete, save as, read and modify pixel,

1 #day 
# learning content: an image reading, display, delete, save as, read and modify pixel,
Import CV2
Import numpy AS NP

Image = cv2.imread ( "D: \ OpenCV \ CVproject \ Image / lenacolor.png" ) # image reading
cv2.imshow ( "show", image) # image display


#ROI face extraction
A np.ones = (( 100, 100, . 3))
A = Image [ 200 is: 390, 230: 350] #lenacolor face location
cv2.imshow ( "face1", A)
Image [ 0: 190, 0: 120] A =
cv2.imshow ( "face2", image) # an image projecting face parts


#BGR three separate pixels
B, G, R & lt cv2.split = (image) # may be a single extraction b = cv2.split (image) [0]
cv2.imshow ( "Blue", B)

Print (image.shape) # output image row, a column, the channel
rows, cols, CHN image.shape =
G = np.zeros (( rows, cols), image.dtype) # orderg channels 0
R & lt np.zeros = ((rows, cols), image.dtype)
m = cv2.merge ([B, g, R & lt])
cv2.imshow ( "Merge", m)



cv2.imwrite ( "D : \ OpenCV \ Image / merge.jpg ", m) # Save window as



cv2.waitKey ( 0) # window waiting
cv2.destroyAllWindows () # window delete

Guess you like

Origin www.cnblogs.com/jdxxuexi/p/12164305.html