0% found this document useful (0 votes)
33 views

Bab I Desain Sistem: 1.1 Blok Diagram

The document describes the steps in an optical flow algorithm to estimate pixel velocity between two consecutive frames in a video. The steps include: 1) Reading in a video file and extracting the frames, 2) Converting frames to grayscale, 3) Applying a Hom-Schunck optical flow method to estimate velocity vectors, 4) Calculating the magnitude squared of the velocity vectors, 5) Thresholding to isolate motion regions, 6) Applying median filtering and morphological closing, 7) Identifying motion regions using region properties, 8) Drawing rectangles on regions and counting objects passing a threshold.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Bab I Desain Sistem: 1.1 Blok Diagram

The document describes the steps in an optical flow algorithm to estimate pixel velocity between two consecutive frames in a video. The steps include: 1) Reading in a video file and extracting the frames, 2) Converting frames to grayscale, 3) Applying a Hom-Schunck optical flow method to estimate velocity vectors, 4) Calculating the magnitude squared of the velocity vectors, 5) Thresholding to isolate motion regions, 6) Applying median filtering and morphological closing, 7) Identifying motion regions using region properties, 8) Drawing rectangles on regions and counting objects passing a threshold.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

BAB I DESAIN SISTEM

1.1

Blok Diagram

Optical Flow didefinisikan sebagai suatu gerakan yang tampak karena adanya perpindahan pola brightness pada dua buah bidang citra dengan mengasumsikan bahwa brightness tiap elemen citra yang lain konstan dari waktu ke waktu. Optical flow field (medan optical flow) merupakan medan vektor kecepatan sesaat dari pixel pixel yang berpindah antara satu citra dan citra lain berikutnya. Masalah dalam optical flow adalah bagaimana mengestimasi kecepatan perpindahan pixel pada dua buah citra berurutan. 1.1.1 Input Video

Soruce code :
mmobj = mmreader('160x120_10fps_A.avi'); dur=mmobj.Duration; nframes = mmobj.NumberOfFrames; height = mmobj.Height; width = mmobj.Width; datavid=read(mmobj); prevframe=rgb2gray(datavid(:,:,:,1)); for k=2:nframes %% tampilin frame xx=(datavid(:,:,:,k)); imshow(xx) hold on

1.1.2 RGB to Intensity (Grayscale)


Source code : frame=rgb2gray(xx);

1.1.3 Hom- Schunck Optical Flow


alpha=10; iterations=10; rata2=0; rat(1)=0; COUNT=0; images=cat(3,prevframe,frame); [vx vy of] = OpticalFlow2(images,alpha,iterations); prevframe=frame;

1.1.4 Magnitude Square Source code :


gg=vx.^2 + vy.^2

1.1.5 Thresholding
Source code : temp=mean(gg(:)); rat(k)=temp; rata2=rata2+temp; thr=rata2/k; gg=gg>thr;

1.1.6 Median Filter (Kernel 3x3)


gg=medfilt2(gg,[3 3]);

1.1.7 Morpholoical Closing


xx= strel('line',5,45); gg=imclose(gg,xx);

1.1.8 Region Filtering


Source code : markimg = regionprops(gg,['basic']); [MM,NN] = size(markimg); % Do bubble sort (large to small) on regions in case there are more than 1 % The largest region is the object (1st one) for nn = 1:MM if markimg(nn).Area > markimg(1).Area tmp = markimg(1); markimg(1)= markimg(nn); markimg(nn)= tmp; end end

% Get the upper-left corner, the measurement centroid and bounding window size bb = markimg(1).BoundingBox; xcorner = bb(1); ycorner = bb(2); xwidth = bb(3); ywidth = bb(4); cc = markimg(1).Centroid; centroidx= cc(1); centroidy= cc(2);

1.1.9 Counting Source code :


if centroidy >102 && tmp(1).Area < 1300 COUNT=COUNT+1; end

% Plot the rectangle of background subtraction algorithm -blue hold on rectangle('Position',[xcorner ycorner xwidth ywidth],'EdgeColor','b','Linewidth',1.5); hold on plot(centroidx,centroidy, 'b*'); catch hold on; end pause(0.01) end

You might also like