2012-06-01 124 views
2

向大家致意。在MATLAB中播放圖像序列

我有這個有點令人沮喪的問題,我希望你能幫我解決它。

我正在MATLAB開發一個人體跟蹤系統,並希望在一個吸引人的GUI中顯示結果(同樣在使用GUIDE的MATLAB中)。

有一個主窗口,其中大小爲320x240的大約2500個灰度圖像的圖像序列將像視頻一樣播放,但人物在其中很好地勾勒出來。

挑戰在於;這些圖像在顯示在窗口上之前需要一些處理(檢測概述人類)。

現在,是否可以顯示一組圖像,同時對另一組圖像進行一些處理以後再顯示?

我非常喜歡它像普通的視頻一樣播放,但我想這會有點雄心勃勃。

+0

只是一個想法:怎麼樣做處理,並捕獲每個圖像的結果。然後以接近實時的速度播放整部電影。 – Amro

+0

@Amro嘿,夥計,很高興再次收到你的來信。 – Absi

+0

正如我所說,有2500個圖像,每個處理都會消耗大量時間,無論如何顯示結果都太晚了。但如果找不到其他解決方案,這將是最後的手段。 – Absi

回答

2

下面是一個示例,顯示與您所描述的情況類似的情況。這是從我在評論中提到的demo改編而來的。

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 

screenshot