第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

OpenCV中的梯度方向

OpenCV中的梯度方向

慕碼人8056858 2021-05-07 14:12:41
通過Sobel運(yùn)算符,我已經(jīng)能夠確定圖像的梯度大小。我在下面顯示此:現(xiàn)在,我想確定梯度方向。為此,我正在關(guān)注該帖子,該帖子使用了function cv2.phase。然后,根據(jù)函數(shù)的返回角度,將角度硬編碼為特定顏色。我的問題是此函數(shù)為我返回的值在0到90度之間。因此,我得到的圖像僅由紅色和青色組成。我的代碼如下:# 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 blurred grayscale images using filter2Dfiltered_blurred_x = cv2.filter2D(gray_blur, -1, sobel_x)  filtered_blurred_y = cv2.filter2D(gray_blur, -1, sobel_y)# Compute the orientation of the imageorien = cv2.phase(np.array(filtered_blurred_x, np.float32), np.array(filtered_blurred_y, dtype=np.float32), 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)哪個(gè)顯示圖像:
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 339 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)