脚部压力点,用于在脚部扫描图像中进行前旋检测

时间:2019-01-02 18:07:06

标签: c# opencv image-processing

在脚部扫描图像中检测到脚内翻时存在问题,我尝试根据阈值标记压力点并能够获得一些结果,但是该技术在脚色较暗的那些图像中失败了。我尝试过的结果是Here,但我希望最终结果看起来像这些Feet Image Results
任何帮助/建议将不胜感激。
谢谢

修改 我添加了手的扫描图像,其中压力点被圈出,并且处理过的图像应该只能检测压力点,但是如上所述,它基于皮肤的颜色而失败。我正在应用颜色阈值。检测失败的图像是Here

1 个答案:

答案 0 :(得分:0)

没有足够的色差来轻松实现此目的。我尝试通过增加对比度并转换为HSV色彩空间(info-opencv)来简化颜色选择。

结果:

enter image description here

# load image
img = cv2.imread("hand.png")

#increase contrast
new_image = np.zeros(img.shape, img.dtype)
alpha = 4 # Simple contrast control
beta = -300    # Simple brightness control
for y in range(img.shape[0]):
    for x in range(img.shape[1]):
        for c in range(img.shape[2]):
            new_image[y,x,c] = np.clip(alpha*img[y,x,c] + beta, 0, 255)

# convert to HSV
hsv = cv2.cvtColor(new_image, cv2.COLOR_BGR2HSV) 
# set lower and upper color limits
lower_val = np.array([30,0,200])
upper_val = np.array([75,240,255])
# Threshold the HSV image 
mask = cv2.inRange(hsv, lower_val, upper_val)
# remove noise
kernel =  np.ones((3,3),np.uint8)
mask = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel)

# select whole hand
# set lower and upper color limits
lower_val = np.array([0,0,100])
upper_val = np.array([179,255,255])
# Threshold the HSV image 
mask2 = cv2.inRange(hsv, lower_val, upper_val)

# create a mask that has the whole hand, but not the prssure points
mask_combined = cv2.bitwise_xor(mask, mask2)
# Create a copy of the image
image = img.copy()
# Fill copy image with a blue-green-ish color
image[:] = (150, 150, 20)
# use the combined mask to color in upressured area's of the hand
res2 = cv2.bitwise_and(image,image, mask= mask_combined)
# Fill copy image with red color(set each pixel to red)
image[:] = (20, 20, 205)
# use the pressure mask to color in pressured area's
res = cv2.bitwise_and(image,image, mask= mask)
# combine colored images
final = dst = cv2.add(res2,res)
#show image
cv2.imshow("img", img)
cv2.imshow("result", final)
cv2.imshow("mask", mask)
cv2.imshow("mask2", mask_combined)
cv2.waitKey(0)
cv2.destroyAllWindows()      

注意:我裁剪了您提供的图像,如果您拥有完整的图像,则可以通过调整颜色限制和形态来改善结果-阅读here