Ask Your Question
1

automatically remove shadow and edge filling

asked 2019-03-27 00:32:50 -0600

Zerok gravatar image

updated 2020-12-09 07:57:51 -0600

I've written a code to create the binary mask of the images in my dataset. In this code, I specify the edge of the object in the image. As you can see from the picture, I have some problems.

1) How do I automatically remove the shadow of the plane?

2) How do I fill the area with the color after I remove the shadow? Thanks...

 import cv2
 import numpy as np
 from matplotlib import pyplot as plt
 import argparse
 import glob

def auto_canny(image, sigma=0.33):

    v = np.median(image)

   lower = int(max(0, (1.0 - sigma) * v))
   upper = int(min(255, (1.0 + sigma) * v))
   edged = cv2.Canny(image, lower, upper)


   return edged

image = cv2.imread("2.png")
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (3, 3), 0)

auto = auto_canny(blurred)

cv2.imshow("Original", image)
cv2.imshow("Edges", np.hstack([auto]))
cv2.waitKey(0)

Example

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2019-03-27 14:56:20 -0600

updated 2019-03-27 14:59:38 -0600

Hello! The problem of eliminate the shadow can be solved by thresholding your image before submiting it to your code (Document about automatic thresholding: http://nca.ufma.br/~geraldo/vc/materi.... You can just make intensity values above 200 become 255, and values bellow become 0. See the result: https://drive.google.com/open?id=12sK...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-03-27 00:32:50 -0600

Seen: 2,648 times

Last updated: Mar 27 '19