Good job Rick...

Now to say that I don't know if I'm happy with the quality of that blur.
It's sort of pixel-y. Could just be the amount of blur you put on it I
suppose...

Keep up the good work regardless...I assume that this is for adding into
Image.cfc?

<!----------------//------
andy matthews
web developer
certified advanced coldfusion programmer
ICGLink, Inc.
[EMAIL PROTECTED]
615.370.1530 x737
--------------//--------->

-----Original Message-----
From: Rick Root [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 13, 2006 7:39 AM
To: CF-Talk
Subject: Re: Code Comparison: Java - CF


I finally got a box blur to work!

Original image:
http://www.opensourcecf.com/imagecfc/thumbnail_test/boxblurorig.jpg

hRadius=1, vRadius=1, iterations=3:
http://www.opensourcecf.com/imagecfc/thumbnail_test/boxblurorig2.jpg

I went to wikipedia to see what the mathematical description of a box
blur is, and it says that each pixel is an "average" of its neighboring
pixels (depending on the radius).

Essentially, I'm averaging each component of the left and right pixels
to any given pixel.

The following loop handles each row of pixels.  "inIndex" is always the
location of the first pixel in the row.

for ( x = 0; x lt width; x=x+1 )
{

        // clamp(num,min,max) forces a number to be between a certain
        // range
        // which pixels to look at:
offsetRight = clamp(x+radius,0,width-1);
offsetLeft = clamp(x-radius,0,width-1);

        // get the ARGB value for each pixel
rgbRight = arrObj.get(inPixels, javacast("int",inIndex+offsetRight));
rgbLeft = arrObj.get(inPixels, javacast("int",inIndex+offsetLeft));

        // separateRGB(val) returns a struct with the 4 components
        // in it - alpha, red, green, and blue
separatedRight = separateRGB(rgbRight);
separatedLeft = separateRGB(rgbLeft);
ta = (separatedRight.rgbAlpha+separatedLeft.rgbAlpha)/2;
tr = (separatedRight.rgbRed+separatedLeft.rgbRed)/2;
tg = (separatedRight.rgbGreen+separatedLeft.rgbGreen)/2;
tb = (separatedRight.rgbBlue+separatedLeft.rgbBlue)/2;
rgb = combineRGB(ta,tr,tg,tb);
arrObj.setInt(out, javacast("int",outIndex), javacast("int",rgb));

        // I don't really understand this but it works.  I think
        // it's because a box blur requires TWO passes ...
outIndex = outIndex + height;
}

Now to work on getting the gaussian blur to work (though a box blur with
3 iterations "simulates" a gaussian blur apparently)

Rick



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:263916
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to