1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
/** \file
* \brief IM Lua 5 Binding
*
* See Copyright Notice in im_lib.h
* $Id: imlua_kernel.c,v 1.1 2008/10/17 06:16:32 scuri Exp $
*/
#include <memory.h>
#include <math.h>
#include <stdlib.h>
#include "im.h"
#include "im_image.h"
#include "im_process.h"
#include "im_util.h"
#include "im_kernel.h"
#include <lua.h>
#include <lauxlib.h>
#include "imlua.h"
#include "imlua_aux.h"
#include "imlua_image.h"
static int imluaKernelSobel(lua_State *L)
{
imlua_pushimage(L, imKernelSobel());
return 1;
}
static int imluaKernelPrewitt(lua_State *L)
{
imlua_pushimage(L, imKernelPrewitt());
return 1;
}
static int imluaKernelKirsh(lua_State *L)
{
imlua_pushimage(L, imKernelKirsh());
return 1;
}
static int imluaKernelLaplacian4(lua_State *L)
{
imlua_pushimage(L, imKernelLaplacian4());
return 1;
}
static int imluaKernelLaplacian8(lua_State *L)
{
imlua_pushimage(L, imKernelLaplacian8());
return 1;
}
static int imluaKernelLaplacian5x5(lua_State *L)
{
imlua_pushimage(L, imKernelLaplacian5x5());
return 1;
}
static int imluaKernelLaplacian7x7(lua_State *L)
{
imlua_pushimage(L, imKernelLaplacian7x7());
return 1;
}
static int imluaKernelGradian3x3(lua_State *L)
{
imlua_pushimage(L, imKernelGradian3x3());
return 1;
}
static int imluaKernelGradian7x7(lua_State *L)
{
imlua_pushimage(L, imKernelGradian7x7());
return 1;
}
static int imluaKernelSculpt(lua_State *L)
{
imlua_pushimage(L, imKernelSculpt());
return 1;
}
static int imluaKernelMean3x3(lua_State *L)
{
imlua_pushimage(L, imKernelMean3x3());
return 1;
}
static int imluaKernelMean5x5(lua_State *L)
{
imlua_pushimage(L, imKernelMean5x5());
return 1;
}
static int imluaKernelCircularMean5x5(lua_State *L)
{
imlua_pushimage(L, imKernelCircularMean5x5());
return 1;
}
static int imluaKernelMean7x7(lua_State *L)
{
imlua_pushimage(L, imKernelMean7x7());
return 1;
}
static int imluaKernelCircularMean7x7(lua_State *L)
{
imlua_pushimage(L, imKernelCircularMean7x7());
return 1;
}
static int imluaKernelGaussian3x3(lua_State *L)
{
imlua_pushimage(L, imKernelGaussian3x3());
return 1;
}
static int imluaKernelGaussian5x5(lua_State *L)
{
imlua_pushimage(L, imKernelGaussian5x5());
return 1;
}
static int imluaKernelBarlett5x5(lua_State *L)
{
imlua_pushimage(L, imKernelBarlett5x5());
return 1;
}
static int imluaKernelTopHat5x5(lua_State *L)
{
imlua_pushimage(L, imKernelTopHat5x5());
return 1;
}
static int imluaKernelTopHat7x7(lua_State *L)
{
imlua_pushimage(L, imKernelTopHat7x7());
return 1;
}
static int imluaKernelEnhance(lua_State *L)
{
imlua_pushimage(L, imKernelEnhance());
return 1;
}
static const luaL_reg imkernel_lib[] = {
{"KernelSobel", imluaKernelSobel},
{"KernelPrewitt", imluaKernelPrewitt},
{"KernelKirsh", imluaKernelKirsh},
{"KernelLaplacian4", imluaKernelLaplacian4},
{"KernelLaplacian8", imluaKernelLaplacian8},
{"KernelLaplacian5x5", imluaKernelLaplacian5x5},
{"KernelLaplacian7x7", imluaKernelLaplacian7x7},
{"KernelGradian3x3", imluaKernelGradian3x3},
{"KernelGradian7x7", imluaKernelGradian7x7},
{"KernelSculpt", imluaKernelSculpt},
{"KernelMean3x3", imluaKernelMean3x3},
{"KernelMean5x5", imluaKernelMean5x5},
{"KernelCircularMean5x5", imluaKernelCircularMean5x5},
{"KernelMean7x7", imluaKernelMean7x7},
{"KernelCircularMean7x7", imluaKernelCircularMean7x7},
{"KernelGaussian3x3", imluaKernelGaussian3x3},
{"KernelGaussian5x5", imluaKernelGaussian5x5},
{"KernelBarlett5x5", imluaKernelBarlett5x5},
{"KernelTopHat5x5", imluaKernelTopHat5x5},
{"KernelTopHat7x7", imluaKernelTopHat7x7},
{"KernelEnhance", imluaKernelEnhance},
{NULL, NULL}
};
void imlua_open_kernel (lua_State *L)
{
/* "im" table is at the top of the stack */
luaL_register(L, NULL, imkernel_lib);
}
|