20 FUNCTION_NAME(IMAGETYPE &dest,
const IMAGETYPE &source,
21 float width, FilterFunction *make_filter,
int channel) {
22 if (!dest.is_valid() || !source.is_valid()) {
30 StoreType **matrix = (StoreType **)PANDA_MALLOC_ARRAY(dest.ASIZE() *
sizeof(StoreType *));
31 StoreType **matrix_weight = (StoreType **)PANDA_MALLOC_ARRAY(dest.ASIZE() *
sizeof(StoreType *));
35 for (a=0; a<dest.ASIZE(); a++) {
36 matrix[a] = (StoreType *)PANDA_MALLOC_ARRAY(source.BSIZE() *
sizeof(StoreType));
37 matrix_weight[a] = (StoreType *)PANDA_MALLOC_ARRAY(source.BSIZE() *
sizeof(StoreType));
42 StoreType *temp_source, *temp_source_weight, *temp_dest, *temp_dest_weight;
44 scale = (float)dest.ASIZE() / (float)source.ASIZE();
45 temp_source = (StoreType *)PANDA_MALLOC_ARRAY(source.ASIZE() *
sizeof(StoreType));
46 temp_source_weight = (StoreType *)PANDA_MALLOC_ARRAY(source.ASIZE() *
sizeof(StoreType));
47 temp_dest = (StoreType *)PANDA_MALLOC_ARRAY(dest.ASIZE() *
sizeof(StoreType));
48 temp_dest_weight = (StoreType *)PANDA_MALLOC_ARRAY(dest.ASIZE() *
sizeof(StoreType));
53 make_filter(scale, width, filter, filter_width);
55 for (b = 0; b < source.BSIZE(); b++) {
56 memset(temp_source_weight, 0, source.ASIZE() *
sizeof(StoreType));
57 for (a = 0; a < source.ASIZE(); a++) {
58 if (source.HASVAL(a, b)) {
59 temp_source[a] = (StoreType)(source_max * source.GETVAL(a, b, channel));
60 temp_source_weight[a] = filter_max;
64 filter_sparse_row(temp_dest, temp_dest_weight, dest.ASIZE(),
65 temp_source, temp_source_weight, source.ASIZE(),
67 filter, filter_width);
69 for (a = 0; a < dest.ASIZE(); a++) {
70 matrix[a][b] = temp_dest[a];
71 matrix_weight[a][b] = temp_dest_weight[a];
75 PANDA_FREE_ARRAY(temp_source);
76 PANDA_FREE_ARRAY(temp_source_weight);
77 PANDA_FREE_ARRAY(temp_dest);
78 PANDA_FREE_ARRAY(temp_dest_weight);
79 PANDA_FREE_ARRAY(filter);
82 scale = (float)dest.BSIZE() / (float)source.BSIZE();
83 temp_dest = (StoreType *)PANDA_MALLOC_ARRAY(dest.BSIZE() *
sizeof(StoreType));
84 temp_dest_weight = (StoreType *)PANDA_MALLOC_ARRAY(dest.BSIZE() *
sizeof(StoreType));
86 make_filter(scale, width, filter, filter_width);
88 for (a = 0; a < dest.ASIZE(); a++) {
89 filter_sparse_row(temp_dest, temp_dest_weight, dest.BSIZE(),
90 matrix[a], matrix_weight[a], source.BSIZE(),
92 filter, filter_width);
94 for (b = 0; b < dest.BSIZE(); b++) {
95 if (temp_dest_weight[b] != 0) {
96 dest.SETVAL(a, b, channel, (
float)temp_dest[b]/(
float)source_max);
101 PANDA_FREE_ARRAY(temp_dest);
102 PANDA_FREE_ARRAY(temp_dest_weight);
103 PANDA_FREE_ARRAY(filter);
107 for (a = 0; a < dest.ASIZE(); a++) {
108 PANDA_FREE_ARRAY(matrix[a]);
109 PANDA_FREE_ARRAY(matrix_weight[a]);
111 PANDA_FREE_ARRAY(matrix);
112 PANDA_FREE_ARRAY(matrix_weight);