Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I hope this is posted under the right category. I am using VBE 2010 and I am trying to figure out a way to find the closest match from a given image to a collection of stored images or by comparing an array of the image with stored sets of arrays.

 

The images that I am comparing are all black and white and look like a histogram. Each row in the image starting from the left most pixel is white to a variable length and the remainder of the pixels in each row are black. I have also made this into an array where it counts the number of white pixels in each row.

 

The image or array that is being compared to the set does not match exactly to any of them, but it should be very close to at least one image... Also it does not have to match the entire length of the array or image, only about 60% as long as it is in order.

 

I am not sure where to start on this, I hope it makes sense?

 

Can someone help me figure out a way to compare the image or array to a set and find the closest match?

Posted

How about calculating a sum of the pixel count difference of each row between the image under inspection and a comparison histogram. Calculate the sum against every comparison image and choose the one with the smallest total difference.

 

        Dim IndexOfBestMatch As Integer = 0
       Dim DifferenceOfBestMatch As Integer = Integer.MaxValue
       For i As Integer = 0 To ComparisonImages.Count - 1
           Dim PixelDifference As Integer = 0
           For j As Integer = 0 To 255
               PixelDifference += Math.Abs( _
                                  ComparisonImages(i).Row(j).AmountOfWhitePixels _
                                  - ImageUnderInspection.Row(j)AmountOfWhitePixels)
           Next
           If PixelDifference < DifferenceOfBestMatch Then
               IndexOfBestMatch = i
               DifferenceOfBestMatch = PixelDifference
           End If
       Next

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...