多个图像 - Matlab [英] Multiple Images - Matlab

查看:124
本文介绍了多个图像 - Matlab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个matlab项目,它将视频作为输入,将其剪切成帧,并逐个向用户显示帧,使他能够对每个帧进行更改。

I have written a matlab project that takes a video as an input, cuts it into frames, and shows the frames to the user one by one, giving him the ability to make changes to each frame.

我想添加一个侧边栏,向用户显示一个特定的框架,以及1到10个GUI框架的按钮,当他可以按 - >或< - 移动到prev \ next 10帧,并且可以点击一个框架以更大的尺寸显示它。

I want to add a "side bar", that shows a particular frame to the user, as well as buttons for GUI frames from 1 to 10, when he can press on "->" or "<-" to move to prev\next 10 frames, and can click on a frame to show it in a larger size.

这样的事情:

   This is the GUI:




.__________________________________.
|                                  | 
|          Frame No. i             | 
|                                  | 
|--------------------------------- | 
|<-| Frame j|j+1|.....|Frame j+9|->| 
|__________________________________|


我想过使用subplot但不知道如何添加在点击时显示\update prev \\\
ext框架的功能。

I thought about using "subplot" but didn't know how to add the ability to show\update prev\next frames on clicking.

另一种实现是这样的:

% The Main Image:
   hAx = axes('Position',[0 0.3 1 0.8], 'Parent',hFig);
   hMainImg = imshow(img, 'Parent',hAx);

% the slider
hPanel = uipanel('Position',[0 0.04 1 0.26], 'Parent',hFig);
uicontrol('Style','slider', 'Parent',hFig, ...
    'Callback',@slider_callback, ...
    'Units','normalized', 'Position',[0 0 1 0.04], ...
    'Value',1, 'Min',1, 'Max',mx, 'SliderStep',[1 10]./mx);

但是,滑块怎么样?

任何想法我该如何实现?

Any ideas how can I implement this?

推荐答案

这是一个有效的例子。我们打开一个小视频文件,读取所有141帧。您可以使用滑块浏览它们,单击任何小图像以在主轴上显示它。

Here is a working example. We open a small video file, and reads all its 141 frames. You can browse through them using the slider, click any small image to display it in the main axis.

function framesBrowserDemo()
    %# read all frames at once
    vid = VideoReader('xylophone.mpg');
    numImgs = get(vid, 'NumberOfFrames');
    frames = read(vid);
    clear vid

    %# design GUI
    numThumbs = 5;
    mx = numImgs-numThumbs+1;
    hFig = figure('Menubar','none');
    hPanel = uipanel('Position',[0 0.04 1 0.16], 'Parent',hFig);
    uicontrol('Style','slider', 'Parent',hFig, ...
        'Callback',@slider_callback, ...
        'Units','normalized', 'Position',[0 0 1 0.04], ...
        'Value',1, 'Min',1, 'Max',mx, 'SliderStep',[1 10]./mx);

    %# main axis, and show first frame
    hAx = axes('Position',[0 0.2 1 0.8], 'Parent',hFig);
    hMainImg = imshow(frames(:,:,:,1), 'Parent',hAx);

    %# thumbnail axes
    hThumImg = zeros(numThumbs,1);
    for i=1:numThumbs
        %# create axis, show frame, hookup click callback
        hAx = axes('Parent',hPanel, ...
            'Position',[(i-1)/numThumbs 0 1/numThumbs 1]);
        hThumImg(i) = imshow(frames(:,:,:,i), 'Parent',hAx);
        set(hThumImg(i), 'ButtonDownFcn',@click_callback)
        axis(hAx, 'normal')
    end

    %# callback functions
    function slider_callback(src,~)
        val = round(get(src,'Value'));  %# starting index
        %# update the thumbnails
        for k=1:numel(hThumImg)
            set(hThumImg(k), 'CData',frames(:,:,:,k+val-1))
            drawnow
        end
    end

    function click_callback(src,~)
        %# update the main image
        set(hMainImg, 'CData',get(src,'CData'));
        drawnow
    end
end

这篇关于多个图像 - Matlab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