Open Cv支持DICOM图像

时间:2015-06-02 11:52:29

标签: matlab opencv dicom

我想问一下open cv是否支持DICOM图像?

是否可以在opencv中实现DICOM图像的matlab功能

2 个答案:

答案 0 :(得分:1)

没有OpenCV不支持DICOM格式,但是python库名pydicom image可以做到你可以通过以下函数打开它

def read_xray(path, voi_lut = True, fix_monochrome = True):
    # Original from: https://www.kaggle.com/raddar/convert-dicom-to-np-array-the-correct-way
    dicom = dcmread(path)
    
    # VOI LUT (if available by DICOM device) is used to transform raw DICOM data to 
    # "human-friendly" view
    if voi_lut:
        data = apply_voi_lut(dicom.pixel_array, dicom)
    else:
        data = dicom.pixel_array
               
    # depending on this value, X-ray may look inverted - fix that:
    if fix_monochrome and dicom.PhotometricInterpretation == "MONOCHROME1":
        data = np.amax(data) - data
        
    data = data - np.min(data)
    data = data / np.max(data)
    img = (data * 255).astype(np.uint8)
        
    return img

在执行 install pydicom 并从这里帮助库之前。 Installation of pydicom

答案 1 :(得分:0)

由于FAQ,OpenCV不支持DICOM图像。

http://answers.opencv.org/question/52181/dicom-images-in-opencv/