フィルターのクリア

How to show the image slice from the below example?

8 ビュー (過去 30 日間)
blues
blues 2021 年 2 月 26 日
コメント済み: Walter Roberson 2021 年 2 月 28 日
Hello, I want to show the image slice from the below example, where CT and SPECT both are image array with the same width, size and spacing.
% This is a part of the code
% Visualize the CT and SPECT together
for m = 1:199
CT_img = new_CT(:,:,m);
SPECT_img = SPECT(:,:,m);
final_img = imfuse(CT_img, SPECT_img);
% Visualize CT and SPECT together
imshow(final_img, [-800 1000]);
end
% Now, I want to see the overlapped slices one by one, so I want somethig like:
show_20th_slice = imshow(final_img(:,:,20)) %...>> but this says: "Index in position 3 exceeds array bounds (must not exceed 3)."
How can I do this?

採用された回答

Walter Roberson
Walter Roberson 2021 年 2 月 26 日
% This is a part of the code
% Visualize the CT and SPECT together
for m = 1:199
CT_img = new_CT(:,:,m);
SPECT_img = SPECT(:,:,m);
final_img(:,:,:,m) = imfuse(CT_img, SPECT_img);
% Visualize CT and SPECT together
imshow(final_img(:,:,:,m), [-800 1000]);
end
% Now, I want to see the overlapped slices one by one, so I want somethig like:
show_20th_slice = imshow(final_img(:,:,:,20))
I am not sure at the moment why you are getting back color images instead of grayscale, but your error message would have been different if you were getting back grayscale.
  4 件のコメント
blues
blues 2021 年 2 月 26 日
One additional thing: When I use imfuse the colormap of CT image becomes green and SPECT becomes pink. Is there a way to change the colormap to grey and hot or jet? See attached.
Thank you, Walter, for your help. Have a great weekened.
Walter Roberson
Walter Roberson 2021 年 2 月 28 日
im1 = imread('cameraman.tif');
im2 = rgb2gray(imread('flamingos.jpg'));
im2 = imresize(im2, size(im1));
fused_by_function = imfuse(im1, im2);
fused_manually = cat(3, im2, im1, im2);
subplot(2,1,1);
imshow(fused_by_function);
title('imfuse()')
subplot(2,1,2)
imshow(fused_manually);
title('manual fuse')
max(abs(double(fused_by_function(:)) - double(fused_manually(:))))
ans = 12
We can see from this that imfuse(A,B) is effectively the same as putting B into the red and blue panes and A into the green pane.
And that in turn tells us that using a different colormap would not be easy, because it is not really "calculating" a color for each pixel, and is more "just letting it happen". So you would need a quite different approach.
Perhaps something like:
alpha = 0.7;
cmap1 = gray(256);
cmap2 = jet(256);
im1rgb = ind2rgb(im1, cmap1);
im2rgb = ind2rgb(im2, cmap2);
blended = alpha * im1rgb + (1-alpha) * im2rgb;
figure()
subplot(3,1,1)
imshow(im1rgb); title('image1 recolored');
subplot(3,1,2);
imshow(im2rgb); title('image2 recolored');
subplot(3,1,3);
imshow(blended); title('blended')

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeometric Transformation and Image Registration についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by