如何在OpenCV中将16位图像转换为8位图像? [英] How to convert a 16 bit to an 8 bit image in OpenCV?
本文介绍了如何在OpenCV中将16位图像转换为8位图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个16位灰度图像,我想将其转换为OpenCV中的8位灰度图像,以便python使用它具有各种功能(如findContours等)。是可以在python中完成它还是我必须切换到C ++?
I have a 16bit grayscale image and I want to convert it to a 8bit grayscale image in OpenCV for python to use it with various functions (like findContours etc.). Is it possible to do it in python or I have to switch to C++?
推荐答案
你可以使用numpy转换方法作为OpenCV mat是一个numpy数组。
You can use numpy conversion methods as an OpenCV mat is a numpy array.
这个有效:
img8 = (img16/256).astype('uint8')
这篇关于如何在OpenCV中将16位图像转换为8位图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文