0

This is the original image

enter image description here

Code for applying equalizeHist to image:

PhotoImage_hist = resized_img
hist_image = resized_img
def histogram():
    global PhotoImage_hist,hist_image,gray_image
    hist_image = cv2.equalizeHist(gray_image)
    PhotoImage_hist = Image.fromarray(hist_image)
    PhotoImage_hist = ImageTk.PhotoImage(PhotoImage_hist)
    canvas_hist.create_image(0, 0, anchor=NW, image=PhotoImage_hist)

It is the image after applying equalizeHist:

enter image description here

After applying cvtColor to equalize image, it is not showing color image

PhotoImage_color = resized_img
color_img = resized_img
def coloredHist():
    global PhotoImage_color,hist_image,color_img
    color_img = cv2.cvtColor(hist_image,cv2.COLOR_GRAY2BGR)
    PhotoImage_color = Image.fromarray(color_img)
    PhotoImage_color = ImageTk.PhotoImage(PhotoImage_color)
    canvas_color.create_image(0, 0, anchor=NW, image=PhotoImage_color)

This is the output after applying cv2.cvtColor(hist_image,cv2.COLOR_GRAY2BGR)

enter image description here

Is there any other channel I can use to gain result my specific result??

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
GALAXY A50
  • 29
  • 7
  • GRAY2BGR **cannot magically recreate color**. you get the same gray image you passed into the call, just with three channels instead of one. – Christoph Rackwitz Aug 31 '22 at 07:25
  • Idea: Since your original image is largely monochromatic, try converting it to HSV first and split the channels into H1, S1 and V1. Then perform histogram equalization on the V1 channel (which should be identical to the grayscale image above) giving V2. Finally, merge H1, S1 and V2 into a new HSV image and convert back to BGR. – beaker Aug 31 '22 at 15:07
  • @GalaxyA50 You could try a `for` loop where you multiply the input image's colors with the grey values. Example pseudo-code: `finalCol_rgb = ( (inR * grey) & (inG * grey) & (inB * grey) );`. You multiply each R/G/B channel individually before it contributes to final RGB. Finally you can also add (`plus`) the grey to each channel to boost Lightness. – VC.One Sep 01 '22 at 22:38

0 Answers0