2

向你们所有人问好。

我有这个有点令人沮丧的问题,我希望你能帮我解决它。

我正在 MATLAB 中开发人类跟踪系统,并希望在一个吸引人的 GUI 中显示结果(也在 MATLAB 中使用 GUIDE)。

在这个主窗口中,大约 2500 张大小为 320x240 的灰度图像的图像序列将像视频一样播放,但人物在其中被很好地勾勒出来。

挑战是;这些图像在显示在窗口上之前需要进行一些处理(检测人体轮廓)。

现在,是否可以在显示一组图像的同时对稍后显示的另一组图像进行一些处理?

我非常希望它像普通视频一样播放,但我想这会有点雄心勃勃。

4

1 回答 1

2

这是一个示例,显示类似于您所描述的场景。这是改编自我在评论中提到的演示。

function ImgSeqDemo()
    figure()
    for i=1:10
        %# read image
        img = imread( sprintf('AT3_1m4_%02d.tif',i) );

        %# process image to extract some object of interest
        [BW,rect] = detectLargestCell(img);

        %# show image
        imshow(img), hold on

        %# overlay mask in red color showing object
        RGB = cat(3, BW.*255, zeros(size(BW),'uint8'), zeros(size(BW),'uint8'));
        hImg = imshow(RGB); set(hImg, 'AlphaData',0.5);

        %# show bounding rectangle
        rectangle('Position', rect, 'EdgeColor','g');
        hold off

        drawnow
    end
end

这是上面使用的处理函数。在您的情况下,您将插入您的算法:

function [BW,rect] = detectLargestCell(I)
    %# OUTPUT
    %#    BW    binary mask of largest detected cell
    %#    rect  bounding box of largest detected cell

    %# find components
    [~, threshold] = edge(I, 'sobel');
    BW = edge(I,'sobel', threshold*0.5);
    se90 = strel('line', 3, 90);
    se0 = strel('line', 3, 0);
    BW = imdilate(BW, [se90 se0]);
    BW = imclearborder(BW, 4);
    BW = bwareaopen(BW, 200);
    BW = bwmorph(BW, 'close');
    BW = imfill(BW, 'holes');

    %# keep largest component
    CC = bwconncomp(BW);
    stats = regionprops(CC, {'Area','BoundingBox'});
    [~,idx] = max([stats.Area]);
    rect = stats(idx).BoundingBox;
    BW(:) = 0;
    BW(CC.PixelIdxList{idx}) = 1;
end

截屏

于 2012-06-01T07:36:58.647 回答