plt.imshow显示CT/MRI图像

先看一下plt.imshow

help(plt.imshow)

下面只是显示此博客关注的关键部分,完整的可以自己运行命令查看。

imshow(X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=None, vmin=None, vmax=None, origin=None, extent=None, shape=None, filternorm=1, filterrad=4.0, imlim=None, resample=None, url=None, *, data=None, **kwargs)
    Display an image, i.e. data on a 2D regular raster
    Parameters
    ----------
    X : array-like or PIL image
        The image data. Supported array shapes are:
    
        - (M, N): an image with scalar data. The data is visualized
          using a colormap.
        - (M, N, 3): an image with RGB values (float or uint8).
        - (M, N, 4): an image with RGBA values (float or uint8), i.e.
          including transparency.
        The RGB(A) values should be in the range [0 .. 1] for floats or
        [0 .. 255] for integers.  Out-of-range values will be clipped to
        these bounds.
    
    cmap : str or `~matplotlib.colors.Colormap`, optional
        A Colormap instance or registered colormap name. The colormap
        maps scalar data to colors. It is ignored for RGB(A) data.
        Defaults to :rc:`image.cmap`.
    ...
    ...
    ...
    
    Returns
    -------
    image : `~matplotlib.image.AxesImage`

注意,一般显示医疗影像的时候,我们读取的是其中的一个切片,所以使用的是 ( M , N ) (M,N) M,N,而千万不要自作聪明,将 ( M , N ) (M,N) M,N扩展成 ( M , N , 3 ( 4 ) ) (M,N,3(4)) M,N,3(4)这种形式。具体原因:

The RGB(A) values should be in the range [0 … 1] for floats or
[0 … 255] for integers. Out-of-range values will be clipped to
these bounds.

会对像素值进行自动裁剪的!!

dicom

plt.imshow(filedata,cmap=plt.cm.bone)

plt.imshow显示CT/MRI图像_第1张图片
有关cmap=plt.cm.bone,
参考https://matplotlib.org/3.1.0/gallery/color/colormap_reference.html?highlight=bone
plt.imshow显示CT/MRI图像_第2张图片

你可能感兴趣的:(医疗影像处理)