<jupyter_start><jupyter_text><jupyter_code>import cv2
from google.colab.patches import cv2_imshow
import numpy as np

image = cv2.imread('/content/RedEye.png')
image = cv2.resize(image, (256, 256))
cv2_imshow(image)
hls = cv2.cvtColor(image, cv2.COLOR_RGB2HLS)
cv2_imshow(hls)
def skin(hls_image):

  skin_image = np.zeros_like(hls_image)
  for i in range(hls_image.shape[0]):
    for j in range(hls_image.shape[1]):
      if ((hls_image[i, j, 2] >= 50) and ( 0.5 < float(hls_image[i, j, 1] / hls_image[i, j, 2])) and
       (float(hls_image[i, j, 1] / hls_image[i, j, 2]) < 3) and ((14 <= hls_image[i, j, 0]) or (hls_image[i, j, 0 ] >= 165))):
        skin_image[i, j, 0] = hls_image[i, j, 0]
        skin_image[i, j, 1] = hls_image[i, j, 1]
        skin_image[i, j, 2] = hls_image[i, j, 2]
      else:
        pass
  return skin_image

skin_image = skin(hls)
cv2_imshow(skin_image)

def redeye(hls_image):

  epsilon = 0.0001
  redeye_image = np.zeros_like(hls_image)
  for i in range(hls_image.shape[0]):
    for j in range(hls_image.shape[1]):
      if ((hls_image[i, j, 1] >= 64) and ( 0.5 < (hls_image[i, j, 1] / (hls_image[i, j, 2]+epsilon))) and (hls_image[i, j, 2] >= 100) and 
       ((hls_image[i, j, 1] / (hls_image[i, j, 2])+epsilon) < 1.5) and ((7 >= hls_image[i, j, 0 ]) or (hls_image[i, j, 0 ] >= 162))):
        redeye_image[i, j, 0] = hls_image[i, j, 0]
        redeye_image[i, j, 1] = hls_image[i, j, 1]
        redeye_image[i, j, 2] = hls_image[i, j, 2]
      else:
        pass
  return redeye_image

redeye_image = redeye(hls)
cv2_imshow(redeye_image)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17217716781035558, 'fraction_numerical': 0.047411104179663134, 'mean_word_length': 3.5568181818181817, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 11, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '56945', 'license': 'MIT', 'n_tokens_mistral': 795, 'n_tokens_neox': 728, 'n_words': 164, 'path': 'Images/Skin_RedEye_Detection.ipynb', 'repo_name': 'alirezash97/Computer-Vision', 'size': '1603'}