Reputation: 141
i want to change pixel range from [0,255] to [0,1] in opencv. Is there any pre-made functions in numpy or openCV to do that? Or i need to do it handy!?
Can i use cv.normalize?
norm_image = cv2.normalize(img, None, alpha = 0, beta = 1, norm_type = cv2.NORM_MINMAX, dtype = cv2.CV_64F)
Upvotes: 2
Views: 8364
Reputation: 476557
An opencv image is just a numpy array. You can thus convert the type to a float
(or another number type that can work with fractional numbers), and then divide by 255.
So if you have an image a
, then you can convert it with:
b = a.astype(float) / 255
Upvotes: 3