1

我想将操作保存imshow(im16, [WC-WW/2,WC+WW/2]);在一个新变量中。这是一张我正在显示一定范围的图像,但我不想使用imshow(),我只想保存一个具有一定强度范围的新图像 WC-WW/2,WC+WW 操作的窗口结果/2。

我正在使用 Matlab 中的 CT 图像(以 png 格式),并调整窗口宽度和窗口级别。

4

1 回答 1

0

什么是将强度低于黑色(0)的imshow(im16,[WC-WW/2,WC+WW/2])每个像素放入,将强度高于白色(255)的每个像素放入,然后重新缩放剩余的像素。一种方法是:im16WC-WW/2WC+WW/2

im = imread('corn.tif',3); % your image goes here

low = 0.2*255; % lower intensity that you want to put to black (WC-WW/2)
high = 0.8*255; % upper intensity that you want to put to white (WC+WW/2)

im1 = double(im); % turn into double
idxlow = im1 <= low; % index of pixels that need to be turned to black
idxhigh = im1 >= high; % index of pixels that need to be turned to white
im1(idxlow) = 0; % black
im1(idxhigh) = 255; % white
im1(~idxlow & ~idxhigh) = im1(~idxlow & ~idxhigh) - min(im1(~idxlow & ~idxhigh),[],'all'); % rescale low values
im1(~idxlow & ~idxhigh) = im1(~idxlow & ~idxhigh).*255./max(im1(~idxlow & ~idxhigh),[],'all'); % rescale high values
im1 = uint8(im1); % turn back into uint8 (or your initial format)

只是为了检查:

figure
hold on
% Show the original image
subplot(1,3,1)
imshow(im)
title('Original')
% Show the original image reranged with imshow()
subplot(1,3,2)
imshow(im,[low,high])
title('Original scaled with imshow')
% Show the new reranged image
subplot(1,3,3)
imshow(im1)
title('New image')
于 2020-10-09T07:09:06.517 回答