Friday, 18 July 2014

To find transpose of an image

for i=1:512
   for j=1:512
    B(j,i)=A(i,j);
 end
end


Vertical Flip

for i=1:512
   for j=1:512
    B(i,512+1-j)=A(i,j);
 end
end

Image Cropping

for k=0:64-1
    for l=0:128-1
        B(k+1,l+1)=A(255+k+1,255+l+1);
  end
end
 

Thursday, 17 July 2014

detect people in matlab

peopleDetector = vision.PeopleDetector;
I = imread('visionteam1.jpg');
[bboxes, scores] = step(peopleDetector, I);
shapeInserter = vision.ShapeInserter('BorderColor','Custom','CustomBorderColor',[255 255 0]);
 scoreInserter = vision.TextInserter('Text',' %f','Color', [0 80 255],'LocationSource','Input port','FontSize',16);
I = step(shapeInserter, I, int32(bboxes));
 I = step(scoreInserter, I, scores, int32(bboxes(:,1:2)));
figure, imshow(I)
title('Detected people and detection scores'); 

how to detect cars in an image taken from real time

foregroundDetector = vision.ForegroundDetector('NumGaussians', 3, ...
    'NumTrainingFrames', 50);

videoReader = vision.VideoFileReader('visiontraffic.avi');
for i = 1:150
    frame = step(videoReader); % read the next video frame
    foreground = step(foregroundDetector, frame);
end
figure; imshow(frame); title('Video Frame');
figure; imshow(foreground); title('Foreground');
se = strel('square', 3);
filteredForeground = imopen(foreground, se);
figure; imshow(filteredForeground); title('Clean Foreground');
blobAnalysis = vision.BlobAnalysis('BoundingBoxOutputPort', true, ...
    'AreaOutputPort', false, 'CentroidOutputPort', false, ...
    'MinimumBlobArea', 150);
bbox = step(blobAnalysis, filteredForeground);
result = insertShape(frame, 'Rectangle', bbox, 'Color', 'green');
numCars = size(bbox, 1);
result = insertText(result, [10 10], numCars, 'BoxOpacity', 1, ...
    'FontSize', 14);
figure; imshow(result); title('Detected Cars');

Wednesday, 16 July 2014

how to reduce image using Gaussian Pyramid Decomposition

The image reduction step involves lowpass filtering and downsampling the image pixels. The image expansion step involves upsampling the image pixels and lowpass filtering.


Example
gaussPyramid = vision.Pyramid('PyramidLevel', 2);
I = im2single(imread('cameraman.tif'));                 
J = step(gaussPyramid, I);
figure, imshow(I); title('Original Image');
figure, imshow(J); title('Reduced Image');

Monday, 14 July 2014

Useful System Objects for Video File I/O, Display, and Graphics

Useful System Objects for Video File I/O,  Display, and Graphics

File I/O
–VideoFileReader
–VideoFileWriter

Display
–VideoPlayer
–DeployableVideoPlayer

Graphics
–AlphaBlender
–MarkerInserter
–ShapeInserter
–TextInserter

Preprocessing
–ChromaResampler
–Deinterlacer
–DemosaicInterpolator

Statistics (running across video frames)
–Histogram
–Maximum
–Mean
–Median
–Minimum
–StandardDeviation
–Variance

how to count number of cells in image

a=imread('normal.jpg');
[m n p]=size(a);
 r=a(:,:,1);
 g=a(:,:,2);
 b=a(:,:,3);
for i=1:m
    for j=1:n
        for k=1:p
        if (r(i,j)>200)||(g(i,j)>160)||(b(i,j)>200)
      d(i,j)=0;
  else
      d(i,j)=a(i,j);
        end
    end
    end
end
imshow(d);
b=imcomplement(d);
figure,imshow(b);
[l num]=bwlabel(b,4);
figure,disp(l);
for i=1:num
    imshow(l==i);
   % pause(1);
 end



roipoly command in matlab

a=imread('data1.jpg');
[m n]=ginput(1);
bw=roipoly(a,m,n);
figure,imshow(bw);
[M N]=size(bw);
for i=1:m
 for j=1:n
    if bw(i,j)==1
       b(i,j)=a(i,j);
   else
      b(i,j)=0;
   end
end
end
figure,imshow(b,[]);title('output image');

