Mask bright spots [closed]

asked 2018-05-09 10:58:32 -0500

Safa gravatar image

Hello, I'm trying to detect contours in a video but i also want to ignore/mask the bright objects in it (leds, light sources...). Is there a way to do it?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-25 13:47:59.091036


Please post your code so far, and any input image samples would be nice.

You can iterate over your image and write to another image the white and not white parts, if you're looking to make a mask.

What language are you using?

sjhalayka gravatar imagesjhalayka ( 2018-05-09 11:02:00 -0500 )edit

I'm using Opencvforunity and i was warned about posting code that corresponds to that asset previously, i'm only searching for functions/ways to do so in here (because the community is better) and then i'll look for the corresponding ones in the asset. Basically all i'm doing is this:
-blurring the image using a median filter

-using morphological operation for noise removal

-using canny for edge detection

is there a way to apply a reversed threshold?

Safa gravatar imageSafa ( 2018-05-09 20:21:18 -0500 )edit

reversed threshold? can you post image for each step?

LBerger gravatar imageLBerger ( 2018-05-10 04:26:02 -0500 )edit

thresh = cv2.threshold(blurred, 200, 255, cv2.THRESH_BINARY) This operation takes any pixel value p >= 200 (bright) and sets it to 255 (white). Pixel values < 200 are set to 0 (black). I would like to do the opposite of that and if it's possible i would like to preserve the grayscale version instead of using a binary image.

Safa gravatar imageSafa ( 2018-05-10 08:48:34 -0500 )edit

Have you tried cv2.THRESH_BINARY_INV?

sjhalayka gravatar imagesjhalayka ( 2018-05-10 11:19:06 -0500 )edit

I'm still not sure to understand what you mean : "preserve the grayscale ". You should read doc (and curve )about threshold parameters

LBerger gravatar imageLBerger ( 2018-05-10 12:36:44 -0500 )edit