I croped some parts of images and displayed them in one figure with subplots. Number of subplots are not certain. I read images from a file then crop them. My aim is that wh
I had same problem, change your function like below then it will be solved:
function newFigure1(h1, h2)
figure()
data = get(h1, 'CData');
colormap(gray);
imagesc(data)
end
The example uses the ButtonDownFcn that can be added to most matlab plot commands. Just copy both functions into one file and run the "interactivePlot" function.
The list_of_images contains all matrices that shall be plotted. The number of matrices is flexible. However, you have to adjust the subplot command...
function interactivePlot
list_of_images = {rand(5), rand(10), rand(50), rand(100)}
for ii = 1:length(list_of_images)
subplot(2,2,ii)
imagesc(list_of_images{ii}, 'ButtonDownFcn', @newFigure1)
end
end
function newFigure1(h1, h2)
figure()
data = get(h1, 'CData');
imagesc(data)
end