Remove eye glow from image

4

Well, I'm trying to apply canny edge to the image because the brightness that is contained in the pupil impairs the result obtained because to have an edge with cv2.Canny() or feature.canny() needs that there is a continuity of it. As I have to apply media filter it gets even worse because that region of brightness increases!

  • How to remove pupil brightness?

Code to extract border:

from skimage import feature
from skimage.io import imread
import cv2
img = imread("../olho.jpg",as_gray=True)
img = cv2.blur(img,(5,5))
borda = feature.canny(img)

Original picture with noise:

Imagewanted(madeinpaint!!):

Obtainededges(withaholeinthelocationoftheglowandtheedgesoftheglow):

  

I need these right edges because after the extraction I will apply Hough transform to find the circles

    
asked by anonymous 28.11.2018 / 19:49

1 answer

1

Result

The image on the left is the original image and the image on the right is unreflective.

Code

importcv2importnumpyasnpimporturllib.requestresp=urllib.request.urlopen("https://i.stack.imgur.com/TvChy.jpg")
img = np.asarray(bytearray(resp.read()), dtype="uint8")
img = cv2.imdecode(img, cv2.IMREAD_COLOR)
copia = img.copy()

#Converte para Escala de Cinza
gray = cv2.cvtColor(copia,cv2.COLOR_BGR2GRAY)

#Máscara para obter o que está no intervalo branco
mask = cv2.inRange(gray, 215, 255)

#Lógica AND
mask_not = cv2.bitwise_not(mask)
copia = cv2.bitwise_and(copia, copia, mask=mask_not )


#Interpolação da imagem para preencher os vazios
inpaint = cv2.inpaint(copia, mask, 3,cv2.INPAINT_TELEA)

#Mostra a nova imagem e a original
cv2.imshow("Original / Inpaint", np.hstack([img, inpaint]))
cv2.waitKey(0)

Explanation

  • Loads image and converts to grayscale (% w / o%)
  • Creates an image mask with values between the range 215 and 255 (close to white)
  • Use the AND logic to remove the pixels between the range defined in the mask gray
  • Fill in the blanks with Alexandru Telea's Inpaint interpolation, predicting what should be in that empty place
  

A fine-tuning can probably be done in the InRange parameters: mask

    
30.11.2018 / 20:02