'''simple docstring'''

from pathlib import Path

import numpy as np
from PIL import Image
def       __UpperCamelCase	(       UpperCAmelCase					) ->    Union[str, Any]:
 lowercase__    :   str						= rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2]
 return 0.2_9_8_9 * r + 0.5_8_7_0 * g + 0.1_1_4_0 * b
def       __UpperCamelCase	(       UpperCAmelCase					) ->    Optional[int]:
 return (gray > 127) & (gray <= 255)
def       __UpperCamelCase	(       UpperCAmelCase		,					UpperCAmelCase					) ->    Optional[int]:
 lowercase__    :   List[Any]						= np.zeros_like(UpperCAmelCase					)
 lowercase__    :   Dict						= np.zeros(
     (image.shape[0] + kernel.shape[0] - 1, image.shape[1] + kernel.shape[1] - 1)					)

 # Copy image to padded image
 lowercase__    :   str						= image

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


if __name__ == "__main__":
  # read original image
  __a:			List[str]	       =       Path(__file__).resolve().parent / """image_data""" / """lena.jpg"""
  __a:			int	       =       np.array(Image.open(lena_path))
  # kernel to be applied
  __a:			Tuple	       =       np.array([[0, 1, 0], [1, 1, 1], [0, 1, 0]])
  __a:			Union[str, Any]	       =       dilation(gray_to_binary(rgb_to_gray(lena)), structuring_element)
  # Save the output image
  __a:			Optional[int]	       =       Image.fromarray(output).convert("""RGB""")
  pil_img.save("""result_dilation.png""")


'''simple docstring'''

import qiskit
def       __UpperCamelCase	(       UpperCAmelCase		,					UpperCAmelCase					):
 lowercase__    :   Dict						= qiskit.Aer.get_backend('''aer_simulator'''					)

 # Create a Quantum Circuit acting on the q register
 lowercase__    :   Any						= qiskit.QuantumCircuit(UpperCAmelCase		,					UpperCAmelCase					)

 # Map the quantum measurement to the classical bits
 circuit.measure([0]		,					[0]					)

 # Execute the circuit on the simulator
 lowercase__    :   Any						= qiskit.execute(UpperCAmelCase		,					UpperCAmelCase		,					shots=1000					)

 # Return the histogram data of the results of the experiment.
 return job.result().get_counts(UpperCAmelCase					)


if __name__ == "__main__":
  print(F'Total count for various states are: {single_qubit_measure(1, 1)}')

