该版本的巨蟒:如何认识到粉红色的木材的图像?

0

的问题

怎么我可以认识到 粉红色的木 图像? 我用这个代码但我没有找到任何粉红色的小木图像。

我希望如果给我这样的图像作为输入、输出的 粉红色的 木材将得到承认。

这比其他方法,你有一个建议认识到粉红色的木材????

输入:

产出预期(手动标示)

代码:

import numpy as np


import cv2
from cv2 import *
im = cv2.imread(imagePath)

im = cv2.bilateralFilter(im,9,75,75)
im = cv2.fastNlMeansDenoisingColored(im,None,10,10,7,21)
hsv_img = cv2.cvtColor(im, cv2.COLOR_BGR2HSV)   # HSV image


COLOR_MIN = np.array([233, 88, 233],np.uint8)       # HSV color code lower and upper bounds
COLOR_MAX = np.array([241, 82, 240],np.uint8)       # color pink 

frame_threshed = cv2.inRange(hsv_img, COLOR_MIN, COLOR_MAX)     # Thresholding image
imgray = frame_threshed
ret,thresh = cv2.threshold(frame_threshed,127,255,0)
contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
print(contours)
for cnt in contours:
    x,y,w,h = cv2.boundingRect(cnt)
    print(x,y)
    cv2.rectangle(im,(x,y),(x+w,y+h),(0,255,0),2)
cv2.imwrite("extracted.jpg", im)

输出代码:

print(contours)
()

问题是,粉红色的木材是不承认

1

最好的答案

1

改变你的单纯疱疹病毒的下限和上限如下:

COLOR_MIN = np.array([130,0,220],np.uint8)    
COLOR_MAX = np.array([170,255,255],np.uint8)  

enter image description here

2021-11-22 21:03:20

谢谢你的回答。 这就是答案。 一个问题,为什么你选择了这个颜色? [170,255,255]
M. Farzalizadeh

只是玩那些单纯疱疹病毒的范围。正常的单纯疱疹病毒的范围:H=在0-360,S=0到100和V=0到100. 该版本的单纯疱疹病毒的范围:H:0-179、S:0至255,V:为0-255。不同的应用程序的使用不同的尺度对于单纯疱疹病毒。 请参阅类似的问题[stackoverflow.com/questions/10948589/...
Nishani Kasineshan

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................