Hi guys,
I am currently trying to normalize an RGB image coming from the onboard camera to delete the brightness influence, but all I get is a black image.
Here is the code of my function:
def normalization(img):
for i in xrange(3):
img[:,:,i]=np.absolute((img[:,:,i]-np.min(img[:,:,i]))/(np.max(img[:,:,i])-np.min(img[:,:,i])))*255
return img
If someone could tell me why it’s wrong i would appreciate.
Thank you
I wasn’t able to reproduce this result executing the code that you provided. Perhaps there is some discrepancy in how I tested
(a) What is the data type of the image that you’re providing to the normalization function?
(b) How do you determine that the image is ‘black’? Ie, are you displaying the image using some other function, or printing values, etc.
Also, depending on your application it might be worth considering using an existing method for balancing the image, like histogram equalization. OpenCV provides a function that accomplishes this
Hi jaybdub,
what do you get when you’re using my function ?
to answer your question:
(a): I just use cv2.VideoCapture and then cap.read() to get a frame that I put in the function call. If I’m right it’s a numpy array.
(b): I show the image out of the function using imshow().
I already tried this function, but it seems to me it only normalize intensity…(value part of HSV) and what I need is to normalize through the 3 colors RGB…
You may try to look at min and max of your image with cv2.minMaxLoc.
You might find that min is 0 and max 255, so it doesn’t rescale.
Think about dead and hot pixels. So you may use some filtering before.
You may also use cv2.split for checking each BGR component, and apply cv2.normalize on each and then merge these again into your output BGR frame.