12bit灰度图像映射到8bit显示及python 实现
来源:互联网 发布:数据传输软件 编辑:程序博客网 时间:2024/05/22 01:57
图像显示和打印面临的一个问题是:图像的亮度和对比度能否充分突出关键部分。这里所指的“关键部分”在 CT 里的例子有软组织、骨头、脑组织、肺、腹部等等。
技术问题
1、显示器往往只有 8-bit, 而数据有 12- 至 16-bits。
2、如果将数据的 min 和 max 间 (dynamic range) 的之间转换到 8-bit 0-255 去,过程是个有损转换, 而且出来的图像往往突出的是些噪音。
算法分析
12-bit 到 8-bit 直接转换:
computeMinMax(pixel_val, min, max); // 先算图像的最大和最小值 for (i = 0; i < nNumPixels; i++) disp_pixel_val[i] = (pixel_val[i] - min)*255.0/(double)(max-min);
这个算法必须有,对不少种类的图像是很有效的:如 8-bit 图像,MRI, ECT, CR 等等。
python实现
def matrix2uint8(matrix): ''' matrix must be a numpy array NXNReturns uint8 version ''' m_min= np.min(matrix) m_max= np.max(matrix) matrix = matrix-m_min return(np.array(np.rint( (matrix-m_min)/float(m_max-m_min) * 255.0),dtype=np.uint8)) #np.rint, Round elements of the array to the nearest integer.
def preprocess(img, crop=True, resize=True, dsize=(224, 224)): if img.dtype == np.uint8: img = img / 255.0 if crop: short_edge = min(img.shape[:2]) yy = int((img.shape[0] - short_edge) / 2) xx = int((img.shape[1] - short_edge) / 2) crop_img = img[yy: yy + short_edge, xx: xx + short_edge] else: crop_img = img if resize: norm_img = imresize(crop_img, dsize, preserve_range=True) else: norm_img = crop_img return (norm_img).astype(np.float32)def deprocess(img): return np.clip(img * 255, 0, 255).astype(np.uint8)
参考文献
16bit灰度图像映射到8bit显示
阅读全文
0 0
- 12bit灰度图像映射到8bit显示及python 实现
- 16bit灰度图像映射到8bit显示
- 16bit灰度图像映射到8bit显示
- 16bit灰度图像映射到8bit显示
- 24bit彩色图像转8bit灰度图
- CImage图像得到BYTE数组数据 - 8bit灰度图像
- 8bit、12bit、16bit图像数据
- C#中将byte数组转换为8bit灰度图像
- C#中将byte数组转换为8bit灰度图像
- bmp头文件和8 bit 灰度图的显示
- 使用GDAL将12bit量化图像转为16bit或者8bit
- 利用自动色阶原理,将遥感图象从16Bit映射到8bit
- python存储16bit和32bit图像
- python的meshgrid的用法及灰度图像的显示
- 32-bit到64-bit 开发及升级经验
- 使用C语言实现采样位16bit到8bit的转换
- 图像灰度变换及实现
- 图像灰度变换及实现
- poj2488 A Knight's Journey 之 dfs解法
- PHP写webservices接口
- windows下elasticsearch5.6.0 安装x-pack
- 适合新手的Linux发行版
- [转载]如何管理数百个微服务并避免踩坑?
- 12bit灰度图像映射到8bit显示及python 实现
- 欢迎使用CSDN-markdown编辑器
- 数据库事务基础
- Ubuntu 串口测试
- IO多路复用之select总结
- androidstudio module 应用进阶
- Springboot restTempate POST 上传图片
- [转载]微服务实施Spring Cloud中踩过的坑
- No suitable driver found for jdbc:mysql://localhost/mysql