Sign in to follow this  
TechnoRobbo

TR's Intense Filtration v 1.3 (Oct 09,2014

Recommended Posts

TechnoRobbo's Intense Filtration v 1.3

PDN 3.5 compatible

 

Based on a Topic conversation about Hue

It's not a hue adjustment it's a color filter and augmenter

 

v1.3 has an anti-clipping algorithm

 

 

Menu: Effects->Color

IntenseFiltration.PNG?raw=1

 

IntenseFiltration2.PNG?raw=1

 

Demo Video

 

CodeLab Source Code

Hidden Content:

 
// Submenu: Color
// Name: TR's Intense Filtration
// Title: TR's Intense Filtration- v1.3
// Author: TechnoRobbo
// URL: http://www.technorobbo.com
 
#region UICode
int Amount1 = 4700; // [0,5999] Hue
double Amount2 = .90; // [0,2] Gain
int Amount3 = 0; // [0,2000] Filter Intensity
byte Amount4 = 0; // [1] Fade To -|Base Image|B&W|Hue
#endregion
 
void Render(Surface dst, Surface src, Rectangle rect)
{
    // Delete any of these lines you don't need
    Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
    int CenterX = ((selection.Right - selection.Left) / 2)+selection.Left;
    int CenterY = ((selection.Bottom - selection.Top) / 2)+selection.Top;
    ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
    ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor;
    int BrushWidth = (int)EnvironmentParameters.BrushWidth;
    
        
    float[,] hues = {{1,0,0,1,1,0},
                    {1,1,0,0,1,0},    
                    {0,1,0,0,1,1},       
                    {0,1,1,0,0,1}, 
                    {0,0,1,1,0,1},
                    {1,0,1,1,0,0}};      
                    
    ColorBgra CP;
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        if (IsCancelRequested) return;
        for (int x = rect.Left; x < rect.Right; x++)
        {
 
            float coeff = (float)Amount2;
            float mix =1f - (float)Amount3 / 2000f ;
            
            //hues
            int hueIdx= Amount1/1000;
            float hueshift = (float)(Amount1 % 1000)/1000f;
            float r,g,b;
            r = hues[hueIdx ,3] * hueshift  + hues[hueIdx,0] - hues[hueIdx,0] * hueshift ;
            g = hues[hueIdx ,4 ] * hueshift  + hues[hueIdx ,1] - hues[hueIdx ,1] * hueshift ;
            b = hues[hueIdx ,5] * hueshift  + hues[hueIdx , 2] - hues[hueIdx , 2] * hueshift ;
 
            
            CP = src[x,y];
            
            //hue filtration * gain
            float tmpr = (float)CP.R * coeff * r; 
            tmpr = (tmpr > 255) ? 255: tmpr;
 
            float tmpg = (float)CP.G * coeff * g;  
            tmpg = (tmpg>255) ? 255: tmpg;
 
            float tmpb = (float)CP.B * coeff * b;     
            tmpb = (tmpb>255) ? 255: tmpb;
            
            //grayscale
            float gray = (float)(CP.R + CP.G + CP.B)/3f * coeff ;
            gray = (gray >255) ? 255: gray ;
            
 
            //base image * gain
            float thresh = (coeff>1) ? 128: 255 ;
            float himax = 255f * coeff - thresh ;
            
            float CPR = (float)CP.R * coeff;  
            CPR = (CPR >thresh ) ? (CPR - thresh ) * (255-thresh) /himax  + thresh : CPR;
 
            float CPG = (float)CP.G * coeff;  
            CPG = (CPG >thresh ) ? (CPG - thresh ) * (255-thresh)/himax  + thresh : CPG;
            
            float CPB = (float)CP.B * coeff;  
            CPB = (CPR >thresh ) ? (CPB - thresh ) * (255-thresh)/himax  + thresh : CPB;
            
            //gray * gain
            float graymix = gray/255f;
            float gr = r * graymix * 255 * coeff ;
            gr = (gr >255) ? 255: gr ;
            float gg = g * graymix * 255 * coeff ;
            gg = (gg >255) ? 255: gg ;
            float gb = b * graymix * 255 * coeff ;
            gb = (gb >255)? 255: gb ;
            
 
            if (Amount4==0)
            {
                tmpr = CPR * mix + tmpr - tmpr * mix;
                tmpg = CPG * mix + tmpg - tmpg * mix;
                tmpb = CPB * mix + tmpb - tmpb * mix;
                
            }else if (Amount4==1){
 
                tmpr = gray * mix + tmpr - tmpr * mix;
                tmpg = gray * mix + tmpg - tmpg * mix;
                tmpb = gray * mix + tmpb - tmpb * mix;
                
            }else if (Amount4==2){
 
                tmpr = gr * mix + tmpr - tmpr * mix;
                tmpg = gg * mix + tmpg - tmpg * mix;
                tmpb = gb * mix + tmpb - tmpb * mix;
            }
            CP .R = (byte)tmpr;
            CP .G = (byte)tmpg;
            CP .B = (byte)tmpb;
            CP.A = (byte)CP.A;
            dst[x,y] = CP;
        }
    }
}

 
 
 

TRsIntenseFilteration.zip

  • Upvote 4

Share this post


Link to post
Share on other sites

 

Posted Today, 07:56 PM

Nai, on 03 Oct 2014 - 7:48 PM, said:snapback.png

Where is the download link ?

 

The zip file is attached to the bottom of the first post.

It is now, Nai I was updating to version 1.1  a few minutes ago and you may have seen at at the wrong moment  when I hadn't uploaded the update.

Share this post


Link to post
Share on other sites

V 1.3 ready for download - eliminates color clipping artifact.

 

oh and a video demo

 

 

POST EDIT: V1.3 source code updated

Share this post


Link to post
Share on other sites

TechnoRobbo! I have not been here 2 weeks and so many new beautiful things. Great work, thank you so much.  6ij44rjk.gif

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this