imgcv.histogram.histogram_equalization

Functions

check_image(image)

Check if the input is a numpy array

histogram_equalization(img)

Equalizes the histogram of the image and returns the equalized image.

calculate_histogram(img)

Calculates the histogram of the image

calculate_pdf(img, pixel_freqs)

Calculates the probability density function of the image

calculate_cdf(img, pdf)

Calculates the cumulative density function of the image

Module Contents

imgcv.histogram.histogram_equalization.check_image(image)

Check if the input is a numpy array

Parameters:

image (np.ndarray) – Input image to be transformed

Raises:
  • TypeError – If the input is not a numpy array

  • ValueError – If the input is not a grayscale or color image

imgcv.histogram.histogram_equalization.histogram_equalization(img)

Equalizes the histogram of the image and returns the equalized image.

Parameters:

img (np.ndarray) – Image to equalize the histogram

Returns:

Equalized image

Return type:

np.ndarray

imgcv.histogram.histogram_equalization.calculate_histogram(img)

Calculates the histogram of the image

Parameters:

img (np.ndarrray) – Image to calculate the histogram

Returns:

Dictionary containing the frequency of each pixel value

Return type:

dict

imgcv.histogram.histogram_equalization.calculate_pdf(img, pixel_freqs)

Calculates the probability density function of the image

Note: This function currently only works for grayscale images.

Parameters:
  • img (np.ndarray) – Image to calculate the pdf

  • pixel_freqs (dict) – Dictionary containing the frequency of each pixel value

Returns:

Dictionary containing the probability density function of the image

Return type:

dict

imgcv.histogram.histogram_equalization.calculate_cdf(img, pdf)

Calculates the cumulative density function of the image

Parameters:
  • img (np.ndarray) – Image to calculate the cdf

  • pdf (dict) – Dictionary containing the probability density function of the image

Returns:

Dictionary containing the cumulative density function of the image

Return type:

dict