0
I’m testing some algorithms to improve the image quality that my hardware is getting. I have in the image a pick and I would like to highlight the object contained in it.
I used the code below to equalize the image, but I was not successful.
import cv2
import numpy as np
def histogram_equalize(img):
b, g, r = cv2.split(img)
red = cv2.equalizeHist(r)
green = cv2.equalizeHist(g)
blue = cv2.equalizeHist(b)
return cv2.merge((blue, green, red))
img = cv2.imread('pos20.jpg')
img_yuv = cv2.cvtColor(img, cv2.COLOR_BGR2YUV)
# equalize the histogram of the Y channel
img_yuv[:,:,0] = cv2.equalizeHist(img_yuv[:,:,0])
# convert the YUV image back to RGB format
img_output = cv2.cvtColor(img_yuv, cv2.COLOR_YUV2BGR)
cv2.imshow('Color input image', img)
cv2.imshow('Histogram equalized', img_output)
cv2.imwrite('20.jpg',img_output)
cv2.waitKey(0)
Output:
what is the best algorithm to improve image quality and highlight the edge of the object?
But the result of equalization is just that, the problem there is the original image, try to equalize with the Numpy and probably the result will be very similar.
– Sidon
Your question has many problems, as I mentioned earlier. You don’t say exactly what is object, you don’t define what is "quality" in the context, you don’t say clearly your intention (just say you want to "highlight the edge of the object"). If you want to highlight the edge, why not use a border sensitive filter, such as a gradient or the famous Canny in place of equalization?
– Luiz Vieira