kernel HorizontalGaussianBlurEllipse < namespace : "northprint"; vendor : ""; version : 1; description : ""; > { input image4 src; output pixel4 dst; //BlurLevel parameter int blurradius < minValue : 1; maxValue : 6; defaultValue : 1; >; //Center parameter float2 centerpoint < minValue:float2(0.0); maxValue:float2(1000.0); defaultValue:float2(200.0); >; //Circle Radius parameter float radius < minValue:0.0; maxValue:500.0; defaultValue:100.0; >; void evaluatePixel(){ pixel4 center, band1, band2, band3, band4, band5, band6; float2 pos = outCoord(); float2 ellipsepos = float2(float((pos.x + centerpoint[0]) / 2.0) , pos.y); float dist = distance(centerpoint,ellipsepos); if (dist > radius){ //Sample image in bands if( blurradius > 5 ){ band6 = sampleNearest(src, float2(pos.x - 6.0, pos.y)) + sampleNearest(src, float2(pos.x + 6.0, pos.y)); } if( blurradius > 4 ){ band5 = sampleNearest(src, float2(pos.x - 5.0, pos.y)) + sampleNearest(src, float2(pos.x + 5.0, pos.y)); } if( blurradius > 3 ){ band4 = sampleNearest(src, float2(pos.x - 4.0, pos.y)) + sampleNearest(src, float2(pos.x + 4.0, pos.y)); } if( blurradius > 2 ){ band3 = sampleNearest(src, float2(pos.x - 3.0, pos.y)) + sampleNearest(src, float2(pos.x + 3.0, pos.y)); } if( blurradius > 1 ){ band2 = sampleNearest(src, float2(pos.x - 2.0, pos.y)) + sampleNearest(src, float2(pos.x + 2.0, pos.y)); } band1 = sampleNearest(src, float2(pos.x - 1.0, pos.y))+ sampleNearest(src, float2(pos.x + 1.0, pos.y)); center = sampleNearest(src, pos); //Apply weights and compute resulting pixel if( blurradius == 6 ){ dst = (band6 + (band5 * 12.0) + (band4 * 66.0) + (band3 * 220.0) + (band2 * 495.0) + (band1 * 792.0) + (center * 924.0))/4096.0; } if( blurradius == 5 ){ dst = (band5 + (band4 * 10.0) + (band3 * 45.0) + (band2 * 120.0) + (band1 * 210.0) + (center * 252.0))/1024.0; } if( blurradius == 4 ){ dst = (band4 + (band3 * 8.0) + (band2 * 28.0) + (band1 * 56.0) + (center * 70.0))/256.0; } if( blurradius == 3 ){ dst = (band3 + (band2 * 6.0) + (band1 * 15.0) + (center * 20.0))/64.0; } if( blurradius == 2 ){ dst = (band2 + (band1 * 4.0) + (center * 6.0))/16.0; } if( blurradius == 1 ){ dst = (band1 + (center * 2.0))/4.0; } } else { dst = sampleNearest(src,pos); } } }