Comparing Arrays or Image Histogram

Timin

Newcomer
Joined
Nov 15, 2009
Messages
1
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?
 
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.

Visual Basic:
        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
 
Back
Top