0

let us consider following code -which reads image, applies histogram equalization procedure and display both result :

import cv2
import numpy as np
img = cv2.imread('original.png', cv2.IMREAD_GRAYSCALE)
assert img is not None, "file could not be read, check with os.path.exists()"
equ = cv2.equalizeHist(img)
res = np.hstack((img,equ)) #stacking images side-by-side
cv2.imshow("both image",res)
cv2.waitKey(0)
cv2.destroyAllWindows()

result is : enter image description here

we can see clearly that contrast of the image was increased, but as you know almost every part of the AI , Machine learning or computer vision tasks is evaluated by some criteria, for example in deep learning we have notion of loss function(like a binary_crossentropy, mean_squared_error and etc), so my question is : is there any measurment scale whch will be suitable to the contrast increasment ? so if i would like to ask : by how much or how large changement has been made after histogram equalization, is there any score for this? sure i can calculate difference between two image as they have same dimension and calculate square of difference(therefore squared distance between two image) but is it correct? maybe difference between two histogram(difference between two distribution) will be right action to be done?if so could you tell me please how?

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
  • equalized histogram will have approximately *flat* histogram (CDF is a diagonal line). -- are you asking for distance measures that are defined on histograms? there's the earth mover's distance. there is the Euclidean distance. there are others... – Christoph Rackwitz Apr 22 '23 at 20:56
  • so i am looking for distance between two image after changes are done, so which one is relevant distance? – neural science Apr 22 '23 at 21:01
  • that's a conceptual question, not a programming question. asking for literature review to be done is beyond the scope of Stack Overflow and perhaps better suited to another stack exchange site. I am also hesitant to give an opinion on what distance measure you should use. that's for you to decide. – Christoph Rackwitz Apr 22 '23 at 21:09
  • This question is more suited to https://dsp.stackexchange.com/ – Cris Luengo Apr 22 '23 at 23:55
  • 1
    Also, before you post this on the DSP stack exchange, think about what exactly are you asking for: Do you want to quantify how much the image changed? Do you want to measure contrast, so you can say how much the contrast increased? Do you you want to determine how well the task was accomplished (ie how flat the output histogram is)? State this clearly in the question! – Cris Luengo Apr 22 '23 at 23:59

0 Answers0