# Classification of very similar images

I have two groups of images, each one with 1000 samples.

The speckle pattern, in this context, is the same as a random pattern or "white noise" image. So these images are fundamentally different.

In group one, each figure is generated by considering a random function that returns something similar to a speckle pattern (see fig. 1). In group two we follow the same procedure as group 1, but we plot a small point above that can be positioned anywhere and with any color (see fig. 2).

I want to classify both groups and I already tried to do it with simple neural networks, but I have been unsuccessful.

What is the best technique for this kind of problems?

Fig. 1:

Fig. 2:

• Isn't it a challenge of a feature selection? If you calculate for each pixel the number of adjacent pixels with the same color and takes the maximum value as a feature of the image, you'll get a small number for teh group 1 and higher number for the group 2. – Marmite Bomber Mar 1 '18 at 17:30
• Do you want the answer to specifically uses neural networks? Or are other approaches acceptable (such as the rule based approaches mentioned)? If you are open to any technique, that could change people's answers, rather than if you're only interested in neural network techniques. You also mention "any color for the small point in group 2, this includes all possible gray values, is that correct? – prijatelj Mar 1 '18 at 22:54
• The final goal of this work is to be used with photos of metalic surfaces taken with a color camera. So the ideal is to be used with CNN. – nunodsousa Mar 2 '18 at 10:34

Have you tried rule-based approaches?

Based on your example, I can think of two ways:

• For each picture, get a list of all RGB values it contains. The first contains only grays (which have RGB values (x, x, x)), the second one contains color (so some pixel with RGB value (x, y, z), where $x \neq y$ or $y \neq z$). Or - if that is faster - convert all pictures to gray scale and check if the converted picture is identical to the original.
• Scan the image for areas (larger than one pixel) with identical colors. If your dots are large enough and the background noise is uncorrelated for neighboring pixels, it is very likely that these areas are the dots you are looking for.
• I would add, this should have 99.998% accuracy (assuming my maths is correct). 255 possible pure greys, out of 255^3 possible colours. – Roland Heath Mar 1 '18 at 23:36

You're going to have to do some experimenting to figure out what is 'best', but I would recommend starting with a convolutional neural network.

Since you're only detecting a very small difference, though, the pixel values themselves should give you a good indication of where the colour is, and whether there is colour at all. I'm a bit surprised that a simpler architecture hasn't given you any luck.

• I'm not sure CNN is the right approach here. First of all, with only 1000 samples to learn from, your classify is likely to be weak. Secondly, since there are no features to extract from the image per se, you can easily achieve this using a rules based approach as others have answered below. – Sledge Mar 1 '18 at 20:28
• Fair point @Sledge, I missed the '1000 examples' part in the question. In my defence, CNNs are the de facto starting method for image classification. – StatsSorceress Mar 2 '18 at 1:12

Based on the given Example

If they are literally the same everywhere except in a small region, just subtract image 1 from image 2 to find the differences...

And then we can check the positive and negative values where they are differing by a considerable margin to classify them

This Will (Probably) Work...

• No, the speckle pattern, in this context, is the same as a random pattern or "white noise" image. So these images are fundamentally different. – nunodsousa Mar 1 '18 at 17:27

I found the answer in the paper linked above. The authors use a CNN to solve the problem. I will post the code.