
'''simple docstring'''



def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_  )       ->       list[int]:




   """simple docstring"""
   if len(SCREAMING_SNAKE_CASE_  ) > 1:
      _SCREAMING_SNAKE_CASE       	=			len(SCREAMING_SNAKE_CASE_  ) // 2  # Finds the middle of the array
      _SCREAMING_SNAKE_CASE       	=			arr[
          :middle_length
      ]  # Creates an array of the elements in the first half.
      _SCREAMING_SNAKE_CASE       	=			arr[
          middle_length:
      ]  # Creates an array of the elements in the second half.
      _SCREAMING_SNAKE_CASE       	=			len(SCREAMING_SNAKE_CASE_  )
      _SCREAMING_SNAKE_CASE       	=			len(SCREAMING_SNAKE_CASE_  )
      merge(SCREAMING_SNAKE_CASE_  )  # Starts sorting the left.
      merge(SCREAMING_SNAKE_CASE_  )  # Starts sorting the right
      _SCREAMING_SNAKE_CASE       	=			0  # Left Counter
      _SCREAMING_SNAKE_CASE       	=			0  # Right Counter
      _SCREAMING_SNAKE_CASE       	=			0  # Position Counter
      while (
          left_index < left_size and right_index < right_size
      ):  # Runs until the lowers size of the left and right are sorted.
         if left_array[left_index] < right_array[right_index]:
            _SCREAMING_SNAKE_CASE       	=			left_array[left_index]
            left_index += 1
         else:
            _SCREAMING_SNAKE_CASE       	=			right_array[right_index]
            right_index += 1
         index += 1
      while (
          left_index < left_size
      ):  # Adds the left over elements in the left half of the array
         _SCREAMING_SNAKE_CASE       	=			left_array[left_index]
         left_index += 1
         index += 1
      while (
          right_index < right_size
      ):  # Adds the left over elements in the right half of the array
         _SCREAMING_SNAKE_CASE       	=			right_array[right_index]
         right_index += 1
         index += 1
   return arr


if __name__ == "__main__":
     import doctest

     doctest.testmod()








'''simple docstring'''



from cva import destroyAllWindows, imread, imshow, waitKey
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_  )       ->       Dict:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE	,							_SCREAMING_SNAKE_CASE       	=			img.shape[0], img.shape[1]

   def to_grayscale(SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_  ):
      return 0.2126 * red + 0.587 * green + 0.114 * blue

   def normalize(SCREAMING_SNAKE_CASE_  ):
      return min(SCREAMING_SNAKE_CASE_      , 2_55  )

   for i in range(SCREAMING_SNAKE_CASE_  ):
      for j in range(SCREAMING_SNAKE_CASE_  ):
         _SCREAMING_SNAKE_CASE       	=			int(to_grayscale(*img[i][j]  )  )
         _SCREAMING_SNAKE_CASE       	=			[
             normalize(SCREAMING_SNAKE_CASE_  ),
             normalize(greyscale + factor  ),
             normalize(greyscale + 2 * factor  ),
         ]

   return img


if __name__ == "__main__":
     # read original image
     UpperCamelCase__ :						Optional[int]    							=					{
         percentage: imread("image_data/lena.jpg", 1) for percentage in (10, 20, 30, 40)
     }

     for percentage, img in images.items():
          make_sepia(img, percentage)

     for percentage, img in images.items():
          imshow(f"""Original image with sepia (factor: {percentage})""", img)

     waitKey(0)
     destroyAllWindows()






