2

I want to calculate the difference between two images and want to highlight them by showing a rectangle. These images can be webpages of same site twice time. i would like to refer this link "http://www.codeproject.com/Articles/10248/Motion-Detection-Algorithms" according to this I calculate the difference between two images but it return me a large number of blobs. but i want to combine the small blobs to make a bigger once then I will be able to draw a bigger rectangle instead of showing small rectangles. But I would not increase the Threshold which is one in my case.

// create filter
MoveTowards moveTowardsFilter = new MoveTowards( );
// move background towards current frame
moveTowardsFilter.OverlayImage = currentFrame;
Bitmap tmp = moveTowardsFilter.Apply( backgroundFrame );
// dispose old background
backgroundFrame.Dispose( );
backgroundFrame = tmp;

// create processing filters sequence
FiltersSequence processingFilter = new FiltersSequence( );
processingFilter.Add( new Difference( backgroundFrame ) );
processingFilter.Add( new Threshold( 15 ) );
processingFilter.Add( new Opening( ) );
processingFilter.Add( new Edges( ) );
// apply the filter
Bitmap tmp1 = processingFilter.Apply( currentFrame );

// extract red channel from the original image
IFilter extrachChannel = new ExtractChannel( RGB.R );
Bitmap redChannel = extrachChannel.Apply( image );
//  merge red channel with moving object borders
Merge mergeFilter = new Merge( );
mergeFilter.OverlayImage = tmp1;
Bitmap tmp2 = mergeFilter.Apply( redChannel );
// replace red channel in the original image
ReplaceChannel replaceChannel = new ReplaceChannel( RGB.R );
replaceChannel.ChannelImage = tmp2;
Bitmap tmp3 = replaceChannel.Apply( image );

and return me blob like this

BlobCounter blobCounter = new BlobCounter( );
...
// get object rectangles
blobCounter.ProcessImage( thresholdedImage );
Rectangle[] rects = BlobCounter.GetObjectRectangles( );

some how i want to reduce the number of blobs i want to combine the nearest small blobs to make a bigger one. Any suggestion regarding this ?

sm.abdullah
  • 1,777
  • 1
  • 17
  • 34
  • Note : if I increase the Threshold value then I am unable to identify the change in script written on webpage.So in my case i set it to 1. i my case the images are high definition there is no noise. and I want to track the even minor changes.. – sm.abdullah Jan 13 '14 at 11:36

1 Answers1

0

instead of combining blobs, you can get the min pixel and the max pixel from the image and then you can draw rectangle from min(c):max(c),min(r):max(r)

Abdul Rehman
  • 2,224
  • 25
  • 30