


'''simple docstring'''
import numpy as np
from cva import COLOR_BGR2GRAY, cvtColor, imread
from numpy import array, uinta
from PIL import Image

from digital_image_processing import change_contrast as cc
from digital_image_processing import convert_to_negative as cn
from digital_image_processing import sepia as sp
from digital_image_processing.dithering import burkes as bs
from digital_image_processing.edge_detection import canny
from digital_image_processing.filters import convolve as conv
from digital_image_processing.filters import gaussian_filter as gg
from digital_image_processing.filters import local_binary_pattern as lbp
from digital_image_processing.filters import median_filter as med
from digital_image_processing.filters import sobel_filter as sob
from digital_image_processing.resize import resize as rs

__snake_case							      =     imread(R'''digital_image_processing/image_data/lena_small.jpg''')
__snake_case							      =     cvtColor(img, COLOR_BGR2GRAY)


def 			a      (			)  ->	int:



					'''simple docstring'''






					UpperCamelCase__   :List[Any]												= cn.convert_to_negative(__a   )
					# assert negative_img array for at least one True
					assert negative_img.any()


def 			a      (			)  ->	Optional[Any]:



					'''simple docstring'''






					with Image.open('''digital_image_processing/image_data/lena_small.jpg'''   ) as img:
										# Work around assertion for response
										assert str(cc.change_contrast(__a ,					110   )   ).startswith(
										    '''<PIL.Image.Image image mode=RGB size=100x100 at'''   )


def 			a      (			)  ->	Optional[Any]:



					'''simple docstring'''






					UpperCamelCase__   :List[Any]												= canny.gen_gaussian_kernel(9 ,					sigma=1.4   )
					# Assert ambiguous array
					assert resp.all()


def 			a      (			)  ->	Dict:



					'''simple docstring'''






					UpperCamelCase__   :int												= imread('''digital_image_processing/image_data/lena_small.jpg''' ,					0   )
					# assert ambiguous array for all == True
					assert canny_img.all()
					UpperCamelCase__   :Optional[Any]												= canny.canny(__a   )
					# assert canny array for at least one True
					assert canny_array.any()


def 			a      (			)  ->	Optional[Any]:



					'''simple docstring'''






					assert gg.gaussian_filter(__a ,					5 ,					sigma=0.9   ).all()


def 			a      (			)  ->	Any:



					'''simple docstring'''






					UpperCamelCase__   :Optional[int]												= array([[0.2_5, 0.5, 0.2_5], [0.5, -3, 0.5], [0.2_5, 0.5, 0.2_5]]   )
					UpperCamelCase__   :Dict												= conv.img_convolve(__a ,					__a   ).astype(__a   )
					assert res.any()


def 			a      (			)  ->	Union[str, Any]:



					'''simple docstring'''






					assert med.median_filter(__a ,					3   ).any()


def 			a      (			)  ->	List[Any]:



					'''simple docstring'''






					UpperCamelCase__					,				UpperCamelCase__   :Dict												= sob.sobel_filter(__a   )
					assert grad.any() and theta.any()


def 			a      (			)  ->	Optional[Any]:



					'''simple docstring'''






					UpperCamelCase__   :str												= sp.make_sepia(__a ,					20   )
					assert sepia.all()


def 			a      (			__a = "digital_image_processing/image_data/lena_small.jpg"   )  ->	List[str]:



					'''simple docstring'''






					UpperCamelCase__   :List[Any]												= bs.Burkes(imread(__a ,					1   ) ,					120   )
					burkes.process()
					assert burkes.output_img.any()


def 			a      (			__a = "digital_image_processing/image_data/lena_small.jpg" ,					)  ->	List[Any]:



					'''simple docstring'''






					UpperCamelCase__   :int												= rs.NearestNeighbour(imread(__a ,					1   ) ,					400 ,					200   )
					nn.process()
					assert nn.output.any()







def 			a      (			)  ->	Optional[int]:



					'''simple docstring'''






					UpperCamelCase__   :Dict												= '''digital_image_processing/image_data/lena.jpg'''

					# Reading the image and converting it to grayscale.
					UpperCamelCase__   :str												= imread(__a ,					0   )

					# Test for get_neighbors_pixel function() return not None
					UpperCamelCase__   :Optional[int]												= 0
					UpperCamelCase__   :str												= 0
					UpperCamelCase__   :Tuple												= image[x_coordinate][y_coordinate]

					UpperCamelCase__   :int												= lbp.get_neighbors_pixel(
					    __a ,					__a ,					__a ,					__a   )

					assert neighbors_pixels is not None

					# Test for local_binary_pattern function()
					# Create a numpy array as the same height and width of read image
					UpperCamelCase__   :str												= np.zeros((image.shape[0], image.shape[1])   )

					# Iterating through the image and calculating the local binary pattern value
					# for each pixel.
					for i in range(0 ,					image.shape[0]   ):
										for j in range(0 ,					image.shape[1]   ):
															UpperCamelCase__   :List[Any]												= lbp.local_binary_value(__a ,					__a ,					__a   )

					assert lbp_image.any()



