26 enum find_ref_t find_ref(
struct ref_set *refs,
struct blob_set *blobset,
int width,
int height,
const mpfr_t centerx,
const mpfr_t centery,
const mpfr_t radius,
double max_glitch,
int max_blob) {
33 for (
int i = 0;
i < blob_count; ++
i) {
36 double percent = 100 * count / (double) (width * height);
39 if (percent <= max_glitch || blobs[0].count <= max_blob) {
43 mpfr_inits2(53, cx, cy, (mpfr_ptr) 0);
44 for (
int i = 0;
i < blob_count; ++
i) {
46 struct blob *blobs2 =
find_blobs2(&blob_count2, width, height, glitched, &blobs[
i]);
48 for (
int j = 0;
j < blob_count2; ++
j) {
51 int x = round(blobs2[j].i / (
double) blobs2[j].count);
52 int y = round(blobs2[j].j / (
double) blobs2[j].count);
53 pixel_coordinate(cx, cy, width, height, centerx, centery, radius, x + 0.5, y + 0.5);
67 mpfr_clears(cx, cy, (mpfr_ptr) 0);
83 double percent = 100 * count / (double) (width * height);
91 mpfr_inits2(53, cx, cy, (mpfr_ptr) 0);
92 for (
int k = 0; k < count; ++k) {
93 pixel_coordinate(cx, cy, width, height, centerx, centery, radius, pxs[k].
i + 0.5, pxs[k].
j + 0.5);
100 mpfr_clears(cx, cy, (mpfr_ptr) 0);
114 if (blobs[0].count > 0) {
116 for (
int i = 0;
i < index; ++
i) {
120 if (blobs[i].count > 0) {
123 mpfr_inits2(53, cx, cy, r, (mpfr_ptr) 0);
124 int px = round(blobs[i].i / (
double) blobs[i].count);
125 int py = round(blobs[i].j / (
double) blobs[i].count);
126 pixel_coordinate(cx, cy, width, height, centerx, centery, radius, px + 0.5, py + 0.5);
132 mpfr_clears(cx, cy, r, (mpfr_ptr) 0);
146 free(blobs); blobs = 0;
151 int pixels = width * height;
155 struct pixel *reg = malloc((width + M - 1)/(M/2) * (height + N - 1)/(N/2) *
sizeof(
struct pixel));
157 for (
int j = 0; j < height; j += N/2) {
158 for (
int i = 0; i < width; i += M/2) {
160 double local_total = 0;
161 double local_max = -1;
164 for (
int jj = 0; jj < N; ++jj) {
166 if (! (jjj < height)) {
continue; }
167 for (
int ii = 0; ii < M; ++ii) {
169 if (! (iii < width)) {
continue; }
170 int kkk = jjj * width + iii;
173 local_total += data_n[kkk];
174 if (data_n[kkk] > local_max) {
175 local_max = data_n[kkk];
184 reg[regs].
n = local_total;
185 reg[regs].
i = local_i;
186 reg[regs].
j = local_j;