No available image handler could decode this transfer syntax JPEG Lossless when read DICOM and ploting using matplotlib

后端 未结 3 689
旧巷少年郎
旧巷少年郎 2021-01-16 07:11

When i use pydicom in python3.6, there are some problem:

import pydicom
import matplotlib.pyplot as plt
import os
import pylab

filePath = \"/Users/zhuangrui         


        
3条回答
  •  迷失自我
    2021-01-16 07:52

    Problem:

    I was trying to read medical images with .dcm extension. But was getting an error on Windows as well as on Ubuntu. I find a solution which will work on both the machined.

    The error I got on Ubuntu is: NotImplementedError: this transfer syntax JPEG 2000 Image Compression (Lossless Only), can not be read because Pillow lacks the jpeg 2000 decoder plugin

    (Note for Windows I was getting a different error but I am sure it's because of the same issue i.e. Pillow does not support JPEG 2000 format)

    Platforma Information:

    1. I am using: Python 3.6, Anaconda and Ubuntu, 15 GB RAM

    RAM is important:

    The solution I applied is the same as Ali explained above. But I want to add this installation may take time (depending on RAM you are using). On ubuntu where I am using 15 GB RAM on Cloud platform taken less time and on Windows on a local machine having 4 GB RAM taken a lot of time.

    Solution

    1. Anaconda is necessary. Why? Please check the official doc of pydicom (https://pydicom.github.io/pydicom/dev/getting_started.html) its mentioned "To install pydicom along with image handlers for compressed pixel data, we encourage you to use Miniconda or Anaconda" (Note for Windows I was getting a different error)

    2. If you are using Ubuntu directly open Terminal. If you are using Windows then on Anaconda Navigator go to Environment from here start terminal. Execute the following commands on it:

      pip install -U git+https://github.com/pydicom/pydicom.git

      conda install pydicom --channel conda-forge

      conda install -c conda-forge gdcm

    Cross Check:

    Now use .dcm file for which we got the Error. Try to use the following code in Python notebook

    filename = 'FileName.dcm'
    ds = pydicom.dcmread(filename)
    plt.imshow(ds.pixel_array, cmap=plt.cm.bone) 
    

    It should print the output. Also try this code:

    ds.pixel_array
    

    This will give you the array containing values.

提交回复
热议问题