下面是一個示例,顯示與您所描述的情況類似的情況。這是從我在評論中提到的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
只是一個想法:怎麼樣做處理,並捕獲每個圖像的結果。然後以接近實時的速度播放整部電影。 – Amro
@Amro嘿,夥計,很高興再次收到你的來信。 – Absi
正如我所說,有2500個圖像,每個處理都會消耗大量時間,無論如何顯示結果都太晚了。但如果找不到其他解決方案,這將是最後的手段。 – Absi