[Edit 2009.03.26 : Modif du filtre "SpacialSoften" : ajout d'un facteur de lissage...]
[Edit 2008.08.11 : Nouveau filtre : "Desinterlace CodeName : LeeperryBlending ... ]
[Edit 2008.01.07 : "Undot" devient "SpacialSoften" ... un vrai "Undot" arrivera un jour... ]
[Edit 2008.01.07 : correction syntaxe Sharpen_3x3 & 5x5 ]
[Edit 2008.01.21 : Modif Undot ... Seuil à l'envers ... ]
[Edit 2006.04.03 : Copier-coller des fitres du post ... ]
LeeperryBlending ( Seb.26 ) : Desentrelace à la bourrin !
- Code: Tout sélectionner
// +deinterlace (blend).txt=ps_3_0
sampler s0 : register(s0);
float4 p0 : register(c0);
float4 p1 : register(c1);
#define width (p0[0])
#define height (p0[1])
#define counter (p0[2])
#define clock (p0[3])
#define one_over_width (p1[0])
#define one_over_height (p1[1])
#define PI acos(-1)
float4 main(float2 tex : TEXCOORD0) : COLOR
{
float2 h = float2(0, one_over_height);
float4 c1 = tex2D(s0, tex-h);
float4 c2 = tex2D(s0, tex+h);
float4 c0 = (c1+c2)/2;
return c0;
}
EdgeSharpen v1.1 ( Seb.26 ) : Detection des contours, puis sharpen de ces derniers
- Code: Tout sélectionner
sampler s0 : register(s0);
float4 p0 : register(c0);
float4 p1 : register(c1);
#define width (p0[0])
#define height (p0[1])
#define counter (p0[2])
#define clock (p0[3])
#define one_over_width (p1[0])
#define one_over_height (p1[1])
#define PI acos(-1)
#define Edge_width 2.0
#define Edge_threshold 0.2
#define Sharpen_width 1.0
#define Sharpen_val0 2.0
#define Sharpen_val1 0.125
float4 main(float2 tex : TEXCOORD0) : COLOR
{
// Read current pixel color
float4 Res = tex2D( s0, tex );
// Edge detection width vector
float dx = Edge_width / height;
float dy = Edge_width / width;
// Read corners color
float4 c2 = tex2D(s0, tex + float2( 0,-dy) );
float4 c3 = tex2D(s0, tex + float2(-dx,0) );
float4 c4 = tex2D(s0, tex + float2( dx,0) );
float4 c5 = tex2D(s0, tex + float2( 0, dy) );
// Compute vector lenght
float4 c0 = Res*4 - c2 - c3 - c4 - c5;
// If vector lenght > Edge_threshold : sharp this pixel
if( length(c0) > Edge_threshold )
{
// Compute sharpen's width vector
dx = Sharpen_width / width;
dy = Sharpen_width / height;
// Read 8 around pixels color
float4 c1 = tex2D(s0, tex + float2(-dx,-dy)) ;
c2 = tex2D(s0, tex + float2(0,-dy)) ;
c3 = tex2D(s0, tex + float2(-dx,0)) ;
c4 = tex2D(s0, tex + float2(dx,0));
c5 = tex2D(s0, tex + float2(0,dy)) ;
float4 c6 = tex2D(s0, tex + float2(dx,dy)) ;
float4 c7 = tex2D(s0, tex + float2(-dx,+dy));
float4 c8 = tex2D(s0, tex + float2(+dx,-dy)) ;
float4 c9 =Res * Sharpen_val0;
Res = c9 - (c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 ) * Sharpen_val1 ;
// Remove '//' from next line to see detected Edges in red ...
//Res = float4( 1.0, 0.0, 0.0, 0.0 );
}
return Res;
}
DisplayLessThan16 v1.1 ( Seb.26 ) : Affiche en vert fluo les pixels dont une des valeurs ( R G B ) est < 16 ...
- Code: Tout sélectionner
sampler s0 : register(s0);
float4 p0 : register(c0);
float4 p1 : register(c1);
#define width (p0[0])
#define height (p0[1])
#define counter (p0[2])
#define clock (p0[3])
#define one_over_width (p1[0])
#define one_over_height (p1[1])
#define PI acos(-1)
#define Value_16 (16.0/255.0)
float4 main(float2 tex : TEXCOORD0) : COLOR
{
float4 c0 = tex2D(s0, tex);
if( c0[0]<Value_16 )
c0 = float4( 0, 1, 0, 0 );
else if( c0[1]<Value_16 )
c0 = float4( 0, 1, 0, 0 );
else if( c0[2]<Value_16 )
c0 = float4( 0, 1, 0, 0 );
return c0;
}
Remap_16_235 ( Seb.26 ) : Remap les valeur de 16->235 vers 0->255 ( Low Quality )
NB: Ce script est "Low Quality" = incorrect/buggé ...
- Code: Tout sélectionner
sampler s0 : register(s0);
float4 p0 : register(c0);
float4 p1 : register(c1);
#define width (p0[0])
#define height (p0[1])
#define counter (p0[2])
#define clock (p0[3])
#define one_over_width (p1[0])
#define one_over_height (p1[1])
#define PI acos(-1)
#define Const_1 (16.0/255.0)
#define Const_2 (255.0/219.0)
float4 main(float2 tex : TEXCOORD0) : COLOR
{
return( ( tex2D( s0, tex ) - Const_1 ) * Const_2 );
}
EdgeSharpen v1.1 ( jim.ro ) : Detection des contours ( Prewitt ), puis sharpen de ces derniers
- Code: Tout sélectionner
sampler s0 : register(s0);
float4 p0 : register(c0);
float4 p1 : register(c1);
#define width (p0[0])
#define height (p0[1])
#define counter (p0[2])
#define clock (p0[3])
#define one_over_width (p1[0])
#define one_over_height (p1[1])
#define PI acos(-1)
#define NbPixel 1
#define Edge_threshold 0.2
#define Sharpen_val0 2.0
#define Sharpen_val1 0.125
float4 main(float2 tex : TEXCOORD0) : COLOR
{
// taille de NbPixel pixels
float dx = NbPixel/width;
float dy = NbPixel/height;
float4 Res = 0;
// Détection de contour par Prewitt
// récuppération des 9 points
// [ 1, 2, 3 ]
// [ 4, 0, 5 ]
// [ 6, 7, 8 ]
float4 c0 = tex2D(s0, tex);
float4 c1 = tex2D(s0, tex + float2(-dx,-dy));
float4 c2 = tex2D(s0, tex + float2(0,-dy));
float4 c3 = tex2D(s0, tex + float2(dx,-dy));
float4 c4 = tex2D(s0, tex + float2(-dx,0));
float4 c5 = tex2D(s0, tex + float2(dx,0));
float4 c6 = tex2D(s0, tex + float2(-dx,dy));
float4 c7 = tex2D(s0, tex + float2(0,dy));
float4 c8 = tex2D(s0, tex + float2(dx,dy));
// Calcul des 3 vecteurs dérivé (hor,vert, diag1, diag2)
float4 delta1 = (c6+c4+c1-c3-c5-c8);
float4 delta2 = (c4+c1+c2-c5-c8-c7);
float4 delta3 = (c1+c2+c3-c8-c7-c6);
float4 delta4 = (c2+c3+c5-c7-c6-c4);
// calcul du Prewitt
float value = length(abs(delta1) + abs(delta2) + abs(delta3) + abs(delta4))/6;
// Si c'est un contour (vector lenght > Edge_threshold) => filtre de sharpen
if(value > Edge_threshold )
{
Res = c0 * Sharpen_val0 - (c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 ) * Sharpen_val1 ;
// Pour voir les contour en rouge ...
//Res = float4( 1.0, 0.0, 0.0, 0.0 );
return Res;
}
else
return c0;
}
SharpenFlou ( jim.ro ) : Soustraction d'une image floutée
- Code: Tout sélectionner
sampler s0 : register(s0);
float4 p0 : register(c0);
float4 p1 : register(c1);
#define width (p0[0])
#define height (p0[1])
#define counter (p0[2])
#define clock (p0[3])
#define one_over_width (p1[0])
#define one_over_height (p1[1])
#define PI acos(-1)
float4 main( float2 tex : TEXCOORD0 ) : COLOR
{
float dx = one_over_width;
float dy = one_over_height;
// récuppération de la matrice de 9 points
// [ 1, 2 , 3 ]
// [ 4,ori, 5 ]
// [ 6, 7 , 8 ]
float4 ori = tex2D(s0, tex);
float4 c1 = tex2D(s0, tex + float2(-dx,-dy));
float4 c2 = tex2D(s0, tex + float2(0,-dy));
float4 c3 = tex2D(s0, tex + float2(dx,-dy));
float4 c4 = tex2D(s0, tex + float2(-dx,0));
float4 c5 = tex2D(s0, tex + float2(dx,0));
float4 c6 = tex2D(s0, tex + float2(-dx,dy));
float4 c7 = tex2D(s0, tex + float2(0,dy));
float4 c8 = tex2D(s0, tex + float2(dx,dy));
// calcul image floue (filtre gaussien)
float multipliers[9]=
{1,2,1,
2,4,2,
1,2,1};
float4 total=0;
total += c1 * multipliers[0];
total += c2 * multipliers[1];
total += c3 * multipliers[2];
total += c4 * multipliers[3];
total += ori * multipliers[4];
total += c5 * multipliers[5];
total += c6 * multipliers[6];
total += c7 * multipliers[7];
total += c8 * multipliers[8];
// 1/(1+2+1+2+4+2+1+2+1) = 1/ 16 = .0625
total *= 0.0625f;
// soustraction de l'image flou à l'image originale
total = 2*ori - total;
//return ori;
return total;
}
Sharpen_3x3 ( Seb.26 ) : Autre matrice ...
- Code: Tout sélectionner
sampler s0 : register(s0);
float4 p0 : register(c0);
float4 p1 : register(c1);
#define width (p0[0])
#define height (p0[1])
#define counter (p0[2])
#define clock (p0[3])
#define one_over_width (p1[0])
#define one_over_height (p1[1])
#define PI acos(-1)
#define x 1.0
float4 main(float2 tex : TEXCOORD0) : COLOR
{
float dx =(one_over_width*x);
float dy =(one_over_height*x);
float4 c9 = tex2D(s0, tex) * 2.0;
float4 c1 = tex2D( s0, tex + float2( -dx , -dy ) ) * 0.1;
c1 += tex2D( s0, tex + float2( 0 , -dy ) ) * 0.15;
c1 += tex2D( s0, tex + float2( dx , -dy ) ) * 0.1;
c1 += tex2D( s0, tex + float2( -dx , 0 ) ) * 0.15;
c1 += tex2D( s0, tex + float2( dx , 0 ) ) * 0.15;
c1 += tex2D( s0, tex + float2( -dx , dy ) ) * 0.1;
c1 += tex2D( s0, tex + float2( 0 , dy ) ) * 0.15;
c1 += tex2D( s0, tex + float2( dx , dy ) ) * 0.1;
float4 c0 = c9 -c1 ;
return c0;
}
Sharpen_5x5 ( Seb.26 ) : Sharpen 5x5 ...
- Code: Tout sélectionner
sampler s0 : register(s0);
float4 p0 : register(c0);
float4 p1 : register(c1);
#define width (p0[0])
#define height (p0[1])
#define counter (p0[2])
#define clock (p0[3])
#define one_over_width (p1[0])
#define one_over_height (p1[1])
#define PI acos(-1)
#define x 1.0
float4 main(float2 tex : TEXCOORD0) : COLOR
{
float dx = (one_over_width*x);
float dy = (one_over_height*x);
float dx2 = one_over_width * 2;
float dy2 = one_over_height * 2;
float4 coef = float4( 0.025, 0.05, 0.1, 2.0 );
float4 c0 = tex2D( s0, tex ) * coef[3];
float4 c1 = tex2D( s0, tex + float2( -dx2 , -dy2 ) ) * coef[0];
c1 += tex2D( s0, tex + float2( -dx , -dy2 ) ) * coef[0];
c1 += tex2D( s0, tex + float2( 0 , -dy2 ) ) * coef[0];
c1 += tex2D( s0, tex + float2( dx , -dy2 ) ) * coef[0];
c1 += tex2D( s0, tex + float2( dx2 , -dy2 ) ) * coef[0];
c1 += tex2D( s0, tex + float2( -dx2 , -dy ) ) * coef[0];
c1 += tex2D( s0, tex + float2( -dx , -dy ) ) * coef[1] ;
c1 += tex2D( s0, tex + float2( 0 , -dy ) ) * coef[2] ;
c1 += tex2D( s0, tex + float2( dx , -dy ) ) * coef[1] ;
c1 += tex2D( s0, tex + float2( dx2 , -dy ) ) * coef[0];
c1 += tex2D( s0, tex + float2( -dx2 , 0 ) ) * coef[0];
c1 += tex2D( s0, tex + float2( -dx , 0 ) ) * coef[2] ;
c1 += tex2D( s0, tex + float2( dx , 0 ) ) * coef[2] ;
c1 += tex2D( s0, tex + float2( dx2 , 0 ) ) * coef[0];
c1 += tex2D( s0, tex + float2( -dx2 , dy ) ) * coef[0];
c1 += tex2D( s0, tex + float2( -dx , dy ) ) * coef[1] ;
c1 += tex2D( s0, tex + float2( 0 , dy ) ) * coef[2] ;
c1 += tex2D( s0, tex + float2( dx , dy ) ) * coef[1] ;
c1 += tex2D( s0, tex + float2( dx2 , dy ) ) * coef[0];
c1 += tex2D( s0, tex + float2( -dx2 , dy2 ) ) * coef[0];
c1 += tex2D( s0, tex + float2( -dx , dy2 ) ) * coef[0];
c1 += tex2D( s0, tex + float2( 0 , dy2 ) ) * coef[0];
c1 += tex2D( s0, tex + float2( dx , dy2 ) ) * coef[0];
c1 += tex2D( s0, tex + float2( dx2 , dy2 ) ) * coef[0];
c0 -= c1;
return c0;
}
SpacialSoften ( Seb.26 ) ( PS3.0 ) : Lisse avec les voisins dont le delta luma est faible ...
- Code: Tout sélectionner
sampler s0 : register(s0);
float4 p0 : register(c0);
float4 p1 : register(c1);
#define width (p0[0])
#define height (p0[1])
#define counter (p0[2])
#define clock (p0[3])
#define one_over_width (p1[0])
#define one_over_height (p1[1])
#define PI acos(-1)
#define dx one_over_width
#define dy one_over_height
#define val0 0.3
#define val1 0.6
float4 main(float2 tex : TEXCOORD0) : COLOR
{
float4 current = tex2D(s0, tex);
float4 Total = current ;
float n = 1;
float4 c0 = tex2D( s0, tex + float2( -dx , -dy ) );
if( length( current - c0 ) < val0 )
{
Total += c0*val1;
n += val1 ;
}
c0 = tex2D( s0, tex + float2( 0 , -dy ) );
if( length( current - c0 ) < val0 )
{
Total += c0*val1;
n += val1 ;
}
c0 = tex2D( s0, tex + float2( dx , -dy ) );
if( length( current - c0 ) < val0 )
{
Total += c0*val1;
n += val1 ;
}
c0 = tex2D( s0, tex + float2( -dx , 0 ) );
if( length( current - c0 ) < val0 )
{
Total += c0*val1;
n += val1 ;
}
c0 = tex2D( s0, tex + float2( dx , 0 ) );
if( length( current - c0 ) < val0 )
{
Total += c0*val1;
n += val1 ;
}
c0 = tex2D( s0, tex + float2( -dx , dy ) );
if( length( current - c0 ) < val0 )
{
Total += c0*val1;
n += val1 ;
}
c0 = tex2D( s0, tex + float2( 0 , dy ) );
if( length( current - c0 ) < val0 )
{
Total += c0*val1;
n += val1 ;
}
c0 = tex2D( s0, tex + float2( dx , dy ) );
if( length( current - c0 ) < val0 )
{
Total += c0*val1;
n += val1 ;
}
return( Total / n );
}
SharpenComplex ( jim.ro ) : Un autre sharpen ( accentuation des détails par soustraction d'une image flou puis accentuation des contours aprés leurs détections)
- Code: Tout sélectionner
sampler s0 : register(s0);
float4 p0 : register(c0);
float4 p1 : register(c1);
#define width (p0[0])
#define height (p0[1])
#define dx (p1[0])
#define dy (p1[1])
float4 main( float2 tex : TEXCOORD0 ) : COLOR
{
// definition des pixels : original, flouté, corigé, final
float4 ori;
float4 flou;
float4 cori;
float4 final;
////////////////////////////////////////////////////
// récuppération de la matrice de 9 points
// [ 1, 2 , 3 ]
// [ 4,ori, 5 ]
// [ 6, 7 , 8 ]
ori = tex2D(s0, tex);
float4 c1 = tex2D(s0, tex + float2(-dx,-dy));
float4 c2 = tex2D(s0, tex + float2(0,-dy));
float4 c3 = tex2D(s0, tex + float2(dx,-dy));
float4 c4 = tex2D(s0, tex + float2(-dx,0));
float4 c5 = tex2D(s0, tex + float2(dx,0));
float4 c6 = tex2D(s0, tex + float2(-dx,dy));
float4 c7 = tex2D(s0, tex + float2(0,dy));
float4 c8 = tex2D(s0, tex + float2(dx,dy));
////////////////////////////////////////////////////
// calcul image floue (filtre gaussien)
// pour normaliser les valeurs, il faut diviser par la somme des coef
// 1/(1+2+1+2+4+2+1+2+1) = 1/ 16 = .0625
flou = (c1+c3+c6+c8 + 2*(c2+c4+c5+c7)+ 4*ori)*0.0625;
// soustraction de l'image flou à l'image originale
cori = 2*ori - flou;
////////////////////////////////////////////////////
// détection des contours
float delta1;
float delta2;
float value;
// par filtre de sobel
// Gradient horizontal
// [ -1, 0 ,1 ]
// [ -2, 0, 2 ]
// [ -1, 0 ,1 ]
delta1 = (c3 + 2*c5 + c8)-(c1 + 2*c4 + c6);
// Gradient vertical
// [ -1,- 2,-1 ]
// [ 0, 0, 0 ]
// [ 1, 2, 1 ]
delta2 = (c6 + 2*c7 + c8)-(c1 + 2*c2 + c3);
// calcul
value = sqrt( mul(delta1,delta1) + mul(delta2,delta2) ) ;
if( value >.3 )
{
////////////////////////////////////////////////////
// si contour, sharpen
#define Sharpen_val0 2.0
#define Sharpen_val1 0.125
final = ori*2 - (c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 ) * 0.125 ;
// final= float4(1,0,0,0);
return final;
}
else
{
////////////////////////////////////////////////////
// sinon, image corrigée
return cori;
}
}