
'''simple docstring'''
import numpy as np
from PIL import Image

def   UpperCamelCase_       (		__SCREAMING_SNAKE_CASE    ):
    """simple docstring"""






    snake_case_     ,	snake_case_     ,	snake_case_	:      int            =  rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2]
    return 0.2989 * r + 0.5870 * g + 0.1140 * b

def   UpperCamelCase_       (		__SCREAMING_SNAKE_CASE    ):
    """simple docstring"""






    return (gray > 1_2_7) & (gray <= 2_5_5)

def   UpperCamelCase_       (		__SCREAMING_SNAKE_CASE,						__SCREAMING_SNAKE_CASE    ):
    """simple docstring"""






    snake_case_	:      Optional[Any]            =  np.zeros_like(__SCREAMING_SNAKE_CASE    )
    snake_case_	:      Dict            =  np.zeros(
        (image.shape[0] + kernel.shape[0] - 1, image.shape[1] + kernel.shape[1] - 1)    )

    # Copy image to padded image
    snake_case_	:      List[Any]            =  image

    # Iterate over image & apply kernel
    for x in range(image.shape[1]    ):
        for y in range(image.shape[0]    ):
            snake_case_	:      List[Any]            =  (
                kernel * image_padded[y : y + kernel.shape[0], x : x + kernel.shape[1]]
            ).sum()
            snake_case_	:      Optional[Any]            =  int(summation == 5    )
    return output


# kernel to be applied
a_     =  np.array([[0, 1, 0], [1, 1, 1], [0, 1, 0]])

if __name__ == "__main__":
  # read original image
  a_     =  np.array(Image.open(R"..\image_data\lena.jpg"))
  # Apply erosion operation to a binary image
  a_     =  erosion(grayabinary(rgbagray(image)), structuring_element)
  # Save the output image
  a_     =  Image.fromarray(output).convert("RGB")
  pil_img.save("result_erosion.png")






'''simple docstring'''
from __future__ import annotations

from collections.abc import Callable

def   UpperCamelCase_       (		__SCREAMING_SNAKE_CASE,						__SCREAMING_SNAKE_CASE,						__SCREAMING_SNAKE_CASE,						__SCREAMING_SNAKE_CASE = 1_0_0,						):
    """simple docstring"""






    snake_case_	:      Optional[Any]            =  x_start
    snake_case_	:      str            =  fnc(__SCREAMING_SNAKE_CASE    )
    snake_case_	:      List[str]            =  0.0

    for _ in range(__SCREAMING_SNAKE_CASE    ):
        # Approximates small segments of curve as linear and solve
        # for trapezoidal area
        snake_case_	:      List[str]            =  (x_end - x_start) / steps + xa
        snake_case_	:      Optional[int]            =  fnc(__SCREAMING_SNAKE_CASE    )
        area += abs(fxa + fxa    ) * (xa - xa) / 2

        # Increment step
        snake_case_	:      List[Any]            =  xa
        snake_case_	:      Optional[Any]            =  fxa
    return area


if __name__ == "__main__":

  def   UpperCamelCase_       (		__SCREAMING_SNAKE_CASE    ):
      """simple docstring"""






      return x**3

  print("f(x) = x^3")
  print("The area between the curve, x = -10, x = 10 and the x axis is:")
  a_     =  10
  while i <= 10_0000:
    a_     =  trapezoidal_area(f, -5, 5, i)
    print(f"""with {i} steps: {area}""")
    i *= 10




