MATLAB Answers

0

How to merge between an image object and a surface object?

Asked by Stanislav Steinberg on 24 Jan 2019
Latest activity Answered by Stanislav Steinberg on 28 Jan 2019
Given an array of images of some size N,
I display an image from that array using imshow():
I = imshow(ImgArr(n))
Capture.PNG
Next, I create a surface overlay that displays a heatmap:
H = surface(x,y,v)
set(H,'EdgeAlpha',0,'FaceAlpha',0.5);
colormap('jet')
Capture.PNG
Now I have two objects: I is the Image object and H is the surface object.
I want to merge between I and H and get an array of merged images that can be displayed using the function montage().
End result should look like this for example (minus the white spaces...) .
Capture.PNG Capture.PNG Capture.PNG
Capture.PNG Capture.PNG Capture.PNG
Any tips on how to do this?
Note: I want to avoid saving anything to the hard disk except perhaps the final montage.

  0 Comments

Sign in to comment.

1 Answer


The solution I came up with thus far (may not be the most elegant):
k=1;
for/while loop
% open a new frame
frame = figure('Visible','off');
% draw whatever it is you draw here
% save frame data into an array
q = getframe(frame);
ImgArray(:,:,:,k) = q.cdata;
k=k+1;
end
fig = figure('Visible', 'on');
montage(ImgArray, 'Size', [num_of_rows num_of_cols]);
Will gladly accept better solutions.

  0 Comments

Sign in to comment.