Package: contrast-image
Contrast-imageBase on multiple papers about contrast, I create this library to contrast images with opencv.Installationpipinstallcontrast-imageUsagefromcontrast_imageimportcontrast_imageimportcv2ascvinput=cv.imread('input.jpg')ci=CI(input,'HSV')output=ci.GHE()APICIStore all functions to contrast imagefromcontrast_imageimportcontrast_imageci=CI(image,color_space='HSV')GHE (Global Histogram Equalization)This function is similar toequalizeHist(image)in opencv.ci.GHE()Return: image after equalizationBBHE (Brightness Preserving Histogram Equalization)This function separate the histogram by the mean of the image, then equalize histogram of each part.This method tries to preserve brightness of output image by assume PDF is symmetrical distribution.ci.BBHE()Return: image after equalizationDSIHE (Dualistic Sub-Image Histogram Equalization)This function is similar to BBHE except using median instead of mean.Unlike BBHE, DSIHE tries to preserve brightness of output image by maximum entropy after separate.ci.DSIHE()Return: image after equalizationMMBEBHE (Minimum Mean Brightness Error Histogram Equalization)This function is similar to BBHE except using minimum mean brightness error instead of mean.Theortically, mean of output image (by GHE) is middle gray level. Therefore, MMBEBHE believe by separate histogram such that mean of output image near mean of input image must preserve brightness.ci.MMBEBHE()Return: image after equalizationBPHEME (Brightness Preserving Histogram Equalization with Maximum Entropy)This function finds matching function such that make output image maximum entropy, then using histogram specification to match input's histogram and matching function.Based on idea of DSIHE, BPHEME tries to generalize by using histogram specification and solve optimize problem by Lagrange interpolation.ci.BPHEME()Return: image after equalizationRLBHE (Range Limited Bi-Histogram Equalization)This function is similar to BBHE except using otsu's method instead of mean. Moreover, this limit range of gray level such that output image has minimum mean brightness error.This method tries to equalize histogram for foreground and background separately by Otsu's method.ci.RLBHE()Return: image after equalizationRMSHE (Recursively Mean-Separate Histogram Equalization)This function recursively separate histogram by mean. Therefore,recursive = 2will create 4 sub-histograms, then equalize each sub-histograms.Same idea as BBHE but recursively separate to preserve more brightness.ci.RMSHE(recursive=2)Parameter recurive: number of recursive timeReturn: image after equalizationRSIHE (Recursive Sub-Image Histogram Equalization)This function is similar to RMSHE except using median instead of mean.Same idea as DSIHE but recursively separate to preserve more brightness.ci.RSIHE(recursive=2)Parameter recurive: number of recursive timeReturn: image after equalizationRSWHE (Recursive Separated and Weighted Histogram Equalization)This function recursively separate histogram by mean or median, then weighting each sub-histogram before equalize them.This method similar to RMSHE and RSIHE except weighting sub-histogram to avoid local extreme value in histogram.ci.RSWHE(type='mean',beta=0,recursive=2)Parameter type: 'mean' or 'median'Parameter beta: increasing more brightness in output imageParameter recurive: number of recursive timeReturn: image after equalizationFHSABP (Flattest Histogram Specification with Accurate Brightness Preservation)This function finds matching function such that make the flattest output's histogram, then using histogram specification to match input's histogram and matching function.Because of discrete, histogram equalization does not often the flattest histogram. FHSABP tries to solve optimization function to find the flattest output's histogram.ci.FHSABP()Return: image after equalizationWTHE (Weighted Thresholded Histogram Equalization)This function weight histogram before equalize it.ci.WTHE(root,value,lower=0)Return: image after equalizationAGCWD (Adaptive Gamma Correction with Weighting Distribution)This function automatic correct gamma using weighting distributionci.AGCWD(alpha)Parameter alpha: adjustmentReturn: image after equalizationAGCCPF (Adaptive Gamma Correction Color Preserving Framework)This similar to AGCWD except smooth pdfci.AGCCPF(alpha)Parameter alpha: adjustmentReturn: image after equalizationQuantitationStore all functions to quantity output imagefromcontrast_imageimportquantitationquantitation=Quantitation()AMBE (Absolute Mean Brightness Error)ci.AMBE(input_image,output_image)PSNR (Peak Signal to Noise Ratio)ci.PSNR(input_image,output_image)Entropyci.Entropy(image)ContributingPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.Please make sure to update tests as appropriate.LicenseMIT