|
|
Fast Blur Algorithm
Added on 8/23/2005
|
This imaging algorithm is a fast blur. It will not work in real time, but it's quick, nonetheless.
-- Fast Blur Imaging Code
-- ©2005 by Josh Chunick (josh@chunick.com)
-- This code is free to use in commercial applications
-- or however you want. If you use this code you
-- must keep the comments, including this message,
-- intact. Feel free to add any changes or make
-- improvements.
-- anImage is an image object
-- hBlur is the amount of blurring as an integer or float
-- vBlur is the amount of blurring as an integer or float
on fastBlur (anImage, hBlur, vBlur)
newImage = anImage.duplicate()
theWidth = newImage.width - 1
theHeight = newImage.height - 1
-- draw each pixel in the new image
repeat with y1 = 0 to theHeight
repeat with x1 = 0 to theWidth
interplY1 = max(min(y1 - vBlur, y1 - 1), 1)
interplX1 = max(min(x1 - hBlur, x1 - 1), 1)
interplY2 = min(max(y1 + vBlur, y1 + 1), theHeight)
interplX2 = min(max(x1 + hBlur, x1 + 1), theWidth)
newImage.copyPixels(anImage, rect(x1,y1,x1 + 1,y1 + 1), rect(interplX1,interplY1,interplX2,interplY2))
end repeat
end repeat
return newImage
end
|
|