0

When applying grey scale photographic convolution, should I set the input as the gamma compressed grey Scale or the inversed the gamma compressed grey Scale?

I usually see people convoluting the Red Green and Blue separately. I think somehow I am filtering out all the RED. I am not sure if it's because I am convoluting the wrong thing.

 private static Color createRGB(int rgbint) {
        System.out.println(rgbint);

        int red;
        int blue;
        int green;
        System.out.println(rgbint);

        if (rgbint <= 255) {
            red = green = blue = rgbint;
        } else {
            red = (rgbint & 0x00FF0000) >> 16;
            blue = rgbint & 0x000000FF;
            green = (rgbint & 0x0000FF00) >> 8;
        }
        red=correctColor(red);
        green=correctColor(green);
        blue=correctColor(blue);

        Color c = new Color(red, blue, green);
        return c;
    }

/**
*To filter out too large or negative numbers
*/
    private static int correctColor( int color){
        int c;
        if(color>255){
            c=255;
        }else if(color<0){
            c=0;
        }else{
            c=color;
        }
        return c;
    }

enter image description here

emily
  • 45
  • 1
  • 9
  • There are so too many cases and your question is too general. The answer depends on your goals. Inverse the gamma and convolving may be better when the result is passed as input to some algorithm. In case the result is used for human observer you may want to convolve in a space that is perceptually linear to humans (after gamma is more perceptually linear but not most accurate). Most of the programmers just ignore the gamma... Regarding "convoluting the Red Green and Blue separately": Since your image is grey scale, R=G=B for all pixels. You can take the red channel, and ignore the others. – Rotem Jun 28 '21 at 19:52
  • Thank you for your reply. I think I just getting numbers like 6052 or 5604 after I applied the convolution on the inversed gamma expression; which corresponding to 174a and 15e4 as RGBs; So my output image looks green. Do you know what's wrong with it? – emily Jun 29 '21 at 01:02
  • In the code, I use create RGB to convert the convoluted inversed gamma expression into the RGB colours. But the rgbint are produced as 6052 or 5604. I guess there might be something wrong with it. Or my convolution function is wrong? @Rotem – emily Jun 29 '21 at 01:08
  • Ok now I see it's just my color splitting function is wrong. I got my pic fixed. Thanks a lot!!! – emily Jun 29 '21 at 02:01

0 Answers0