简体   繁体   English

如何更改Dicom图像的灰度?

[英]How to change gray level of Dicom image?

I am working gray images in which gray level lies 0 to 255 . 我正在处理灰度值为0到255的灰度图像。 I want to work on Dicom images but maximum gray level of dicom image is grater than 255. I just want to know that how to change dicom image with maximum gray level 255. 我想处理Dicom图像,但dicom图像的最大灰度大于255。我只想知道如何更改最大灰度为255的dicom图像。

Thanks in advance. 提前致谢。

You can normalize the images so that they have a range of [0,1] . 您可以对图像进行规格化,使其具有[0,1]的范围。 Once you do this, you can scale the image by 255 to bring this to a range of [0,255] . 完成此操作后,您可以将图像缩放255倍,以使其达到[0,255]的范围。 Assuming your image is stored in im , you can do this: 假设您的图片存储在im ,则可以执行以下操作:

im = double(im);
im = (im - min(im(:))) / (max(im(:)) - min(im(:))); %// Normalize to 0-1
im = uint8(255*im); %// Scale to 255

min(im(:)) will find the minimum intensity of your entire image while max(im(:)) will find the maximum intensity of your entire image. min(im(:))将找到整个图像的最小强度,而max(im(:))将找到整个图像的最大强度。 Note that once I scale the image, I cast to uint8 as this will the proper data type associated with this intensity range. 请注意,缩放图像后,将转换为uint8因为这将是与该强度范围关联的正确数据类型。

However, MATLAB has functionality that already normalizes between [0,1] with im2double . 但是,MATLAB的功能已使用im2double[0,1]之间进行了im2double This takes in an image of any precision and normalizes the image to [0,1] . 这将获取任何精度的图像,并将图像标准化为[0,1] You can then take this output, multiply by 255 and cast to uint8 : 然后,您可以将该输出乘以255并转换为uint8

im = uint8(255*im2double(im));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM