

import numpy as np
from cva import destroyAllWindows, imread, imshow, waitKey
class 	_A						:

  def __init__(			self	,   _SCREAMING_SNAKE_CASE	,   _SCREAMING_SNAKE_CASE   ):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_			:					str          =       0
        # max greyscale value for #FFFFFF
        SCREAMING_SNAKE_CASE_			:					Optional[int]          =       int(self.get_greyscale(255	,   255	,   255   )   )

        if not self.min_threshold < threshold < self.max_threshold:
              SCREAMING_SNAKE_CASE_			:					Optional[Any]          =       f"Factor value should be from 0 to {self.max_threshold}"
              raise ValueError(_SCREAMING_SNAKE_CASE   )

        SCREAMING_SNAKE_CASE_			:					int          =       input_img
        SCREAMING_SNAKE_CASE_			:					Tuple          =       threshold
        SCREAMING_SNAKE_CASE_    ,  SCREAMING_SNAKE_CASE_			:					int          =       self.input_img.shape[1], self.input_img.shape[0]

        # error table size (+4 columns and +1 row) greater than input image because of
        # lack of if statements
        SCREAMING_SNAKE_CASE_			:					Optional[Any]          =       [
            [0 for _ in range(self.height + 4   )] for __ in range(self.width + 1   )
        ]
        SCREAMING_SNAKE_CASE_			:					Optional[int]          =       np.ones((self.width, self.height, 3)	,   np.uinta   ) * 255

  @classmethod
  def 	UpperCAmelCase      (			cls	,   _SCREAMING_SNAKE_CASE	,   _SCREAMING_SNAKE_CASE	,   _SCREAMING_SNAKE_CASE   ):





        """simple docstring"""







        return 0.114 * blue + 0.587 * green + 0.2126 * red



  def 	UpperCAmelCase      (			self   ):





        """simple docstring"""







        for y in range(self.height   ):
              for x in range(self.width   ):
                    SCREAMING_SNAKE_CASE_			:					Any          =       int(self.get_greyscale(*self.input_img[y][x]   )   )
                    if self.threshold > greyscale + self.error_table[y][x]:
                          SCREAMING_SNAKE_CASE_			:					List[str]          =       (0, 0, 0)
                          SCREAMING_SNAKE_CASE_			:					List[Any]          =       greyscale + self.error_table[x][y]
                    else:
                          SCREAMING_SNAKE_CASE_			:					Optional[int]          =       (255, 255, 255)
                          SCREAMING_SNAKE_CASE_			:					Optional[Any]          =       greyscale + self.error_table[x][y] - 255
                    self.error_table[y][x + 1] += int(8 / 32 * current_error   )
                    self.error_table[y][x + 2] += int(4 / 32 * current_error   )
                    self.error_table[y + 1][x] += int(8 / 32 * current_error   )
                    self.error_table[y + 1][x + 1] += int(4 / 32 * current_error   )
                    self.error_table[y + 1][x + 2] += int(2 / 32 * current_error   )
                    self.error_table[y + 1][x - 1] += int(4 / 32 * current_error   )
                    self.error_table[y + 1][x - 2] += int(2 / 32 * current_error   )


if __name__ == "__main__":
    # create Burke's instances with original images in greyscale
    lowerCAmelCase       :				Union[str, Any]         =					[
        Burkes(imread('image_data/lena.jpg', 1), threshold)
        for threshold in (1, 1_26, 1_30, 1_40)
    ]

    for burkes in burkes_instances:
        burkes.process()

    for burkes in burkes_instances:
        imshow(
            F'Original image with dithering threshold: {burkes.threshold}',
            burkes.output_img,
        )

    waitKey(0)
    destroyAllWindows()









from math import sqrt

def 				A_					(							a					):

      """simple docstring"""



      SCREAMING_SNAKE_CASE_			:					List[str]          =       [1]
      for i in range(2   ,				int(sqrt(a					)					) + 1   ,				1					):
            if number % i == 0:
                  values.append(a					)
                  if int(number // i					) != i:
                        values.append(int(number // i					)					)
      return sorted(a					)

def 				A_					(							a					):

      """simple docstring"""



      return sum(factors(a					)					) > n

def 				A_					(							a					):

      """simple docstring"""



      SCREAMING_SNAKE_CASE_			:					Union[str, Any]          =       factors(a					)
      SCREAMING_SNAKE_CASE_			:					Optional[int]          =       len(a					)
      SCREAMING_SNAKE_CASE_			:					Optional[int]          =       [[0 for i in range(number + 1					)] for j in range(r + 1					)]
      for i in range(r + 1					):
            SCREAMING_SNAKE_CASE_			:					Optional[int]          =       True

      for i in range(1   ,				number + 1					):
            SCREAMING_SNAKE_CASE_			:					Optional[Any]          =       False

      for i in range(1   ,				r + 1					):
            for j in range(1   ,				number + 1					):
                  if j < values[i - 1]:
                        SCREAMING_SNAKE_CASE_			:					Dict          =       subset[i - 1][j]
                  else:
                        SCREAMING_SNAKE_CASE_			:					List[str]          =       subset[i - 1][j] or subset[i - 1][j - values[i - 1]]

      return subset[r][number] != 0

def 				A_					(							a					):

      """simple docstring"""



      return abundant(a					) and not semi_perfect(a					)


if __name__ == "__main__":
    import doctest

    doctest.testmod(verbose=True)
    for number in (69, 70, 71):
        print(F'{number} is {"" if weird(number) else "not "}weird.')






