Displaying whole image by clicking on a subplot

后端 未结 2 1102
太阳男子
太阳男子 2021-01-15 14:08

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

2条回答
  •  情话喂你
    2021-01-15 14:57

    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    
    

提交回复
热议问题