zoukankan      html  css  js  c++  java
  • 利用直方图均衡化调整胸片对比度

    拍摄出来的胸片用microDicom读取后有的会不大清楚,microDicom本身并没有调整对比度的功能,我也不大清楚有没有其它读胸片的软件可以调整对比度,于是查阅不少博客,看到有用直方图均衡化来做的,自己试了下效果还不错。

    导入相关包

    import pydicom
    import cv2
    import matplotlib.pyplot as plt
    

    定义调整对比度的函数,调用了opencv中CLAHE(contrast limited adaptive histogram equalization对比度受限直方图均衡化)的库函数

    def limitedEqualize(img_array, limit = 20.0):
        clahe = cv2.createCLAHE(clipLimit = limit, tileGridSize = (8,8))
        return clahe.apply(img_array)
    

    读取胸片和像素矩阵

    ds = pydicom.read_file(filename)
    data = ds.pixel_array
    

    利用matplotlib分别显示原始数据和经过直方图均衡化的数据

    plt.subplot(121)
    plt.imshow(data, cmap='gray')
    
    plt.subplot(122)
    plt.imshow(limitedEqualize(data),cmap='gray')
    

    效果图,左边是原图,右边是处理过的

  • 相关阅读:
    hibernate 映射<二>一对一主键关联
    C# Convert Type to T
    008 OS模块
    001基础知识补充与拓展
    005Buffer(缓冲区)
    009path模块
    002nodejs简介与安装
    007http模块
    004NPM包管理器
    003nodejs的模块化
  • 原文地址:https://www.cnblogs.com/wzyuan/p/10170607.html
Copyright © 2011-2022 走看看