[英]how to detect clouds in image using opencv python
i am working on a project using opencv in python in which i want to detect the clouds in an image. 我正在使用在Python中使用opencv的项目,我想在其中检测图像中的云。 i have tried a lot of things but i am stuck.i couldn't find the exact range of cloud color values for hsv color space.
我已经尝试了很多事情,但是我被卡住了。我找不到hsv颜色空间的云颜色值的确切范围。 this is the code i have tried.
这是我尝试过的代码。 the following code detect some of the clouds but not all.this is the code.i have also attached an image which i am getting from this code.
下面的代码检测到一些云,但不是全部。这是代码。我还附加了我从此代码中获得的图像。
import cv2
import numpy as np
img = cv2.imread('E:/sky.jpg', 1)
hsv=cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
white = np.array([255, 255, 255])
lowerBound = np.array([30,30,30])
mask = cv2.inRange(hsv, lowerBound, white)
res = cv2.bitwise_and(img, img, mask=mask)
cv2.imwrite("E:/clouds.jpg",res)
cv2.imshow("mywindow",res)
cv2.waitKey(0)
Try not changing the image to HSV color space. 尽量不要将图像更改为HSV色彩空间。 Remove line
删除线
hsv=cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
The rest of the code clearly shows you are working with a RGB color based scheme and you have no idea what HSV is. 其余代码清楚地表明您正在使用基于RGB颜色的方案,而您不知道什么是HSV。 Frankly speaking, i don't see the need for you to work with HSV color space in the first place.
坦白地说,我不认为您首先需要使用HSV色彩空间。 It can be done even with grayscale image representation.
即使使用灰度图像表示也可以做到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.