diff options
author | scuri <scuri> | 2008-10-17 06:10:15 +0000 |
---|---|---|
committer | scuri <scuri> | 2008-10-17 06:10:15 +0000 |
commit | 5a422aba704c375a307a902bafe658342e209906 (patch) | |
tree | 5005011e086bb863d8fb587ad3319bbec59b2447 /src/lua5/im_fftw.lua |
First commit - moving from LuaForge to SourceForge
Diffstat (limited to 'src/lua5/im_fftw.lua')
-rw-r--r-- | src/lua5/im_fftw.lua | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/lua5/im_fftw.lua b/src/lua5/im_fftw.lua new file mode 100644 index 0000000..e57c7bf --- /dev/null +++ b/src/lua5/im_fftw.lua @@ -0,0 +1,48 @@ + +------------------------------------------------------------------------------- +-- Creates a new function, with the name suffixed by "New". This new function +-- creates a new image, based on a source image, and calls the previous function +-- with this new image. + +local function OneSourceOneDest (funcname, width, height, color_space, data_type) + local func = im[funcname] + assert(func) -- see if function is really defined + + -- define function with "New" suffix + im[funcname.."New"] = function (src_image, ...) + -- create destination image + local dst_image = im.ImageCreateBased(src_image, width, height, color_space, data_type) + + -- call previous method, repassing all parameters + func(src_image, dst_image, unpack(arg)) + return dst_image + end +end + +------------------------------------------------------------------------------- +-- This function is similar to OneSourceOneDest, but it receives two source +-- images. + +local function TwoSourcesOneDest (funcname, width, height, color_space, data_type) + local func = im[funcname] + + -- see if function is really defined + assert(func, string.format("undefined function `%s'", funcname)) + + -- define function with "New" suffix + im[funcname.."New"] = function (src_image1, src_image2, ...) + -- create destination image + local dst_image = im.ImageCreateBased(src_image1, width, height, color_space, data_type) + + -- call previous method, repassing all parameters + func(src_image1, src_image2, dst_image, unpack(arg)) + return dst_image + end +end + +------------------------------------------------------------------------------- + +TwoSourcesOneDest("ProcessCrossCorrelation") +OneSourceOneDest("ProcessAutoCorrelation", nil, nil, nil, im.CFLOAT) +OneSourceOneDest("ProcessFFT") +OneSourceOneDest("ProcessIFFT") |