Ask Your Question
0

How do I use this image as a mask to perform segmentation?

asked 2020-02-07 06:48:45 -0600

tsabbir96 gravatar image

updated 2020-02-07 06:49:26 -0600

Hello I have this image:

image

i want to use this black and white image as a mask to segment the clouds from this RGB image :

image

However I am having some problem achieving this, as the black and white image is not in binary form. when i print the values of the image it prints some compex number. please kindly have a look at this attached image:

image

Please could you help me by showing a way on how to use this weird black and white image as a mask to segment clouds from the RGB image that I have attached?

btw I am a student and I am really really new to image processing. I Would appreciate your help a lot. Thank you.

edit retag flag offensive close merge delete

Comments

it prints some compex number

no, it's the first and last 20 numbers from your "mask", which is is floating point format

berak gravatar imageberak ( 2020-02-07 07:54:23 -0600 )edit

so if i see "2.4444e-1" such type of numbers, they are basically floating point numbers, yes?

tsabbir96 gravatar imagetsabbir96 ( 2020-02-07 08:27:38 -0600 )edit

yes. how did you acquire it, btw ? (unusual format)

berak gravatar imageberak ( 2020-02-07 08:52:08 -0600 )edit
1

I generated it from a DNN. I trained a DNN to output black and white images of the clouds. I used the same DNN mentioned in this github: https://github.com/Soumyabrata/CloudS... then i used the trained model to predict the output which is the black and white image I attached

tsabbir96 gravatar imagetsabbir96 ( 2020-02-07 08:56:26 -0600 )edit

^^ awesome ;)

berak gravatar imageberak ( 2020-02-07 09:09:18 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-02-07 08:44:50 -0600

berak gravatar image

updated 2020-02-07 08:47:42 -0600

the most common way to get a binary image is thresholding :

#help(cv2.threshold)
# assume, "gray" is your "mask" image above
thr, bin = cv2.threshold(gray, 0.1, 255.0, cv2.THRESH_BINARY);
print("threshold: ",thr)

(to use OTSU, you need to convert / scale to uint8 first !)

image description

then you can mask out the unwanted parts:

#help(cv2.bitwise_or)
# assume, "img" is the bgr cloud img
# images did not have same size, thus:
mask = cv2.resize(mask, (img.shape[1], img.shape[0]))
result = cv2.bitwise_or(img, img, mask=mask);

image description

edit flag offensive delete link more

Comments

Your piece of white cloud cropped out. Not accurately.

supra56 gravatar imagesupra56 ( 2020-02-11 08:00:04 -0600 )edit

yea, image sizes did not match, ad-hoc threshold value, etc.

(i guess, this is more to show, you can threshold float images w/o conversion)

berak gravatar imageberak ( 2020-02-11 08:07:42 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-02-07 06:48:45 -0600

Seen: 3,441 times

Last updated: Feb 07 '20