1

I'm working on a image manipulation. I have a problem I'm dealing with it, I didn't get any results. I need an algorithm to detect inverted colors.

As in the example photo below, I need to find and fix the inverted colors:

Currently I'm trying to find solution with using Java and C# .

I get the best closest result with this method. I convert the image to invert and two image compare with pixel-by-pixel. 70% success.

    public static Color getTrueColor(this Color t, Color m)
    {
        int[] a = { t.R, t.G, t.B };
        int[] b = { m.R, m.G, m.B };

        int x = (int)a.Average();
        int y = (int)b.Average();

        return  x < y ? m : t;

    }

Thanks in advance for every help and suggestion.

VC.One
  • 14,790
  • 4
  • 25
  • 57
Uysal
  • 79
  • 5
  • Hi, this is a rather broad and complex question. Do you have any restrictions? Environmental parameters? Some code to show? – Stefan Oct 02 '18 at 13:34
  • It is advised to edit your attempt at a solution into your post. – absoluteAquarian Oct 02 '18 at 13:34
  • @Stefan Unfortunately no – Uysal Oct 02 '18 at 13:36
  • Hmm... that's to bad..... Another thing; I don't think this image is fully inverted. – Stefan Oct 02 '18 at 13:38
  • @Stefan Yes, This image is partially inverted. That is main proplem. – Uysal Oct 02 '18 at 13:46
  • ... wow... that's a hard nut to crack.... it is possible, but it is gonna take a lot of effort. You could use some color distribution correlation, but that would fail very quickly if multiple "colors" are inverted. And, besides, you will need a valid test set. If you now nothing about the image (people in it, always correctly orrientated, always a sky in it etc.) it's going to be really difficult.... – Stefan Oct 02 '18 at 13:52
  • @Uysal Would you consider using artifical inteligence? – Slawomir Orlowski Oct 03 '18 at 11:02
  • Just curious: Where did these partially inverted image come from? – hkchengrex Oct 03 '18 at 13:21
  • @SlawomirOrlowski May be, but which AI can solve this problem? – Uysal Oct 04 '18 at 20:32
  • @hkchengrex It was obtained with a thermal image processing algorithm. – Uysal Oct 04 '18 at 20:38
  • 1
    I'd say to check for minimal threshold differences between inverted neighbouring pixels to make regions suspected of being inverted... but this is saved as jpeg. It'd be a lot less complicated if it weren't fuzzed up with fades and compression artifacts. I posted an algo for blob detection [here](https://stackoverflow.com/a/50282882/395685); if you have a non-blurred version, the threshold function to use on it should just be comparing pixels with their inverted neighbour. – Nyerguds Oct 09 '18 at 08:55

0 Answers0