How to display Images in the Same Figure?

I want to use the imshow function and set function (both of them) with the MATLAB subplot function to display multiple images in a single figure window. But because of the set function in the following code, it isn't possible. How to solve it?
if str2num(N1(1:end-4)) == str2num(N2(1:end-4))
subplot(1,2,1);
imshow(volume_image(:, :, i), []);
green = cat(3, zeros(size(volume_image(:, :, i))), ones(size(volume_image(:, :, i))), zeros(size(volume_image(:, :, i))));
subplot(1,2,2);
h = imshow(green);
set(h, 'AlphaData', double(Rad_Img));
end

2 commentaires

Walter Roberson
Walter Roberson le 10 Jan 2019
You are missing a ) in the set command.
elham
elham le 11 Jan 2019
@Walter Roberson: Yes, it occurred during edition, but the problem isn't because of it.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 10 Jan 2019
AlphaData must be in the range 0 to 1. I suspect your Rad_Img is uint8, range 0 to 255; if so then double() would produce 0.0 to 255.0 instead of 0 to 1. Perhaps
set(h, 'AlphaData', im2double(Rad_Img));

6 commentaires

elham
elham le 11 Jan 2019
It occurred during edition, but the problem isn't because of it.
Walter Roberson
Walter Roberson le 11 Jan 2019
It is not clear to me why you would want to construct a green image and then use a different image as the AlphaData for the green image, but perhaps you have your reasons.
What difficulty are you having after making the change I show here?
elham
elham le 11 Jan 2019
Modifié(e) : elham le 11 Jan 2019
Fig1:
Fig2:
So, I want to show Fig1, instead of the green figure in the Fig2.
Do not use subplot() for that purpose. Use
hold on
after the first imshow(), and
hold off
after the second imshow()
elham
elham le 11 Jan 2019
Modifié(e) : elham le 11 Jan 2019
@Walter Roberson: I have tried it, but I want to show Fig1 image and the final image after set(h, 'AlphaData', double(Rad_Img)) in a single figure window. Then, the subplot is needed.
elham
elham le 11 Jan 2019
@Walter Roberson: I did it with a duplicate of the same code.

Connectez-vous pour commenter.

Question posée :

le 10 Jan 2019

Commenté :

le 11 Jan 2019

Community Treasure Hunt

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

Start Hunting!

Translated by