Video to frame conversion

clc;
close all;

% Open an
filename = 'vipmen.avi';
mov =VideoReader(filename);
% sample avi file
 % Output folder

outputFolder = fullfile(cd, 'frames');
if ~exist(outputFolder, 'dir')
mkdir(outputFolder);
end

%getting no of frames

numberOfFrames = mov.NumberOfFrames;
numberOfFramesWritten = 0;
for frame = 1 : numberOfFrames
thisFrame = read(mov, frame);
outputBaseFileName = sprintf('%3.3d.png', frame);
outputFullFileName = fullfile(outputFolder, outputBaseFileName);
imwrite(thisFrame, outputFullFileName, 'png');
progressIndication = sprintf('Wrote frame %4d of %d.', frame,numberOfFrames);
disp(progressIndication);
numberOfFramesWritten = numberOfFramesWritten + 1;
end
progressIndication = sprintf('Wrote %d frames to folder "%s"',numberOfFramesWritten, outputFolder);
disp(progressIndication);

Sunday, 13 July 2014

To extract iris region from eye image

It is a program to detect the iris region in an image based on RGB values. The outermost region is eliminated and then the image is as shown


The program to convert the image into binary is as shown:

 a=imread('eye1.jpg');
[m n p]=size(a);
 r=a(:,:,1);
 g=a(:,:,2);
 b=a(:,:,3);
for i=1:m
    for j=1:n
        for k=1:p
        if (r(i,j)>125)||(g(i,j)>75)||(b(i,j)>42)
      d(i,j)=0;
  else
      d(i,j)=a(i,j);
        end
    end
    end
end
d1=uint(d);
figure,imshow(d1);
b=rgb2gray(a);
 figure,imshow(a);
figure,imshow(b);
%figure,imshow(c);
c=im2bw(b,0.3);
i6=medfilt2(c,[3 3]);
figure,imshow(c);
%imtool(i6);
figure,imshow(i6);

How to insert text onto images

The insertion of text can be done on an image by specifying color and location.The input image I, can be a 2-D grayscale image or a truecolor RGB image. The textInserter returns a text inserter object which draws text on image. The step function is used to draw the specified text onto input image

textColor    = [255, 255, 255];
textLocation = [100 315];
a=imread('data1.jpg');
textInserter = vision.TextInserter('Swarupa','Color', textColor, 'FontSize', 24, 'Location', textLocation);
J = step(textInserter, a);
imshow(J);

homomorphic filtering

Homomorphic Filtering 
Homomorphic filtering is a generalized technique for nonlinear image enhancement and correction. It 
simultaneously normalizes the brightness across an image and increases contrast. 

An image can be expressed as the product of illumination and reflectance: 
f( x, y ) = i( x, y )⋅r( x, y ) 

When the illumination is uniform, i( x,y ) is considered to be a constant and the image is considered to 
the reflectance of the object. However, the lighting condition is usually unequal. The illumination component 
tends to vary slowly and its frequency fastens on low part in the frequency domain; the reflectance tends to 
vary rapidly and its frequency is in high part. If two components can be operated separately, the illumination 
problem will be solved and the image will be enhanced. Hence, the log transform is used to equation (1): 
ln f( x, y )= lni( x, y )+lnr( x,y ) -(2) 
Then Fourier transform is used to equation (2), which makes the succedent operation is in frequency 
domain. 

Friday, 11 July 2014

morphology operations

clear all
close all
a=imread('cell1.bmp'); % reads the image
b=im2bw(a); %convert to binary
b1=bwareaopen(b,550); % remove connected components from a binary image
b2=imfill(b1,'holes'); % fill the region
%dialte
se=strel('disk',3,6); %structuring elt default:4
d1=imdilate(b2,se);
%imerode
se1=strel('disk',11);
d2=imerode(d1,se1);
%contour
p=bwmorph(d1,'remove');
perimeter=sum(sum(p));
figure(1);imshow(a);
figure(2);imshow(b1);
figure(3);imshow(d1);
figure(4);imshow(d2);
figure(5);imshow(p);
fprintf('perimeter of the shape');
disp(perimeter)

Wednesday, 9 July 2014

convert image to binary in vision toolbox

 a=imread('untitled1.jpg');
 hcsc = vision.ColorSpaceConverter;
