Pattern recognition

InertiaM

Well-known member
Joined
Nov 3, 2007
Messages
663
Location
Kent, UK
Programming Experience
10+
I am writing an application to take camera images and detect patterns within the image. I know there are lots of third party products out there to do this, but before we spend money on it, I wanted to see how difficult it is :rolleyes:

So far I can take a coloured image, convert it to greyscale, then convert it to black and white (see attachment 1), then identify the individual shapes (see attachment 2).

Unfortunately, to process a 1024x768 image, it takes about 2.9 seconds which is too long for the final application.

If anyone has any tips they have discovered, I would love to hear them :)
 

Attachments

  • blobtest.JPG
    blobtest.JPG
    24.8 KB · Views: 43
  • blobtested.JPG
    blobtested.JPG
    45.4 KB · Views: 41
Unfortunately, to process a 1024x768 image, it takes about 2.9 seconds which is too long for the final application.

If anyone has any tips they have discovered, I would love to hear them :)

Getting faster - down to 0.46 seconds :D
 
I take it you already converting the bitmap to an array before processing using LockBits (or another method)? Assuming you are, try converting the data to a one-dimensional Integer array, not a two-dimensional or byte array. Try to confine all the operations in the processing loop on the data to integer, logical and shift operations. If you need to get at the colour bytes, do it with hex masks and shift operations. Try to avoid any references to external classes such as Math in the processing loop. It's surprising how much time you can save that way.

bye, VicJ
 
Thanks Vic. Yes, I'm already converting using LockBits, and then have managed to convert to a Boolean array for (hopefully) ultimate processing speed. At the moment, I am not using Math (or others) but I will certainly bear it in mind :)
 
Back
Top