Color channel mover - script

Upcoming mother of all image editors

Color channel mover - script

Postby JEL » Fri Aug 14, 2015 1:21 am

A piece of code to put in the reactor-script node.

It can be used to move the color-channels individually up or down. It's simple addition or subtraction to the pixel-value.

It can be used for balancing film-negatives (the orange mask), for whitebalancing ordinary images, or you can turn black'n'white images into colortones like sepia or blue.


Code: Select all
//Increase brightness
//##NAME:Andy's Gudermannian brightness code
//##DESCRIPTION:Andy's Gudermannian brightness code modified by JEL for the PR script-block.
//##INPUTS:1
//##VAR1:50
//##VAR1_NAME:Gain LUMA
//##VAR2:1
//##VAR2_NAME:Gain factor
//##VAR3:50
//##VAR3_NAME:Gain RED
//##VAR4:50
//##VAR4_NAME:Gain GREEN
//##VAR5:50
//##VAR5_NAME:Gain BLUE

void main()
{
   // get the image from input socket
   image img(INPUT);
     int width = img.width;
   int height = img.height;

   double gainCenter = -50 * VAR2;
   
   for (int y=0; y<height; y++)
   {
      for (int x=0; x<width; x++)
      {

         // one way to get color from pixel
         pixel color = img.Pixel(x,y);

         double rr;
         double gg;
         double bb;

//         double rr = color.r^2.2;
//         double gg = color.g^2.2;
//         double bb = color.b^2.2;

         rr = color.r + (gainCenter + (VAR1 * VAR2)) + (gainCenter + (VAR3 * VAR2));
         gg = color.g + (gainCenter + (VAR1 * VAR2)) + (gainCenter + (VAR4 * VAR2));
         bb = color.b + (gainCenter + (VAR1 * VAR2)) + (gainCenter + (VAR5 * VAR2));

//         rr = color.r^0.45;
//         gg = color.g^0.45;
//         bb = color.b^0.45;

         img.SetRGB(x, y,rr,gg,bb);

      }
   
   }

   
   // send the image to output
   img.SetOutput();
   
}
DAP (AOPs): http://jelstudio.dk/DAP/
PhotoReactor (flows, effects and scripts): http://jelstudio.dk/PhotoReactor/
JEL
 
Posts: 291
Joined: Fri Jan 06, 2012 9:35 pm

Re: Color channel mover - script

Postby smmsamm » Fri Aug 14, 2015 4:36 pm

You know that There are some dither methods for color reduction, do you have any idea for better algorithm that can generate with very low colors?
Thank you
smmsamm
 
Posts: 317
Joined: Tue Oct 26, 2010 7:58 pm

Re: Color channel mover - script

Postby JEL » Sat Aug 15, 2015 11:16 pm

This script doesn't do color-reduction. It moves, or slides if you will, the color-channel up or down (on the histogram it looks like it's sliding left or right)

The purpose is to align the RGB channels manually.

If you have a scanned film-negative, with the orange-mask still included, the RGB channels will be misaligned. This script can be used to align them.
Or you can intentionally misalign the channels on a normal image, to create special effects or to whitebalance the image in a specific place on the histogram.
DAP (AOPs): http://jelstudio.dk/DAP/
PhotoReactor (flows, effects and scripts): http://jelstudio.dk/PhotoReactor/
JEL
 
Posts: 291
Joined: Fri Jan 06, 2012 9:35 pm


Return to Photo Reactor

Who is online

Users browsing this forum: No registered users and 2 guests

cron