2

I am doing an image comparer for learning purposes.

I have done almost everything already and I am now improving it. To check for similarity, I have 2 jagged-multidimensional arrays (byte[][,]) where I access each element of each array using a triple for loop and store their remainder, like this:

for (int dimension = 0; dimension < 8; dimension++)
{
    Parallel.For(0, 16, mycolumn =>
    {
        Parallel.For(0, 16, myrow =>
        {
            Diffs[dimension][mycolumn, myrow] =
                (byte)Math.Abs(Image1Bytes[dimension][mycolumn, myrow]
                - Image2Bytes[dimension][mycolumn, myrow]);
        });
    });
}

Now, I would like to check how much each dimension is equal to another in the other collection.

How could I compare the entire arrays in each array (like array1[i][,] == array2[j][,])?

I think there are better ways to do these operations, but I have managed to do them pretty quickly.

leppie
  • 115,091
  • 17
  • 196
  • 297
Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120

2 Answers2

0

Here is an older thread on comparing two images that would be simple for you to adapt to your needs.

Compare Bitmaps

Community
  • 1
  • 1
John Taylor
  • 446
  • 3
  • 8
0

Since Array supports the IStructuralEquatable interface, you can use structural comparison:

using System.Collections;

. . .

var areEqual = StructuralComparisons.StructuralEqualityComparer.Equals(array1[i], array2[j]);
Mark Shevchenko
  • 7,937
  • 1
  • 25
  • 29