Clear Filters
Clear Filters

overlay two images in GUI

36 views (last 30 days)
Dimani4
Dimani4 on 23 May 2021
Edited: Dimani4 on 24 May 2021
Hi,
I can't overlay two pictures in gui but I succeed to do this in figure. Take a look at my code when I do in Figure:
function link2axes(whole_matrix_sum,topography_trace)
figure;
ax1=axes;
raman=imagesc(whole_matrix_sum);
ax2=axes;
topography_image=imagesc(topography_trace);
linkaxes([ax1,ax2]);
ax2.Visible = 'off';
ax2.XTick = [];
ax2.YTick = [];
colormap(ax1,'jet'); %raman
colormap(ax2,'parula'); %topography
set(raman, 'AlphaData', double(whole_matrix_sum > 0));
set(topography_image, 'AlphaData', 0.6);
Here I have 2 images (2 matrices of 40X40 pixels). I succeed to do this when I create a figure but I cannot succeed it in Gui.
In Gui I try to write the similar thing but somehow it doesnt do overlay.
See attached the result of overlay of 2 pictures in Figure (as written in the attached code below).
I have the handle which points on axes1 in the gui as handles.axes1.
I try to write code according the code which works on simple Figure as following:
axes(handles.axes1);
ax1=handles.axes1;
raman=imagesc(whole_matrix_sum);
raman.Parent;
ax2=raman.Parent;
topography_image=imagesc(topography_trace);
topography_image=imagesc(handles.topography_trace);
linkaxes([ax1,ax2]);
colormap(ax1,'jet'); %raman
colormap(ax2,'parula'); %topography
set(raman, 'AlphaData', double(whole_matrix_sum > 0));
Error using matlab.graphics.primitive.Image/set
Invalid or deleted object.
Here the matrix of topography I bring from another function that's why it's located in handles.
I attach 2 matrices as well.
As you can see I want overlay two pictures and to control transparency of the one of the pictures.
Where is my mistake?
Thank you very much.

Answers (0)

Community Treasure Hunt

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

Start Hunting!