hcsc.Conversion = 'RGB to intensity';
 i2 = step(hcsc, a);
imshow(i2);
 bin = step(hautoth,i2);
figure;imshow(bin);

How to insert a shape on an gray image

yellow = uint8([255 255 0]);
shapeInserter = vision.ShapeInserter('Shape','Circles','BorderColor','Custom','CustomBorderColor',yellow);
I = imread('cameraman.tif');
circles = int32([30 30 20; 80 80 25]);
RGB = repmat(I,[1,1,3]); % convert I to an RGB image
J = step(shapeInserter, RGB, circles);
imshow(J);

Monday, 7 July 2014

Detect Face and track using feature points

videoFileReader = vision.VideoFileReader('visionface.avi');
videoPlayer = vision.VideoPlayer('Position', [100, 100, 680, 520]);
objectFrame = step(videoFileReader);
objectRegion = [264, 122, 93, 93];
objectImage = insertShape(objectFrame, 'Rectangle', objectRegion,'Color', 'red');
figure; imshow(objectImage); title('Yellow box shows object region');
 points = detectMinEigenFeatures(rgb2gray(objectFrame), 'ROI', objectRegion);
 pointImage = insertMarker(objectFrame, points.Location, '+', 'Color', 'white');
figure, imshow(pointImage), title('Detected interest points');
 pointImage = insertMarker(objectFrame, points.Location, '+', 'Color', 'white');
figure, imshow(pointImage), title('Detected interest points');
tracker = vision.PointTracker('MaxBidirectionalError', 1);
 initialize(tracker, points.Location, objectFrame);
 while ~isDone(videoFileReader)
      frame = step(videoFileReader);
      [points, validity] = step(tracker, frame);
      out = insertMarker(frame, points(validity, :), '+');
      step(videoPlayer, out);
end
release(videoPlayer);
release(videoFileReader);

Sunday, 6 July 2014

Skin color detection using YCbCr plane

I=imread('filename');
I=double(I);
[hue,s,v]=rgb2hsv(I);
cb =  0.148* I(:,:,1) - 0.291* I(:,:,2) + 0.439 * I(:,:,3) + 128;
cr =  0.439 * I(:,:,1) - 0.368 * I(:,:,2) -0.071 * I(:,:,3) + 128;
[w h]=size(I(:,:,1));
for i=1:w
    for j=1:h            
        if  140<=cr(i,j) && cr(i,j)<=165 && 140<=cb(i,j) && cb(i,j)<=195 && 0.01<=hue(i,j) && hue(i,j)<=0.1     
            segment(i,j)=1;            
        else       
            segment(i,j)=0;    
        end    
    end
end
% imshow(segment);
im(:,:,1)=I(:,:,1).*segment;   
im(:,:,2)=I(:,:,2).*segment; 
im(:,:,3)=I(:,:,3).*segment; 
figure,imshow(uint8(im));

Friday, 4 July 2014

Segement cells in an image


%% Segmment cells in an image?
% A customer recently provided me with an image of cells that were roughly
% circular, but not very well defined, and often overlapping. He asked how
% we might use MATLAB and the <http://www.mathworks.com/products/image/ Image Processing Toolbox>
% to segment the cells in the presence of noise.
%
% Many of us know the Hough transform functionality in the Image Processing
% Toolbox, and the ability of that function to detect lines in an image.
% With some modifications, the Hough transform can be used to find other
% shapes as well. In this case, I wanted to find circles; a quick search
% for "detect circles" on the MATLAB Central File Exchange revealed
% <http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectId=1094843&objectType=author Tao Peng>'s
% implementation of the 
% <http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=9168&objectType=FILE Circular Hough Transform>.
% After an easy download, I was on my way to solving the problem. Tao's file is <http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectType=author&objectId=1093599 Brett>'s
% choice for this week's Pick of the Week.
%
% (Thanks to Cem Girit at Biopticon Corp. for permission to use his image!)

%% Read, Display image
togglefig Original
% Note: togglefig is a utility function I wrote for managing figure
% windows, and is available
% <http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=18220&objectType=file here>.
img = imread('NB1ln1.jpg');
imshow(img);

