1

i am working on a project using opencv in python in which i want to detect the clouds in an image. 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. 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.

enter image description here

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)
8
  • You assign a value of [255,255,255] for white in HSV colorspace? HSV is not RGB Commented Nov 14, 2017 at 10:52
  • if i change [255,255,255] to [0,0,100] which is hsv for [255,255,255] then it make it all black. the image become all black..is there any problem with my code? Commented Nov 14, 2017 at 10:58
  • "If I change..." are you blindly trying combinations of numbers? Where does the [30,30,30] come from? What color does it represent in HSV (remember you are not in RGB) Commented Nov 14, 2017 at 11:02
  • [30,30,30] is a dark greenish color in HSV, nothing to do with your sky or clouds color Commented Nov 14, 2017 at 11:04
  • 1
    Possible duplicate of Tracking white color using python opencv Commented Nov 14, 2017 at 12:03

1 Answer 1

0

Try not changing the image to HSV color space. 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. Frankly speaking, i don't see the need for you to work with HSV color space in the first place. It can be done even with grayscale image representation.

Sign up to request clarification or add additional context in comments.

3 Comments

now i understand that i was working with RGB but now i don't know the color range for clouds. i have searched a lot but couldn't find the hsv values to detect clouds.
and by removing the line of code which convert the image from BGR to HSV is not giving me my desired result
then you should go and do some research on the function name adaptivethreshold

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.