Thursday, May 27, 2010

Tracking w/ blob detection, morphological operation (Togeather)

frames = {avi.cdata}; %uses the cdata from the video file

fg = extractForeground(frames); % do foreground extraction
cmap = colormap(gray);

for i = 1:length(fg)
temp0{i} = edge(fg{i}, 'canny', 0.99) + fg{i};
temp2 = temp0{i};
temp2 = cat(3,temp2,temp2,temp2);

fgs = rgb2gray(temp2);
sedisk = strel('square',10);
fgs = imclose(fgs, sedisk);
fgs = imfill(fgs,'holes');
RLL = bwlabel(fgs);

stats = regionprops(RLL,'basic','Centroid');
fig = figure(1),imshow(RLL)
hold on

for n = 1:length(stats)
if(stats(n).Area > 100)
plot(stats(n).Centroid(1), stats(n).Centroid(2),'r*')
end
end
hold off


end;

clear all;

5 comments:

  1. frames = {avi.cdata}.it post this message after i enter the command.Undefined variable "avi" or class "avi.cdata". what does it imply?thank you..

    ReplyDelete
  2. it means u did not set the variable "avi", you need to do something like

    avi = aviread('somevideo.avi');
    frames = avi.cdata;

    ReplyDelete
  3. Sorry for late.I have try this
    >> avi = aviread('somevideo.avi');

    and it show this:
    ??? Error using ==> readavi
    Error getting frame data.

    Error in ==> aviread at 64
    X = readavi(info.Filename,-1);

    What wrong with the command? After I tried this and it works,
    >> avi = aviread('somevideo.avi',1);

    Is there any significant between those two command? Thank you.

    ReplyDelete
  4. by the way..i can use the extractForeground.m i get from matlab.It got error stated;

    ??? Error using ==> subsref
    Index exceeds matrix dimensions.

    Error in ==> extractForeground>pctile at 261
    pct = subsref(sx,ref);

    Error in ==> extractForeground at 98
    backgroundDeviation(:,:,1) =
    max(backgroundDeviation(:,:,1),pctile(nonzeros(backgroundDeviation(:,:,1)),minSigmaLevel));

    Error in ==> blob_morphological at 14
    fg = extractForeground(frames); %foreground extraction

    Do you know what can i do to solve it and why it happen?

    Thank you again.

    ReplyDelete
  5. do you hav any idea about oil leakage detection using matlab if so mail me @ sujith.oilleakage@gmail.com

    ReplyDelete