0

I want to make filters like shown here

  • these are my target filters but can you please guide me how to go for them
  • how i can make filters like these?
  • which algorithms i need to follow? and which step i need to take as beginner?
  • Which is the better and easiest way to get the values of RGB and shades of filters .

copy of image from link above by spektre: filters example

  • the source image is the first after camera in the first line.
Spektre
  • 49,595
  • 11
  • 110
  • 380
AHF
  • 1,070
  • 2
  • 15
  • 47

1 Answers1

2

very hard to say from single non test-screen image.

  1. the black and white filter

    is easy just convert RGB to intensity i and then instead RGB write iii color. The simplest not precise conversion is

    i=(R+G+B)/3
    

    but better way is use of weights

    i=w0*R+w1*G+w2*B
    

    where w0+w1+w2=1 the values can be found by a little google search effort

  2. the rest

    some filters seem like over exponated colors or weighted colors like this:

    r=w0*r; if (r>255) r=255;
    g=w1*g; if (g>255) g=255;
    b=w2*b; if (b>255) b=255;
    

    write an app with 3 scrollbars for w0,w1,w2 in range <0-10> and redraw image with above formula. After little experimenting you should find w0,w1,w2 for most of the filters ... The rest can be mix of colors like this:

    r=w00*r+w01*g+w02*b; if (r>255) r=255;
    g=w10*r+w11*g+w12*b; if (g>255) g=255;
    b=w20*r+w21*g+w22*b; if (b>255) b=255;
    

    or:

    i=(r+g+b)/3
    r=w0*r+w3*i; if (r>255) r=255;
    g=w1*g+w3*i; if (g>255) g=255;
    b=w2*b+w3*i; if (b>255) b=255;
    

btw if you want the closest similarity you can:

  1. find test colors in input image

    like R shades, G shades , B shades , RG,RB,BG,RGB shades from 0-255. Then get colors from filtered image at the same position and draw depedency graphs for each shade draw R,G,B intensities.

    One axis is input image color intensity and the other one is R,G,B intensity of filtered color. Then you should see which formula is used directly and can also compute the weights from it. This is how over-exponation works for Red color

    red overexponate filter

  2. if the lines are not lines but curves

    then some kind of gamma correction is used so formulas use polynomial of higher order (power of 2,3,4...) mostly power of 2 suffice. In that case the weights can be also negative !!!

  3. some filters could use different color spaces

    for example transform RGB to HSV shift hue and convert back to RGB. That will shift colors a little.

Spektre
  • 49,595
  • 11
  • 110
  • 380
  • thank you for well explained answer , but the thing which i didn't get is the value of `w` and its role ? , i wrote app of 3 scroll bar whcih work with `RGB` but how i can put `w` with them to change their effects – AHF Apr 08 '14 at 16:49
  • You mean of weight as like we have a sepia filter like its value in a 2x2 matrix as suppose `0.7 , .03 ; 0.1 ,0.43 ; ` than multiply this matrix with the image mat ? – AHF Apr 08 '14 at 16:54
  • on change of any scrollbar get w weights from all scrollbars positions and redraw image. on redraw image you just loop through entire image get color (RGB) compute new color with one of the equations and write the color to output image at the same position (on the screen). Then just play a little with scrollbars until the output image match filter you want if it does remember used weights (so it is wise to write them on screen or hints). If you can not match some filter then try another equations – Spektre Apr 09 '14 at 06:20