Ask Your Question

the dtype of read image

asked 2017-02-19 17:46:12 -0600

surfreta gravatar image


I have read an image as follows

image = cv2.imread('/data/cat.jpg',cv2.IMREAD_UNCHANGED)
print('image dtype ',image.dtype)

The dtype for the read image is uint8, how to transfer it into float32 or what kind of read option can enforce the read image as float32.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2017-02-19 22:26:09 -0600

Tetragramm gravatar image

You can simply use the numpy functions

floatImage = np.float32(image)
edit flag offensive delete link more

answered 2017-02-20 02:59:43 -0600

pi-null-mezon gravatar image

updated 2017-02-20 03:01:13 -0600

Use Mat::convertTo(...) function.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-02-19 17:46:12 -0600

Seen: 28,361 times

Last updated: Feb 20 '17