'''simple docstring'''
from scipy.stats import pearsonr

import datasets


__snake_case							      =     '''
Pearson correlation coefficient and p-value for testing non-correlation.
The Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies on the assumption that each dataset is normally distributed. Like other correlation coefficients, this one varies between -1 and +1 with 0 implying no correlation. Correlations of -1 or +1 imply an exact linear relationship. Positive correlations imply that as x increases, so does y. Negative correlations imply that as x increases, y decreases.
The p-value roughly indicates the probability of an uncorrelated system producing datasets that have a Pearson correlation at least as extreme as the one computed from these datasets.
'''


__snake_case							      =     '''
Args:
    predictions (`list` of `int`): Predicted class labels, as returned by a model.
    references (`list` of `int`): Ground truth labels.
    return_pvalue (`boolean`): If `True`, returns the p-value, along with the correlation coefficient. If `False`, returns only the correlation coefficient. Defaults to `False`.

Returns:
    pearsonr (`float`): Pearson correlation coefficient. Minimum possible value is -1. Maximum possible value is 1. Values of 1 and -1 indicate exact linear positive and negative relationships, respectively. A value of 0 implies no correlation.
    p-value (`float`): P-value, which roughly indicates the probability of an The p-value roughly indicates the probability of an uncorrelated system producing datasets that have a Pearson correlation at least as extreme as the one computed from these datasets. Minimum possible value is 0. Maximum possible value is 1. Higher values indicate higher probabilities.

Examples:

    Example 1-A simple example using only predictions and references.
        >>> pearsonr_metric = datasets.load_metric("pearsonr")
        >>> results = pearsonr_metric.compute(predictions=[10, 9, 2.5, 6, 4], references=[1, 2, 3, 4, 5])
        >>> print(round(results[\'pearsonr\'], 2))
        -0.74

    Example 2-The same as Example 1, but that also returns the `p-value`.
        >>> pearsonr_metric = datasets.load_metric("pearsonr")
        >>> results = pearsonr_metric.compute(predictions=[10, 9, 2.5, 6, 4], references=[1, 2, 3, 4, 5], return_pvalue=True)
        >>> print(sorted(list(results.keys())))
        [\'p-value\', \'pearsonr\']
        >>> print(round(results[\'pearsonr\'], 2))
        -0.74
        >>> print(round(results[\'p-value\'], 2))
        0.15
'''


__snake_case							      =     '''
@article{2020SciPy-NMeth,
author  = {Virtanen, Pauli and Gommers, Ralf and Oliphant, Travis E. and
      Haberland, Matt and Reddy, Tyler and Cournapeau, David and
      Burovski, Evgeni and Peterson, Pearu and Weckesser, Warren and
      Bright, Jonathan and {van der Walt}, St{\'e}fan J. and
      Brett, Matthew and Wilson, Joshua and Millman, K. Jarrod and
      Mayorov, Nikolay and Nelson, Andrew R. J. and Jones, Eric and
      Kern, Robert and Larson, Eric and Carey, C J and
      Polat, Ilhan and Feng, Yu and Moore, Eric W. and
      {VanderPlas}, Jake and Laxalde, Denis and Perktold, Josef and
      Cimrman, Robert and Henriksen, Ian and Quintero, E. A. and
      Harris, Charles R. and Archibald, Anne M. and
      Ribeiro, Antonio H. and Pedregosa, Fabian and
      {van Mulbregt}, Paul and {SciPy 1.0 Contributors}},
title   = {{{SciPy} 1.0: Fundamental Algorithms for Scientific
      Computing in Python}},
journal = {Nature Methods},
year    = {2020},
volume  = {17},
pages   = {261--272},
adsurl  = {https://rdcu.be/b08Wh},
doi = {10.1038/s41592-019-0686-2},
}
'''
@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION	,		_KWARGS_DESCRIPTION					)
class    lowercase	(							datasets.Metric					):

		"""simple docstring"""

		def     lowerCAmelCase__				(		self							):

							'''simple docstring'''


							return datasets.MetricInfo(
							    description=_DESCRIPTION    ,   citation=_CITATION    ,   inputs_description=_KWARGS_DESCRIPTION    ,   features=datasets.Features(
							        {
							            '''predictions''': datasets.Value('''float'''							),
							            '''references''': datasets.Value('''float'''							),
							        }							)    ,   reference_urls=['''https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.pearsonr.html''']    ,   )




		def     lowerCAmelCase__				(		self    ,   UpperCamelCase_    ,   UpperCamelCase_    ,   UpperCamelCase_=False							):

							'''simple docstring'''


							if return_pvalue:
												UpperCamelCase__   :Any												= pearsonr(UpperCamelCase_    ,   UpperCamelCase_							)
												return {"pearsonr": results[0], "p-value": results[1]}
							else:
												return {"pearsonr": float(pearsonr(UpperCamelCase_    ,   UpperCamelCase_							)[0]							)}