Displaying whole image by clicking on a subplot

后端 未结 2 1100
太阳男子
太阳男子 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:41

    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 
    
    0 讨论(0)
  • 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    
    
    0 讨论(0)
提交回复
热议问题