ui::input: Remove duplicate instance of 'cpf-load' command entry.
[Ale.git] / d2 / align.cc
blob54e9ae673bf6083d6006adba379507a2f106f428
1 // Copyright 2002 David Hilvert <dhilvert@auricle.dyndns.org>,
2 // <dhilvert@ugcs.caltech.edu>
4 /* This file is part of the Anti-Lamenessing Engine.
6 The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with the Anti-Lamenessing Engine; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "align.h"
24 * See align.h for details on these variables.
27 int align::_exp_register = 1;
29 ale_pos align::scale_factor;
31 transformation align::orig_t;
32 int align::_keep = 0;
33 transformation *align::kept_t = NULL;
34 int *align::kept_ok = NULL;
36 tload_t *align::tload = NULL;
37 tsave_t *align::tsave = NULL;
38 render *align::reference = NULL;
39 filter::scaled_filter *align::interpolant = NULL;
40 const image *align::reference_image = NULL;
41 const image *align::reference_defined = NULL;
42 const image *align::weight_map = NULL;
43 image *align::alignment_weights = NULL;
44 const char *align::wmx_file = NULL;
45 const char *align::wmx_exec = NULL;
46 const char *align::wmx_defs = NULL;
47 const char *align::fw_output = NULL;
48 double align::horiz_freq_cut = 0;
49 double align::vert_freq_cut = 0;
50 double align::avg_freq_cut = 0;
51 transformation align::latest_t;
52 int align::latest_ok;
53 int align::latest = -1;
55 int align::alignment_class = 1;
56 int align::default_initial_alignment_type = 1;
57 int align::perturb_type = 0;
58 int align::is_fail_default = 0;
59 int align::channel_alignment_type = 2;
60 float align::metric_exponent = 2;
61 float align::match_threshold = 0;
64 * Upper/lower bounds
67 ale_pos align::perturb_lower = 0.125;
68 int align::perturb_lower_percent = 0;
69 ale_pos align::perturb_upper = 14;
70 int align::perturb_upper_percent = 1;
72 int align::lod_max = -4;
74 ale_pos align::rot_max = 32.0;
75 ale_pos align::bda_mult = 2;
76 ale_pos align::bda_rate = 8;
77 ale_accum align::match_sum = 0;
78 int align::match_count = 0;
80 ale_pos align::_mc = 30;
81 int align::certainty_weights = 0;
82 int align::_gs = 6;
83 unsigned int align::_ma_card = 1;
84 double align::_ma_cont = 100;
86 ale_pos align::_gs_mo = 67;
87 int align::gs_mo_percent = 1;
89 exclusion *align::ax_parameters = NULL;
90 int align::ax_count = 0;
92 const point **align::cp_array = NULL;
93 unsigned int align::cp_count = 0;
95 void *d2::align::diff_stat_t::diff_subdomain(void *args) {
97 subdomain_args *sargs = (subdomain_args *) args;
99 struct scale_cluster c = sargs->c;
100 std::vector<run> runs = sargs->runs;
101 int ax_count = sargs->ax_count;
102 int f = sargs->f;
103 int i_min = sargs->i_min;
104 int i_max = sargs->i_max;
105 int j_min = sargs->j_min;
106 int j_max = sargs->j_max;
107 int subdomain = sargs->subdomain;
109 assert (reference_image);
111 point offset = c.accum->offset();
113 for (mc_iterate m(i_min, i_max, j_min, j_max, subdomain); !m.done(); m++) {
115 int i = m.get_i();
116 int j = m.get_j();
119 * Check for exclusion in render coordinates.
122 if (ref_excluded(i, j, offset, c.ax_parameters, ax_count))
123 continue;
126 * Check transformation support.
129 if (!runs.back().offset.supported((int) (i + offset[0]), (int) (j + offset[1])))
130 continue;
133 * Transform
136 struct point q, r = point::undefined();
138 q = (c.input_scale < 1.0 && interpolant == NULL)
139 ? runs.back().offset.scaled_inverse_transform(
140 point(i + offset[0], j + offset[1]))
141 : runs.back().offset.unscaled_inverse_transform(
142 point(i + offset[0], j + offset[1]));
144 if (runs.size() == 2) {
145 r = (c.input_scale < 1.0)
146 ? runs.front().offset.scaled_inverse_transform(
147 point(i + offset[0], j + offset[1]))
148 : runs.front().offset.unscaled_inverse_transform(
149 point(i + offset[0], j + offset[1]));
152 ale_pos ti = q[0];
153 ale_pos tj = q[1];
156 * Check that the transformed coordinates are within
157 * the boundaries of array c.input and that they
158 * are not subject to exclusion.
160 * Also, check that the weight value in the accumulated array
161 * is nonzero, unless we know it is nonzero by virtue of the
162 * fact that it falls within the region of the original frame
163 * (e.g. when we're not increasing image extents).
166 if (input_excluded(ti, tj, c.ax_parameters, ax_count))
167 continue;
169 if (input_excluded(r[0], r[1], c.ax_parameters, ax_count))
170 r = point::undefined();
173 * Check the boundaries of the input frame
176 if (!(ti >= 0
177 && ti <= c.input->height() - 1
178 && tj >= 0
179 && tj <= c.input->width() - 1
180 && c.certainty->get_pixel(i, j)[0] != 0))
181 continue;
183 if (!(r[0] >= 0
184 && r[0] <= c.input->height() - 1
185 && r[1] >= 0
186 && r[1] <= c.input->width() - 1))
187 r = point::undefined();
189 sargs->runs.back().sample(f, c, i, j, q, r, runs.front());
192 return NULL;