Professional Documents
Culture Documents
Lab 1
Lab 1
Lab 1
0.0.1 Topics -
1. Read Images
2. Changing color modes
3. Display Images using Matplotlib
4. Display Images using OpenCV
5. Write Images
6. Accessing color channels of an image
7. Changing pixel values of an image
8. Cropping an image
9. Resizing an image
10. Flipping an image
[9]: type(roses01)
[9]: numpy.ndarray
[10]: roses01.shape
[11]: #print(roses01)
[13]: plt.imshow(roses01_rgb)
1
[15]: roses_r, roses_g, roses_b = cv2.split(roses01_rgb)
[50]: plt.imshow(roses_r)
2
[49]: plt.imshow(roses_g)
3
[51]: plt.imshow(roses_b)
4
[20]: roses_g = roses_g-50
[23]: plt.imshow(roses02_rgb)
5
[26]: nemo01 = cv2.imread('nemo3.jpg',cv2.IMREAD_COLOR)
nemo01 = cv2.cvtColor(nemo01, cv2.COLOR_BGR2RGB)
plt.imshow(nemo01)
6
[28]: nemo01[90, 160]
[31]: plt.imshow(nemo01)
7
[32]: nemo_face = nemo01[75:125, 170:220]
[33]: plt.imshow(nemo_face)
8
[36]: nemo_face = cv2.cvtColor(nemo_face, cv2.COLOR_BGR2RGB)
cv2.imwrite('nemo_face.jpg', nemo_face)
[36]: True
[40]: plt.imshow(nemo_face03)
9
[41]: plt.imshow(nemo01)
10
[42]: nemo01_vf = cv2.flip(nemo01, 0)
[43]: plt.imshow(nemo01_vf)
11
[44]: nemo01_hf = cv2.flip(nemo01, 1)
plt.imshow(nemo01_hf)
12
[45]: nemo01_vhf = cv2.flip(nemo01, -1)
plt.imshow(nemo01_vhf)
13
[ ]:
14