Computer Vision Assignment – 1
Sudheera Sivani Billakurti - S20160010014
Subhadeep Dash - S20160010021
V. Tejkiran - S20160020155
Question-1: Hybrid images
1. Initialization of libraries:
1. import numpy as np
2. from matplotlib import pyplot as plt
3. from matplotlib import image as mpimg
The above snippet of code is for importing the libraries numpy for vectorization and matplotlib for
reading and displaying images.
2. Hybrid Image conversion function:
1. def hybridImages(image1, image2, alpha, beta):
2. def highpass(values, alpha):
3. (M, N) = (values.shape[0], values.shape[1])
4. for i in range(M):
5. for j in range(N):
6. if(np.linalg.norm((i, j)) < alpha):
7. values[i, j] = 0
8. return values
9. def lowpass(values, beta):
10. (M, N) = (values.shape[0], values.shape[1])
11. for i in range(M):
12. for j in range(N):
13. if(np.linalg.norm((i, j)) > beta):
14. values[i, j] = 0
15. return values
16. image1 = np.array(mpimg.imread(image1))
17. image2 = np.array(mpimg.imread(image2))
18. if(image1.shape != image2.shape):
19. if(image1.shape > image2.shape):
20. image1 = image1[:image2.shape[0], :image2.shape[1]]
21. else:
22. image2 = image2[:image1.shape[0], :image1.shape[1]]
23. red1 = image1[:, :, 0]
24. green1 = image1[:, :, 1]
25. blue1 = image1[:, :, 2]
26. red2 = image2[:, :, 0]
27. green2 = image2[:, :, 1]
28. blue2 = image2[:, :, 2]
29. plt.figure();
30. plt.imshow(image1)
31. plt.show();
32. plt.figure();
33. plt.imshow(image2);