%% How would you segment this?
% Segmentation is often a very challenging task, particularly with noisy
% images like this one. One might try simple threshold or edge detection
% routines, or more sophisticated watershed approaches, for instance.
% Unfortunately, none of these approaches was giving me the results I
% wanted for this particular image. I was at a bit of a loss--until I found
% CircularHough_Grd. Tao suggests some filtering operations in his very
% helpful comments. For this demonstration, I'm going to see how the
% algorithm can perform with just some very minor pre-processing. 

%% Discarding color information
% Tao's function works directly on grayscale images. Rather than converting
% the color image to grayscale with the Image Processing Toolbox's RGB2GRAY
% function, I elected to  simply use the first (red) color plane, and to
% use adaptive histogram equalization:
togglefig('Red Plane, Adjusted')
red = img(:,:,2);
red = adapthisteq(red);
imshow(red)

%% Parameters for the segmentation
% Before I segment, I needed to know how big the cells were in the image;
% CircularHough_Grd takes as an input a range of radii to search for. Using
% the IMDISTLINE function in the Image Processing Toolbox's IMTOOL, I
% estimated that the radii of interest range from about 5 to 25 pixels. 
%
% You can play around with the other input arguments to modify the
% function's sensitivity to less-than-perfect circles, for instance, or to
% change the way it deals with concentric circles. This makes the program
% pretty flexible!

%% Now for the segmentation...
tic;
[accum, circen, cirrad] = ...
    CircularHough_Grd(red, [5 25],...
    20, 13, 1);
toc

%% ...and a bit of post-processing
% Note to Tao: occasionally, your algorithm returns zero-radii "hits":
any(cirrad <= 0)
%%
% This is easy to address (for instance, to keep the RECTANGLE command below
% from erroring), but might be an opportunity for enhancement.
if any(cirrad <= 0)
    inds = find(cirrad>0);
    cirrad = cirrad(inds);
    circen = circen(inds,:);
end

%% View the results
% Now let's see how well the algorithm performed: 
togglefig Results
imshow(img);
hold on;
plot(circen(:,1), circen(:,2), 'r+');
for ii = 1 : size(circen, 1)
    rectangle('Position',[circen(ii,1) - cirrad(ii), circen(ii,2) - cirrad(ii), 2*cirrad(ii), 2*cirrad(ii)],...
        'Curvature', [1,1], 'edgecolor', 'b', 'linewidth', 1.5);
end
hold off;
%%
% That's pretty remarkable, especially given the simplicity of my
% pre-processing. (Adaptive histogram equilization helped a lot; Tao's
% suggested filters improve the performance even more.)

%% Final comments
% The time it takes to run this algorithm varies markedly, depending on the
% user settings. In this case, it took my computer approximately 4
% seconds--but did a pretty amazing job of segmentating the image. Note how
% well it handled overlapping cells (circles), for instance:
togglefig Blowup
imshow(img)
xlims = [406 520];
ylims = [52 143];
set(gca,'xlim',xlims,'ylim',ylims)
inImageCircles = find(inpolygon(circen(:,1), circen(:,2), xlims([1 2 2 1]), ylims([1 1 2 2])));
for ii = 1 : numel(inImageCircles)
    rectangle('Position',...
        [circen(inImageCircles(ii),1) - cirrad(inImageCircles(ii)),...
        circen(inImageCircles(ii),2) - cirrad(inImageCircles(ii)),...
        2*cirrad(inImageCircles(ii)),...
        2*cirrad(inImageCircles(ii))],...
        'Curvature', [1,1], 'edgecolor', 'b', 'linewidth', 1.5);
end
%%
% If you do any image processing, you might recognize how Tao's function
% made a very challenging problem pretty manageable. If you're not an image
% processing expert, this might seem a bit arcane to you...but hopefully
% you'll find some value in it anyway. I'd love to hear your comments!

%%
% _Brett Shoelson_
% _Copyright 2008 The MathWorks, Inc._

Draw triangle and apply Morphology operations on it

 rows = 240;columns = 320;
grayImage = zeros(rows, columns, 'uint8');
xCoords = [100 200 300];
yCoords = [80 160 80];
mask = poly2mask(xCoords, yCoords, rows, columns);
grayImage(mask) = 150; % or whatever value you want.
imshow(grayImage);

>>  B=im2bw(grayImage);
>> figure,imshow(B);
>>  C=imfill(B,'holes');
>> figure,imshow(C);
>>  [Label,Total]=bwlabel(C,8);
>>  figure,imshow(C); 

