Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

automatically remove shadow and edge filling

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](/upfiles/15536646918201492.png)

automatically remove shadow and edge filling

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](/upfiles/15536646918201492.png)

Example

automatically remove shadow and edge filling

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