Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Matlab - Find difference between images. Motion detection

Status
Not open for further replies.

fredted40x

Newbie level 3
Joined
Mar 29, 2011
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,321
Hello.

I would like to create a motion detection system using jpg images that have been taken from a video. The aim of the system is to compare a image of a blank alleyway with the frames from the video. A warning is then given i the difference in colour is greater than a threshold.

The images come from a camera located fairly high up looking down on a alleyway. I have read about block based matching technique from this thread and it seems like something that could help.

One extra feature i would like to add is to be able to change the threshold depending on which half the difference is in. As the camera is looking down on the alleyway the top half of the image is at a greater distance to the bottom half of the photo. So therefore i would like to set a smaller threshold to the upper area and a greater threshold for the bottom half.

Can anyone point me in the right direction please. I have very minimal experience.

Thanks
 

Just to check :

You want perform motion detection of an pre-existing object or is perform an object detection of a new object in frame ?
The objective is detect intruders ?

+++
 
Thanks for your reply.

I have a reference image which is the alleyway when it was empty.

I would then like to compare another image to the reference image to see if there is a difference, e.g someone has appeared in the second image that wasnt there in the reference image. At the moment im aiming to just compare two images and then i can add the function to search through the other images at a later stage.

yes, the objective is to detect intruders and give a warning when a human has walked down the alley but not a cat for example because the difference is lower than the threshold.

So far i've read the image and showed the difference in another image.

Code:
clear
a=imread('left_bay.jpg');
b=imread('empty.jpg');
Inew=rgb2gray(a);
Iold=rgb2gray(b);

Idiff=Inew-Iold;

diff_im = imabsdiff(Inew(:,:),Iold(:,:));
diff_imbw = im2bw(diff_im,0.15);
bwarea = bwareaopen(diff_imbw,60);
imshow(bwarea)


p.s. I believe in the other motion detection thread they also outline the blocks where motion had been detected. Is this a easy thing to do?
 
Last edited:

fred

Need more details on target application to determine wich techique must be adopted.
For instance, if there exists possiblity to vary luminance along time ( day x night ) the complexity increases.

The code above seems don´t consider that possibility.
Pre-processing with high-pass filter could nomalize input array.

Yes; It is possible to differentiate between large and small objects like cat and human
There are a wide algorithms - recursive and nonrecursive - that brings some advantages and disvantages.

Take a look on MoG / CB-Codebook / Kernel Density estimate algorithms that are mos trusteable for that application.

+++
 
Its for a project im doing. What i might do is change the use to a office appication to monitor a office. I could then say that during the day the office is lit and then during the evening the room is dimly lit. This would eliminate the outside light differences and would only require the reference file to be changed.

Just playing around i've managed to pick up how many white pixels there are in a image that shows white where there is a difference between the images and black where there is no difference.

Is there a way to just read half an image in this line instead of the entire image?.
Code:
imabsdiff(Inew(:,:),Iold(:,:));
 
Last edited:

...Is there a way to just read half an image in this line instead of the entire image?...
Half in both dimensions reduce image to 1/4 of original size.
So why don´t you interleaves each inputed line and row at vectors a and b ?
I may be worg but beleve that exists that funcion im MATLAB.

+++
 

sorry, should have said half vertically. So basically chop it into two.

I've tried
Code:
imabsdiff(Inew(1000,:),Iold(1000,:));

But i just get a line. If i try

Code:
imabsdiff(Inew(1000,2000),Iold(1000,2000));

I get a dot. These are the x and y figure arnt they?

The only other thing i cant try is to divide it when i read the image. Not sure if this is possible though.
 

fred

Sorry but I´m not expertize in MATLAB.

When I worked with MATLAB was just to simulate an image recognition process to embeed further. I did´t work too much time with that language.

But data entry was performed by [X,MAP] = imread('file.bmp') funcion, wich associates image to a linear vector. This way was easy to work for me. However I don´t know much other commands in that language.

The sugestion I posted before was considering that approach.

+++
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top