亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將顏色應用于漸變方向

將顏色應用于漸變方向

Cats萌萌 2021-05-10 17:45:57
關于此帖子,當在圖像上硬編碼顏色的漸變方向的度數時,應將強度發生變化的位置涂上顏色,而沒有變化的位置應將圖像涂成黑色。我不確定在那個帖子中是如何實現的。由于為所有度值分配了一種顏色,因此可以為圖像中的所有像素著色,并且不會留下任何黑色。我的代碼如下:# where gray_blur is a grayscale image of dimension 512 by 512# 3x3 sobel filters for edge detectionsobel_x = np.array([[ -1, 0, 1],                    [ -2, 0, 2],                    [ -1, 0, 1]])sobel_y = np.array([[ -1, -2, -1],                    [ 0, 0, 0],                    [ 1, 2, 1]])# Filter the orginal and blurred grayscale images using filter2Dfiltered = cv2.filter2D(gray_noise, cv2.CV_32F, sobel_x)filtered_blurred_x = cv2.filter2D(gray_blur, cv2.CV_32F, sobel_x)  filtered_blurred_y = cv2.filter2D(gray_blur, cv2.CV_32F, sobel_y) # Compute the orientation of the imageorien = cv2.phase(filtered_blurred_x, filtered_blurred_y, angleInDegrees=True)image_map = np.zeros((orien.shape[0], orien.shape[1], 3), dtype=np.int16)# Define RGB coloursred = np.array([255, 0, 0])cyan = np.array([0, 255, 255])green = np.array([0, 255, 0])yellow = np.array([255, 255, 0])# Set colours corresponding to anglesfor i in range(0, image_map.shape[0]):    for j in range(0, image_map.shape[1]):        if orien[i][j] < 90.0:            image_map[i, j, :] = red        elif orien[i][j] >= 90.0 and orien[i][j] < 180.0:            image_map[i, j, :] = cyan        elif orien[i][j] >= 180.0 and orien[i][j] < 270.0:            image_map[i, j, :] = green        elif orien[i][j] >= 270.0 and orien[i][j] < 360.0:            image_map[i, j, :] = yellow# Display gradient orientationf, ax1 = plt.subplots(1, 1, figsize=(20,10))ax1.set_title('gradient orientation')ax1.imshow(image_map)我的代碼在左側產生輸出,而我相信正確的表示形式將是右側的圖像:我想我缺少將每個像素硬編碼為其中一種顏色的方法。
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 141 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號