PlantVillage数据集中的番茄叶图像分割问题 [英] Segmentation problem for tomato leaf images in PlantVillage Dataset

查看:702
本文介绍了PlantVillage数据集中的番茄叶图像分割问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对番茄作物的叶子图像进行分割.我想转换如下图像

I am trying to do segmentation of leaf images of tomato crops. I want to convert images like following image

跟随黑色背景的图像

我已经从 Github

,但是在此问题上效果不佳,它的功能类似于

but it does not do well on this problem, It does something like this

有人可以建议我这样做吗?

Can anyone suggest me a way to do it ?

推荐答案

使用

The image is separable using the HSV-colorspace. The background has little saturation, so thresholding the saturation removes the gray.

结果:

代码:

import numpy as np 
import cv2
# load image
image = cv2.imread('leaf.jpg')
# create hsv
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
 # set lower and upper color limits
low_val = (0,60,0)
high_val = (179,255,255)
# Threshold the HSV image 
mask = cv2.inRange(hsv, low_val,high_val)
# remove noise
mask = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel=np.ones((8,8),dtype=np.uint8))
# apply mask to original image
result = cv2.bitwise_and(image, image,mask=mask)

#show image
cv2.imshow("Result", result)
cv2.imshow("Mask", mask)
cv2.imshow("Image", image)

cv2.waitKey(0)
cv2.destroyAllWindows()

这篇关于PlantVillage数据集中的番茄叶图像分割问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