Thursday, 3 July 2014

how to detect nose in matlab


vid = imaq.VideoDevice('winvideo', 1, 'YUY2_640x480','ROI',[1 1 640 480]);
videoFrame = step(vid);
bbox            = step(faceDetector, videoFrame);
noseDetector = vision.CascadeObjectDetector('Nose');
faceImage    = imcrop(videoFrame,bbox(1,:));
noseBBox     = step(noseDetector,faceImage);
noseBBox(1,1:2) = noseBBox(1,1:2) + bbox(1,1:2);
tracker = vision.HistogramBasedTracker;
initializeObject(tracker, hueChannel, noseBBox(1,:));

% Create a video player object for displaying video frames.
ROI = get(vid,'ROI');
videoSize = [ROI(3) ROI(4)];
videoPlayer  = vision.VideoPlayer('Position',[300 300 videoSize(1:2)+30]);

To detect the upper body part of an image

bodyDetector = vision.CascadeObjectDetector('UpperBody');
bodyDetector.MinSize = [25 25];
%bodyDetector.MaxSize=[90 90];
bodyDetector.ScaleFactor=1.02;
I2 = imread('untitled.jpg');
bboxBody = step(bodyDetector, I2);
disp(bboxBody);
IBody = insertObjectAnnotation(I2, 'rectangle',bboxBody,'Upper Body');
figure(1);
imshow(IBody);
title('Detected upper bodies');



 bodyDetector = vision.CascadeObjectDetector('UpperBody');
 bodyDetector.MinSize = [60 60];
 bodyDetector.MergeThreshold = 10;
 I2 = imread('untitled.jpg');
 bboxBody = step(bodyDetector, I2);
 IBody = insertObjectAnnotation(I2, 'rectangle',bboxBody,'Upper Body');
 figure, imshow(IBody), title('Detected upper bodies');




Wednesday, 2 July 2014

detect face and mouth using viola jones technique in computer vision tool box

a=imread('img.jpg');
MouthDetect = vision.CascadeObjectDetector('Mouth','MergeThreshold',16);
BB=step(MouthDetect,a);
figure,
imshow(I); hold on
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',4,'LineStyle','-','EdgeColor','r');
end
title('Mouth Detection');
hold off;

Detect Surf Features

This deals with matching surf features on an image. It has a function called  detectMSERFFeatues which finds out interest points in an image and mark them with a circles.


I = imread('cameraman.tif');
regions = detectMSERFeatures(I);
figure; imshow(I); hold on;
plot(regions, 'showPixelList', true, 'showEllipses', false);
figure; imshow(I); hold on;
plot(regions); % by default, plot displays ellipses and centroids

how to draw a square template

 T=100;
f=zeros(128,128);
f(32:96,32:96)=255;
[g1, t1]=edge(f, 'sobel', 'vertical');
imshow(g1);
t1

t1 =

   31.9372

>> sigma=1;
f=zeros(128,128);
f(32:96,32:96)=255;
[g3, t3]=edge(f, 'canny', [0.04 0.10], sigma);
figure,imshow(g3);
t3

t3 =

    0.0400    0.1000

Tuesday, 1 July 2014

how to draw a square on an object in matlab

For example type the following command in Matlab which supports Computer Vision toolbox

>> ex_vision_track_object

It opens a simulink and the design is visible and click on run in the window.
It displays a square even though the object is displaced 

detection of vehicle in motion

>> % Object for reading video file.
filename = 'viptraffic.avi';
hVidReader = vision.VideoFileReader(filename, 'ImageColorSpace', 'RGB',...
                              'VideoOutputDataType', 'single');
>> hOpticalFlow = vision.OpticalFlow( ...
    'OutputValue', 'Horizontal and vertical components in complex form', ...
    'ReferenceFrameDelay', 3);
>> hMean1 = vision.Mean;
hMean2 = vision.Mean('RunningMean', true);
>> hMedianFilt = vision.MedianFilter;
>> hclose = vision.MorphologicalClose('Neighborhood', strel('line',5,45));
>> hblob = vision.BlobAnalysis(...
    'CentroidOutputPort', false, 'AreaOutputPort', true, ...
    'BoundingBoxOutputPort', true, 'OutputDataType', 'double', ...
    'MinimumBlobArea', 250, 'MaximumBlobArea', 3600, 'MaximumCount', 80);
