<commit_before>'''
*	REMOVAL OF LED GLARE FROM RETINAL IMAGES
----------------------------------------------------
*	Author: <NAME>
*	A very simple piece of code in openCV (3.1.0 used) to remove the two direct specular reflections on the 20D lens
*	Built for OWL 1.0 (part of openDR project at Srujana Center for Innovation, LV Prasad Eye Institute, Hyderabad, India)
'''

import numpy
import cv2
############# start timing here
import timeit

# read in desired retinal image file
im  = cv2.imread('1.jpg')

start = timeit.default_timer()

# prepare mask - square of width 'w' centered at (x,y) which is the center of the bright spots
mask = numpy.zeros([im.shape[0], im.shape[1]])
x = 1396
y = 958
w = 100
thresh = 0.9

# generate binary image mask - dilated circles around the saturated bright spots at the center
temp = im[y-w:y+w, x-w:x+w,1]  # single channel
ret, temp_mask = cv2.threshold(temp, thresh*256, 255, cv2.THRESH_BINARY)
kernel = numpy.ones((35,35), 'uint8')
temp_mask = cv2.dilate(temp_mask, kernel)

# perform the inpainting...
im[y-w:y+w, x-w:x+w,:] = cv2.inpaint(im[y-w:y+w, x-w:x+w,:], temp_mask, 1, cv2.INPAINT_TELEA)

############STOP TIMER
stop = timeit.default_timer()
print stop - start 

# writeout file
cv2.imwrite('out.jpg', im)<commit_msg>modifications and optimizations to remove_glare<commit_after>'''
*	REMOVAL OF LED GLARE FROM RETINAL IMAGES
----------------------------------------------------
*	Author: <NAME>
*	A very simple piece of code in openCV (3.1.0 used) to remove the two direct specular reflections on the 20D lens
*	Built for OWL 1.0 (part of openDR project at Srujana Center for Innovation, LV Prasad Eye Institute, Hyderabad, India)
'''

import numpy
import cv2
############# start timing here
import timeit

# read in desired retinal image file
im  = cv2.imread('1.jpg')

start = timeit.default_timer()

# prepare mask - square of width 'w' centered at (x,y) which is the center of the bright spots
x = 1396
y = 958
w = 100
thresh = 0.9

# generate binary image mask - dilated circles around the saturated bright spots at the center
temp = im[y-w:y+w, x-w:x+w,1]  # single channel
ret, temp_mask = cv2.threshold(temp, thresh*256, 255, cv2.THRESH_BINARY)
kernel = numpy.ones((25,25), 'uint8')
temp_mask = cv2.dilate(temp_mask, kernel)

# perform the inpainting...
im[y-w:y+w, x-w:x+w,:] = cv2.inpaint(im[y-w:y+w, x-w:x+w,:], temp_mask, 1, cv2.INPAINT_TELEA)

############STOP TIMER
stop = timeit.default_timer()
print stop - start 

# writeout file
cv2.imwrite('out.jpg', im)
{'fraction_non_alphanumeric': 0.17386138613861385, 'fraction_numerical': 0.03326732673267327, 'mean_word_length': 3.6777777777777776, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4408561', 'n_tokens_mistral': 958, 'n_tokens_neox': 891, 'n_words': 298}