###### tags: `影像處理` # *2022/03/01 影像處理 HW01* ## Coding Part ### 實戰(1) #### 題目: ![](https://i.imgur.com/O7wphon.png) ``` #實戰(1) import numpy as np print(np.log(np.exp(2))) print(np.log2(1024)) print(np.sin(np.pi/6)) print(np.cos(np.pi)) print(np.arcsin(1)) print(np.arccos(1/2)) ``` #### 輸出結果: ![](https://i.imgur.com/MgaTVGJ.png) ### 實戰(2) #### 題目: ![](https://i.imgur.com/excOVx9.png) ``` #實戰(2) import numpy as np import cv2 from google.colab.patches import * #Initial a whole black photo img = np.zeros([100,512],dtype="uint8") for j in range(0,510,2):#Every two column are the same color for i in range(0,100):#Because the wide is 100 img[i][j+1]=img[i][j]#Which means that this block is the same as the previous img[i][j+2]=img[i][j+1]+1#Which means that this block is lightting than previous cv2_imshow(img) ``` #### 輸出結果: ![](https://i.imgur.com/AsF9rel.png) ### 實戰(3) #### 題目: ![](https://i.imgur.com/e6dKMYQ.png) ``` #實戰(3) import numpy as np import cv2 from google.colab.patches import cv2_imshow image = np.zeros([512,512],dtype="uint8")#Set a new black paper for i in range(0,512):#Control the wide for j in range(0,512):#Control the high if (i//64+j//64)%2==0:#If wide//64 + high//64 is even, this pixel is black image[i][j]=0; else: image[i][j]=255#If wide//64 + high//64 is odd, this pixel is white cv2_imshow(image)#Show the image ``` #### 輸出結果: ![](https://i.imgur.com/xXuvIme.png)