Head.SmackOnTable();

Contains Nuts.

Archive for the ‘R&D’ tag

LAB: Image Detection, Part 3

without comments

After writing some comparison code, we have the following output, thanks to log4net (I love log4net):

output-3

Source


Target

.

X:79 Y:156 W:17 H:23 X:73 Y:149 W:17 H:23

.

X:337 Y:176 W:27 H:50 X:331 Y:169 W:27 H:49

.

X:158 Y:249 W:32 H:31 X:152 Y:242 W:32 H:32

.

X:446 Y:286 W:28 H:32 X:440 Y:279 W:27 H:32

.

X:398 Y:339 W:18 H:26 X:392 Y:334 W:16 H:24

.

X:244 Y:349 W:47 H:52 X:238 Y:342 W:47 H:52

.

X:38 Y:374 W:16 H:15 X:31 Y:366 W:17 H:16

.

X:34 Y:388 W:16 H:17 X:148 Y:423 W:27 H:24

.

X:154 Y:430 W:27 H:24 X:459 Y:435 W:24 H:22

.

X:465 Y:442 W:25 H:22 X:119 Y:450 W:30 H:46

.

X:126 Y:457 W:29 H:46 X:221 Y:465 W:17 H:19

.

X:227 Y:472 W:17 H:19 X:250 Y:594 W:17 H:18

.

X:256 Y:601 W:17 H:18



Comparison
S[X: 79, Y: 156, Width: 17, Height: 23] matched to T[X: 73, Y: 149, Width: 17, Height: 23]
S[X: 158, Y: 249, Width: 32, Height: 31] matched to T[X: 152, Y: 242, Width: 32, Height: 32]
S[X: 398, Y: 339, Width: 18, Height: 26] matched to T[X: 392, Y: 334, Width: 16, Height: 24]
S[X: 38, Y: 374, Width: 16, Height: 15] matched to T[X: 31, Y: 366, Width: 17, Height: 16]
S[X: 154, Y: 430, Width: 27, Height: 24] matched to T[X: 392, Y: 334, Width: 16, Height: 24]
S[X: 126, Y: 457, Width: 29, Height: 46] matched to T[X: 31, Y: 366, Width: 17, Height: 16]
S[X: 256, Y: 601, Width: 17, Height: 18] matched to T[X: 31, Y: 366, Width: 17, Height: 16]
Non matched
S[X: 34, Y: 388, Width: 16, Height: 17]
S[X: 154, Y: 430, Width: 27, Height: 24]
S[X: 465, Y: 442, Width: 25, Height: 22]
S[X: 126, Y: 457, Width: 29, Height: 46]
S[X: 227, Y: 472, Width: 17, Height: 19]
S[X: 256, Y: 601, Width: 17, Height: 18]
T[X: 148, Y: 423, Width: 27, Height: 24]
T[X: 459, Y: 435, Width: 24, Height: 22]
T[X: 119, Y: 450, Width: 30, Height: 46]
T[X: 221, Y: 465, Width: 17, Height: 19]
T[X: 250, Y: 594, Width: 17, Height: 18]

I know its not perfect, I know its only matching about 50% of the blobs, but im working on it. I have a plan up my sleeve for this :)

Written by Monty

May 8th, 2009 at 1:19 am

Posted in .NET,R&D Lab

Tagged with , , ,

LAB: Image Detection, Part 2

without comments

Warning – this post will be heavy on images, so if you are on a low bandwidth connection, well sucks to be you then.

With a few minor improvements to the code, here we have the Source image:

image

Here is the target image’s blobs:

image

As you can see, it has found both blobs, and here is the raw output for the blob data:

image image

They are very similar, only a few pixels out! Now to compare the images somehow…

Written by Monty

May 4th, 2009 at 1:25 pm

Posted in .NET,R&D Lab

Tagged with ,

LAB: Image Detection, Part 1

without comments

Every now and then, I get a crazy idea, to try something rather hard in .net – maybe hard isnt the right word for it, but something that hasn’t really been attempted before, or if it has, nothing public about it. So the idea I have is for some form of image detection, to say that Image X is x % similar to Image Y. I prefer to use the terms Source and Target, but it doesn’t really matter.

The source and the target images are here. That’s a photo I took a few weeks ago, if you do decide to steal it, please put a message on there that points back to me ;) Anyway, the target image is 14×15 pixels smaller – that’s a whopping 210 pixels different! It shouldn’t be too hard to match up the two images, or should it?

Histograms

My first attempt was with Histograms. I grabbed some open source (unsafe!) code that generates an array of int[] and lists the histogram values, so I shoved both images through that, and got it to output the Source’s histogram value, the Target’s histogram value, the difference between them both, and the percentage of how similar it is, like so: (The first number is the key# of the int in the array, just because)

image

Right at the bottom, I had an average of all the percentages, to see how “similar” the image is. I was expecting the percentage to be fairly high, since there is only a few hundred pixels difference, and I didn’t change any of the levels or colours when I cut the images out of each other, but it told me there was a 87.7% similarity! That was very shockingly low. If you see something wrong with my maths from the code below, please let me know:

public HistogramCompareResults(int key, int source, int target)

{

this.key = key;

this.source = source;

this.target = target;

difference = source – target;

if (difference < 0)

{

difference = difference*-1;

}

if (source != 0 && target !=0)

{

if (source > target)

{

percentage = (double)target / (double)source;

}

else

{

percentage = (double)source / (double)target;

}

percentage = percentage*100;

}

}

Image Processing

My next port of call was basically image processing, like what I did with my ANPR project that I created – basically filtering stuff out and building a “thumbprint” of the image, that hopefully will withstand being resized and stuff like that. Using image filters, flattening images and looking for large “blobs” of images, sofar I have come up with this:

image

That is the current “thumbprint” for the red channel, on the source image.

Written by Monty

May 4th, 2009 at 12:30 am

Posted in .NET,Code Snippet,R&D Lab

Tagged with , ,

Pet Project – Personal ANPR

with one comment

Well iv got a pet project, its creaing my own Automatic Numberplate Recognition System. Why? Because I think it will be very technically challenging to do it in the .net framework.

This is what I have sofar, from an image like this:

it picks up the following:

Not bad, if i say so myself. It needs hell of alot of work though.

Written by Monty

September 16th, 2008 at 7:02 pm

Posted in .NET,Misc,R&D Lab

Tagged with , , ,