>> herode = vision.MorphologicalErode('Neighborhood', strel('square',2));
>> hshapeins1 = vision.ShapeInserter('BorderColor', 'Custom', ...
                                  'CustomBorderColor', [0 1 0]);
hshapeins2 = vision.ShapeInserter( 'Shape','Lines', ...
                                   'BorderColor', 'Custom', ...
                                   'CustomBorderColor', [255 255 0]);
>> htextins = vision.TextInserter('Text', '%4d', 'Location',  [1 1], ...
                               'Color', [1 1 1], 'FontSize', 12);
>> sz = get(0,'ScreenSize');
pos = [20 sz(4)-300 200 200];
hVideo1 = vision.VideoPlayer('Name','Original Video','Position',pos);
pos(1) = pos(1)+220; % move the next viewer to the right
hVideo2 = vision.VideoPlayer('Name','Motion Vector','Position',pos);
pos(1) = pos(1)+220;
hVideo3 = vision.VideoPlayer('Name','Thresholded Video','Position',pos);
pos(1) = pos(1)+220;
hVideo4 = vision.VideoPlayer('Name','Results','Position',pos);

% Initialize variables used in plotting motion vectors.
lineRow   =  22;
firstTime = true;
motionVecGain  = 20;
borderOffset   = 5;
decimFactorRow = 5;
decimFactorCol = 5;
>> while ~isDone(hVidReader)  % Stop when end of file is reached
    frame  = step(hVidReader);  % Read input video frame
    grayFrame = rgb2gray(frame);
    ofVectors = step(hOpticalFlow, grayFrame);   % Estimate optical flow

    % The optical flow vectors are stored as complex numbers. Compute their
    % magnitude squared which will later be used for thresholding.
    y1 = ofVectors .* conj(ofVectors);
    % Compute the velocity threshold from the matrix of complex velocities.
    vel_th = 0.5 * step(hMean2, step(hMean1, y1));

    % Threshold the image and then filter it to remove speckle noise.
    segmentedObjects = step(hMedianFilt, y1 >= vel_th);

    % Thin-out the parts of the road and fill holes in the blobs.
    segmentedObjects = step(hclose, step(herode, segmentedObjects));

    % Estimate the area and bounding box of the blobs.
    [area, bbox] = step(hblob, segmentedObjects);
    % Select boxes inside ROI (below white line).
    Idx = bbox(:,1) > lineRow;

    % Based on blob sizes, filter out objects which can not be cars.
    % When the ratio between the area of the blob and the area of the
    % bounding box is above 0.4 (40%), classify it as a car.
    ratio = zeros(length(Idx), 1);
    ratio(Idx) = single(area(Idx,1))./single(bbox(Idx,3).*bbox(Idx,4));
    ratiob = ratio > 0.4;
    count = int32(sum(ratiob));    % Number of cars
    bbox(~ratiob, :) = int32(-1);

    % Draw bounding boxes around the tracked cars.
    y2 = step(hshapeins1, frame, bbox);

    % Display the number of cars tracked and a white line showing the ROI.
    y2(22:23,:,:)   = 1;   % The white line.
    y2(1:15,1:30,:) = 0;   % Background for displaying count
    result = step(htextins, y2, count);

    % Generate coordinates for plotting motion vectors.
    if firstTime
      [R C] = size(ofVectors);            % Height and width in pixels
      RV = borderOffset:decimFactorRow:(R-borderOffset);
      CV = borderOffset:decimFactorCol:(C-borderOffset);
      [Y X] = meshgrid(CV,RV);
      firstTime = false;
    end

    % Calculate and draw the motion vectors.
    tmp = ofVectors(RV,CV) .* motionVecGain;
    lines = [Y(:), X(:), Y(:) + real(tmp(:)), X(:) + imag(tmp(:))];
    motionVectors = step(hshapeins2, frame, lines);

    % Display the results
    step(hVideo1, frame);            % Original video
    step(hVideo2, motionVectors);    % Video with motion vectors
    step(hVideo3, segmentedObjects); % Thresholded video
    step(hVideo4, result);           % Video with bounding boxes
end

release(hVidReader);
>>