redeye 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Rakefile +1 -1
- data/ext/redeye/redeye.cr +125 -125
- metadata +59 -86
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d8bea79161aeebd27cfd7fda855e10193fc263c7
|
4
|
+
data.tar.gz: b90cac02c0bc02c3fc244898beeb3adf92c686b1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1628f8ae1003705f0ee31bfd0cedb7e386f8e5c643844d212465f78dd1dd031997155baf1044d56d74b4b734c46d605eb75aa50932e46f7d7394febb04be989d
|
7
|
+
data.tar.gz: f4d95dc6ce53c3d26fd117175d7aef1964a74ddce47fc64efd366513fca2e83828654c1a63e8161674ae2d0fb69ff8acda8b8689e229ef498c1f0ff3fd9ad55a
|
data/Rakefile
CHANGED
@@ -22,7 +22,7 @@ spec = Gem::Specification.new do |s|
|
|
22
22
|
s.name = "redeye"
|
23
23
|
s.author = "Geoff Youngs"
|
24
24
|
s.email = "git@intersect-uk.co.uk"
|
25
|
-
s.version = "1.0.
|
25
|
+
s.version = "1.0.2"
|
26
26
|
s.homepage = "http://github.com/geoffyoungs/redeye"
|
27
27
|
s.summary = "Redeye correction for Gdk::Pixbuf"
|
28
28
|
s.add_dependency("rubber-generate", ">= 0.0.17")
|
data/ext/redeye/redeye.cr
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
%pkg-config
|
1
|
+
%pkg-config gdk-pixbuf-2.0
|
2
2
|
%include gdk-pixbuf/gdk-pixbuf.h
|
3
3
|
|
4
|
-
|
4
|
+
%option gtk=no
|
5
5
|
%map VALUE > GdkPixbuf* : GDK_PIXBUF(RVAL2GOBJ(%%))
|
6
6
|
%map GdkPixbuf* > VALUE : GOBJ2RVAL(GDK_PIXBUF(%%))
|
7
7
|
%map unref_pixbuf > VALUE : unref_pixbuf((%%))
|
@@ -36,59 +36,59 @@ typedef struct {
|
|
36
36
|
|
37
37
|
#define MIN_RED_VAL 20
|
38
38
|
|
39
|
-
static inline VALUE
|
39
|
+
static inline VALUE
|
40
40
|
unref_pixbuf(GdkPixbuf *pixbuf)
|
41
41
|
{
|
42
42
|
volatile VALUE pb = Qnil;
|
43
|
-
|
43
|
+
|
44
44
|
pb = GOBJ2RVAL(pixbuf);
|
45
|
-
|
45
|
+
|
46
46
|
g_object_unref(pixbuf);
|
47
|
-
|
47
|
+
|
48
48
|
return pb;
|
49
49
|
}
|
50
50
|
|
51
51
|
static void identify_possible_redeye_pixels(redeyeop_t *op,
|
52
52
|
double green_sensitivity, double blue_sensitivity,
|
53
|
-
int min_red_val)
|
53
|
+
int min_red_val)
|
54
54
|
{
|
55
55
|
guchar *data = gdk_pixbuf_get_pixels(op->pixbuf);
|
56
56
|
int rowstride = gdk_pixbuf_get_rowstride(op->pixbuf);
|
57
57
|
int pixWidth = gdk_pixbuf_get_has_alpha(op->pixbuf) ? 4 : 3;
|
58
|
-
|
58
|
+
|
59
59
|
int y, ry = 0, x, rx = 0;
|
60
60
|
for ( y = op->area.minY; y < op->area.maxY; y++ )
|
61
61
|
{
|
62
62
|
guchar *thisLine = data + (rowstride * y);
|
63
63
|
guchar *pixel;
|
64
|
-
|
64
|
+
|
65
65
|
pixel = thisLine + (op->area.minX * pixWidth);
|
66
66
|
rx = 0;
|
67
|
-
|
67
|
+
|
68
68
|
for ( x = op->area.minX; x < op->area.maxX; x++ )
|
69
69
|
{
|
70
|
-
|
70
|
+
|
71
71
|
int r,g,b;
|
72
|
-
|
72
|
+
|
73
73
|
r = pixel[0];
|
74
74
|
g = pixel[1];
|
75
75
|
b = pixel[2];
|
76
|
-
|
76
|
+
|
77
77
|
gboolean threshMet;
|
78
|
-
|
79
|
-
threshMet = (((double)r) > (green_sensitivity * (double)g)) &&
|
80
|
-
(((double)r) > (blue_sensitivity * (double)b)) &&
|
78
|
+
|
79
|
+
threshMet = (((double)r) > (green_sensitivity * (double)g)) &&
|
80
|
+
(((double)r) > (blue_sensitivity * (double)b)) &&
|
81
81
|
(r > min_red_val);
|
82
|
-
|
82
|
+
|
83
83
|
if(threshMet)
|
84
84
|
op->mask[ rx + ry ] = r;
|
85
85
|
else
|
86
86
|
op->mask[ rx + ry ] = 0; /* MEMZERO should have done its job ? */
|
87
|
-
|
87
|
+
|
88
88
|
pixel += pixWidth;
|
89
89
|
rx ++;
|
90
90
|
}
|
91
|
-
|
91
|
+
|
92
92
|
ry += op->area.width;
|
93
93
|
}
|
94
94
|
}
|
@@ -97,17 +97,17 @@ static void identify_possible_redeye_pixels(redeyeop_t *op,
|
|
97
97
|
inline int group_at(redeyeop_t *op, int px, int py)
|
98
98
|
{
|
99
99
|
int index, region;
|
100
|
-
|
100
|
+
|
101
101
|
if (px < 0 || py < 0)
|
102
102
|
return 0;
|
103
|
-
|
103
|
+
|
104
104
|
index = px + ( py * op->area.width );
|
105
|
-
|
105
|
+
|
106
106
|
if (index < 0)
|
107
107
|
return 0;
|
108
108
|
if (index > (op->area.width * op->area.height))
|
109
109
|
return 0;
|
110
|
-
|
110
|
+
|
111
111
|
region = op->regions.data[ index ];
|
112
112
|
if (region > 0) {
|
113
113
|
if (op->regions.region[ region ].mergeWith) {
|
@@ -122,11 +122,11 @@ inline int group_at(redeyeop_t *op, int px, int py)
|
|
122
122
|
|
123
123
|
#define group_for(x,y) group_at(op, x, y)
|
124
124
|
|
125
|
-
static void identify_blob_groupings(redeyeop_t *op)
|
125
|
+
static void identify_blob_groupings(redeyeop_t *op)
|
126
126
|
{
|
127
127
|
volatile int next_blob_id = 1, blob_id, y, x;
|
128
|
-
|
129
|
-
|
128
|
+
|
129
|
+
|
130
130
|
for( y = 0; y < op->area.height; y++ )
|
131
131
|
{
|
132
132
|
for ( x = 0; x < op->area.width; x++ )
|
@@ -136,28 +136,28 @@ static void identify_blob_groupings(redeyeop_t *op)
|
|
136
136
|
int sx, sy, group = 0;
|
137
137
|
// Target pixel is true
|
138
138
|
blob_id = 0;
|
139
|
-
|
139
|
+
|
140
140
|
for (sy = y; sy >= y - 1; sy --) {
|
141
141
|
sx = (sy == y) ? x : x + 1;
|
142
142
|
for (; sx >= (x - 1); sx --) {
|
143
143
|
/*if ((sx >= x) && (sy >= y))
|
144
144
|
goto blob_scan_done;*/
|
145
|
-
|
145
|
+
|
146
146
|
if (sx >= 0 && sy >= 0)
|
147
147
|
group = group_for(sx, sy);
|
148
|
-
|
148
|
+
|
149
149
|
if (group) {
|
150
150
|
existing = TRUE;
|
151
151
|
if (blob_id) {
|
152
152
|
int target = MIN(blob_id, group);
|
153
153
|
int from = MAX(blob_id, group);
|
154
|
-
|
154
|
+
|
155
155
|
if (op->regions.region[target].mergeWith > 0) {
|
156
156
|
// Already merged
|
157
157
|
target = op->regions.region[target].mergeWith;
|
158
158
|
}
|
159
159
|
op->regions.region[from].mergeWith = target;
|
160
|
-
|
160
|
+
|
161
161
|
// Merge blob_id & group
|
162
162
|
}
|
163
163
|
blob_id = group;
|
@@ -176,38 +176,38 @@ static void identify_blob_groupings(redeyeop_t *op)
|
|
176
176
|
op->regions.region[blob_id].height = 1;
|
177
177
|
op->regions.region[blob_id].noPixels = 1;
|
178
178
|
op->regions.region[blob_id].mergeWith = 0;
|
179
|
-
|
179
|
+
|
180
180
|
next_blob_id ++;
|
181
181
|
op->regions.len = next_blob_id;
|
182
|
-
|
182
|
+
|
183
183
|
if (next_blob_id >= op->regions.size) {
|
184
184
|
int extra, new_size;
|
185
|
-
|
185
|
+
|
186
186
|
/*
|
187
187
|
* Realloc in increasingly large chunks to reduce memory fragmentation
|
188
188
|
*/
|
189
189
|
extra = op->regions.size;
|
190
190
|
new_size = op->regions.size + extra;
|
191
|
-
|
191
|
+
|
192
192
|
REALLOC_N(op->regions.region, region_info, new_size);
|
193
|
-
|
193
|
+
|
194
194
|
op->regions.size = new_size;
|
195
195
|
}
|
196
196
|
}
|
197
|
-
|
198
|
-
if (existing)
|
197
|
+
|
198
|
+
if (existing)
|
199
199
|
{
|
200
200
|
op->regions.region[blob_id].minX = MIN(x, op->regions.region[blob_id].minX);
|
201
201
|
op->regions.region[blob_id].maxX = MAX(x, op->regions.region[blob_id].maxX);
|
202
202
|
op->regions.region[blob_id].minY = MIN(y, op->regions.region[blob_id].minY);
|
203
203
|
op->regions.region[blob_id].maxY = MAX(y, op->regions.region[blob_id].maxY);
|
204
|
-
op->regions.region[blob_id].width = op->regions.region[blob_id].maxX -
|
204
|
+
op->regions.region[blob_id].width = op->regions.region[blob_id].maxX -
|
205
205
|
op->regions.region[blob_id].minX + 1;
|
206
|
-
op->regions.region[blob_id].height = op->regions.region[blob_id].maxY -
|
206
|
+
op->regions.region[blob_id].height = op->regions.region[blob_id].maxY -
|
207
207
|
op->regions.region[blob_id].minY + 1;
|
208
208
|
op->regions.region[blob_id].noPixels ++;
|
209
209
|
}
|
210
|
-
|
210
|
+
|
211
211
|
op->regions.data[ x + (y * op->area.width) ] = blob_id;
|
212
212
|
}
|
213
213
|
}
|
@@ -220,14 +220,14 @@ static void identify_blob_groupings(redeyeop_t *op)
|
|
220
220
|
/*
|
221
221
|
if (op->regions.len <= 0xf || 1)
|
222
222
|
{
|
223
|
-
if (g == 0)
|
223
|
+
if (g == 0)
|
224
224
|
fprintf(fp, " ");
|
225
225
|
else
|
226
226
|
fprintf(fp, "%x", g);
|
227
227
|
}
|
228
228
|
else
|
229
229
|
{
|
230
|
-
if (g == 0)
|
230
|
+
if (g == 0)
|
231
231
|
fprintf(fp, " ");
|
232
232
|
else
|
233
233
|
fprintf(fp, "%x ", g);
|
@@ -267,23 +267,23 @@ static void free_redeye(redeyeop_t *ptr)
|
|
267
267
|
inline gboolean in_region(redeyeop_t *op, int x, int y, int blob_id)
|
268
268
|
{
|
269
269
|
int index;
|
270
|
-
|
270
|
+
|
271
271
|
if ( x < op->area.minX || x > op->area.maxX ||
|
272
272
|
y < op->area.minY || y > op->area.maxY )
|
273
273
|
return FALSE;
|
274
|
-
|
274
|
+
|
275
275
|
index = (x - op->area.minX) + ((y - op->area.minY) * op->area.width);
|
276
|
-
|
276
|
+
|
277
277
|
return op->regions.data[index] == blob_id;
|
278
278
|
}
|
279
279
|
|
280
280
|
inline double alpha_level_for_pixel(redeyeop_t *op, int x, int y, int blob_id)
|
281
281
|
{
|
282
282
|
int j = 0, c = 0, xm, ym;
|
283
|
-
|
283
|
+
|
284
284
|
if (in_region(op, x, y, blob_id))
|
285
285
|
return 1.0;
|
286
|
-
|
286
|
+
|
287
287
|
for ( xm = -2; xm <= 2; xm++ )
|
288
288
|
{
|
289
289
|
for ( ym = -2; ym <= 2; ym ++ )
|
@@ -295,7 +295,7 @@ inline double alpha_level_for_pixel(redeyeop_t *op, int x, int y, int blob_id)
|
|
295
295
|
j ++;
|
296
296
|
}
|
297
297
|
}
|
298
|
-
|
298
|
+
|
299
299
|
return ((double)j)/((double)c);
|
300
300
|
}
|
301
301
|
|
@@ -304,7 +304,7 @@ inline char col(double val)
|
|
304
304
|
if (val < 0) return 0;
|
305
305
|
if (val > 255) return 255;
|
306
306
|
return val;
|
307
|
-
|
307
|
+
|
308
308
|
}
|
309
309
|
|
310
310
|
static GdkPixbuf *redeye_preview(redeyeop_t *op, gboolean reset)
|
@@ -312,27 +312,27 @@ static GdkPixbuf *redeye_preview(redeyeop_t *op, gboolean reset)
|
|
312
312
|
int width, height;
|
313
313
|
width = op->area.width;
|
314
314
|
height = op->area.height;
|
315
|
-
|
315
|
+
|
316
316
|
if (width + op->area.minX > gdk_pixbuf_get_width(op->pixbuf)) {
|
317
317
|
width = gdk_pixbuf_get_width(op->pixbuf) - op->area.minX;
|
318
318
|
}
|
319
319
|
if (height + op->area.minY > gdk_pixbuf_get_height(op->pixbuf)) {
|
320
320
|
height = gdk_pixbuf_get_height(op->pixbuf) - op->area.minY;
|
321
321
|
}
|
322
|
-
|
323
|
-
if ( op->preview == NULL )
|
322
|
+
|
323
|
+
if ( op->preview == NULL )
|
324
324
|
{
|
325
325
|
GdkPixbuf *sub = NULL;
|
326
|
-
sub = gdk_pixbuf_new_subpixbuf(op->pixbuf, op->area.minX, op->area.minY,
|
326
|
+
sub = gdk_pixbuf_new_subpixbuf(op->pixbuf, op->area.minX, op->area.minY,
|
327
327
|
width, height);
|
328
|
-
|
328
|
+
|
329
329
|
op->preview = gdk_pixbuf_copy(sub);
|
330
330
|
g_object_unref(sub);
|
331
331
|
} else if (reset) {
|
332
|
-
gdk_pixbuf_copy_area(op->pixbuf, op->area.minX, op->area.minY,
|
332
|
+
gdk_pixbuf_copy_area(op->pixbuf, op->area.minX, op->area.minY,
|
333
333
|
width, height, op->preview, 0, 0);
|
334
334
|
}
|
335
|
-
|
335
|
+
|
336
336
|
return op->preview;
|
337
337
|
}
|
338
338
|
|
@@ -340,35 +340,35 @@ static void desaturate_blob(redeyeop_t *op, int blob_id)
|
|
340
340
|
{
|
341
341
|
int y, x;
|
342
342
|
int minX, minY, maxX, maxY;
|
343
|
-
|
343
|
+
|
344
344
|
minY = MAX(0, op->area.minY + op->regions.region[blob_id].minY - 1);
|
345
|
-
maxY = MIN(op->area.maxY + op->regions.region[blob_id].maxY + 1,
|
345
|
+
maxY = MIN(op->area.maxY + op->regions.region[blob_id].maxY + 1,
|
346
346
|
gdk_pixbuf_get_height(op->pixbuf)-1);
|
347
347
|
minX = MAX(0, op->area.minX + op->regions.region[blob_id].minX - 1);
|
348
|
-
maxX = MIN(op->area.maxX + op->regions.region[blob_id].maxX + 1,
|
348
|
+
maxX = MIN(op->area.maxX + op->regions.region[blob_id].maxX + 1,
|
349
349
|
gdk_pixbuf_get_width(op->pixbuf)-1);
|
350
|
-
|
350
|
+
|
351
351
|
guchar *data = gdk_pixbuf_get_pixels(op->pixbuf);
|
352
352
|
int rowstride = gdk_pixbuf_get_rowstride(op->pixbuf);
|
353
353
|
int pixWidth = gdk_pixbuf_get_has_alpha(op->pixbuf) ? 4 : 3;
|
354
|
-
|
354
|
+
|
355
355
|
for ( y = minY; y <= maxY; y++ )
|
356
356
|
{
|
357
357
|
guchar *thisLine = data + (rowstride * y);
|
358
358
|
guchar *pixel;
|
359
|
-
|
359
|
+
|
360
360
|
pixel = thisLine + (minX * pixWidth);
|
361
|
-
|
361
|
+
|
362
362
|
for ( x = minX; x <= maxX; x++ )
|
363
363
|
{
|
364
|
-
|
364
|
+
|
365
365
|
double alpha = alpha_level_for_pixel(op, x, y, blob_id);
|
366
366
|
int r,g,b,grey;
|
367
|
-
|
367
|
+
|
368
368
|
r = pixel[0];
|
369
369
|
g = pixel[1];
|
370
370
|
b = pixel[2];
|
371
|
-
|
371
|
+
|
372
372
|
if (alpha > 0)
|
373
373
|
{
|
374
374
|
grey = alpha * ((double)( 5 * (double)r + 60 * (double)g + 30 * (double)b)) / 100.0 +
|
@@ -378,11 +378,11 @@ static void desaturate_blob(redeyeop_t *op, int blob_id)
|
|
378
378
|
pixel[1] = col((grey * alpha) + (1-alpha) * g);
|
379
379
|
pixel[2] = col((grey * alpha) + (1-alpha) * b);
|
380
380
|
}
|
381
|
-
|
381
|
+
|
382
382
|
pixel += pixWidth;
|
383
383
|
}
|
384
384
|
}
|
385
|
-
|
385
|
+
|
386
386
|
}
|
387
387
|
|
388
388
|
static void highlight_blob(redeyeop_t *op, int blob_id, int colour)
|
@@ -390,16 +390,16 @@ static void highlight_blob(redeyeop_t *op, int blob_id, int colour)
|
|
390
390
|
int y, x;
|
391
391
|
int minX, minY, maxX, maxY;
|
392
392
|
int hr, hg, hb;
|
393
|
-
|
393
|
+
|
394
394
|
hr = (colour >> 16) & 0xff;
|
395
395
|
hg = (colour >> 8) & 0xff;
|
396
396
|
hb = (colour) & 0xff;
|
397
|
-
|
397
|
+
|
398
398
|
minY = MAX(0, op->area.minY - 1);
|
399
399
|
maxY = MIN(op->area.maxY + 1, gdk_pixbuf_get_height(op->pixbuf)-1);
|
400
400
|
minX = MAX(0, op->area.minX - 1);
|
401
401
|
maxX = MIN(op->area.maxX + 1, gdk_pixbuf_get_width(op->pixbuf)-1);
|
402
|
-
|
402
|
+
|
403
403
|
guchar *data = gdk_pixbuf_get_pixels(op->pixbuf);
|
404
404
|
int rowstride = gdk_pixbuf_get_rowstride(op->pixbuf);
|
405
405
|
int pixWidth = gdk_pixbuf_get_has_alpha(op->pixbuf) ? 4 : 3;
|
@@ -408,32 +408,32 @@ static void highlight_blob(redeyeop_t *op, int blob_id, int colour)
|
|
408
408
|
{
|
409
409
|
guchar *thisLine = data + (rowstride * y);
|
410
410
|
guchar *pixel;
|
411
|
-
|
411
|
+
|
412
412
|
pixel = thisLine + (minX * pixWidth);
|
413
|
-
|
413
|
+
|
414
414
|
for ( x = minX; x <= maxX; x++ )
|
415
415
|
{
|
416
|
-
|
416
|
+
|
417
417
|
double alpha = alpha_level_for_pixel(op, x, y, blob_id);
|
418
418
|
int r,g,b;
|
419
|
-
|
419
|
+
|
420
420
|
r = (pixel[0]);
|
421
421
|
g = (pixel[1]);
|
422
422
|
b = (pixel[2]);
|
423
|
-
|
424
|
-
|
423
|
+
|
424
|
+
|
425
425
|
if (alpha > 0)
|
426
426
|
{
|
427
|
-
|
427
|
+
|
428
428
|
pixel[0] = col((1-alpha) * r + (alpha * hr));
|
429
429
|
pixel[1] = col((1-alpha) * g + (alpha * hg));
|
430
430
|
pixel[2] = col((1-alpha) * b + (alpha * hb));
|
431
431
|
}
|
432
|
-
|
432
|
+
|
433
433
|
pixel += pixWidth;
|
434
434
|
}
|
435
435
|
}
|
436
|
-
|
436
|
+
|
437
437
|
}
|
438
438
|
|
439
439
|
|
@@ -442,18 +442,18 @@ static void preview_blob(redeyeop_t *op, int blob_id, int colour, gboolean reset
|
|
442
442
|
int y, x;
|
443
443
|
int minX, minY, maxX, maxY;
|
444
444
|
int hr, hg, hb;
|
445
|
-
|
445
|
+
|
446
446
|
redeye_preview(op, reset_preview);
|
447
|
-
|
447
|
+
|
448
448
|
hr = (colour >> 16) & 0xff;
|
449
449
|
hg = (colour >> 8) & 0xff;
|
450
450
|
hb = (colour) & 0xff;
|
451
|
-
|
451
|
+
|
452
452
|
minY = 0;
|
453
453
|
maxY = gdk_pixbuf_get_height(op->preview)-1;
|
454
454
|
minX = 0;
|
455
455
|
maxX = gdk_pixbuf_get_width(op->preview)-1;
|
456
|
-
|
456
|
+
|
457
457
|
guchar *data = gdk_pixbuf_get_pixels(op->preview);
|
458
458
|
int rowstride = gdk_pixbuf_get_rowstride(op->preview);
|
459
459
|
int pixWidth = gdk_pixbuf_get_has_alpha(op->preview) ? 4 : 3;
|
@@ -462,32 +462,32 @@ static void preview_blob(redeyeop_t *op, int blob_id, int colour, gboolean reset
|
|
462
462
|
{
|
463
463
|
guchar *thisLine = data + (rowstride * y);
|
464
464
|
guchar *pixel;
|
465
|
-
|
465
|
+
|
466
466
|
pixel = thisLine + (minX * pixWidth);
|
467
|
-
|
467
|
+
|
468
468
|
for ( x = minX; x <= maxX; x++ )
|
469
469
|
{
|
470
|
-
|
470
|
+
|
471
471
|
double alpha = alpha_level_for_pixel(op, x + op->area.minX, y + op->area.minY, blob_id);
|
472
472
|
int r,g,b;
|
473
|
-
|
473
|
+
|
474
474
|
r = (pixel[0]);
|
475
475
|
g = (pixel[1]);
|
476
476
|
b = (pixel[2]);
|
477
|
-
|
478
|
-
|
477
|
+
|
478
|
+
|
479
479
|
if (alpha > 0)
|
480
480
|
{
|
481
|
-
|
481
|
+
|
482
482
|
pixel[0] = col((1-alpha) * r + (alpha * hr));
|
483
483
|
pixel[1] = col((1-alpha) * g + (alpha * hg));
|
484
484
|
pixel[2] = col((1-alpha) * b + (alpha * hb));
|
485
485
|
}
|
486
|
-
|
486
|
+
|
487
487
|
pixel += pixWidth;
|
488
488
|
}
|
489
489
|
}
|
490
|
-
|
490
|
+
|
491
491
|
}
|
492
492
|
|
493
493
|
%}
|
@@ -507,7 +507,7 @@ class RedEye
|
|
507
507
|
def double:density
|
508
508
|
int noPixels, width, height;
|
509
509
|
double density;
|
510
|
-
|
510
|
+
|
511
511
|
noPixels = <{VALUE>int:rb_struct_getmember(self, rb_intern("noPixels"))}>;
|
512
512
|
width = <{VALUE>int:rb_struct_getmember(self, rb_intern("width"))}>;
|
513
513
|
height = <{VALUE>int:rb_struct_getmember(self, rb_intern("height"))}>;
|
@@ -518,7 +518,7 @@ class RedEye
|
|
518
518
|
def gboolean:squareish?(double min_ratio = 0.5, double min_density = 0.5)
|
519
519
|
int noPixels, width, height;
|
520
520
|
double min, max, ratio, density;
|
521
|
-
|
521
|
+
|
522
522
|
noPixels = <{VALUE>int:rb_struct_getmember(self, rb_intern("noPixels"))}>;
|
523
523
|
width = <{VALUE>int:rb_struct_getmember(self, rb_intern("width"))}>;
|
524
524
|
height = <{VALUE>int:rb_struct_getmember(self, rb_intern("height"))}>;
|
@@ -526,26 +526,26 @@ class RedEye
|
|
526
526
|
min = (double)MIN(width,height);
|
527
527
|
max = (double)MAX(width,height);
|
528
528
|
ratio = (min / max);
|
529
|
-
|
529
|
+
|
530
530
|
density = ((double)noPixels / (double)(width * height));
|
531
531
|
|
532
532
|
return ((ratio >= min_ratio) && (density > min_density));
|
533
533
|
end
|
534
534
|
end
|
535
|
-
|
535
|
+
|
536
536
|
def __alloc__
|
537
537
|
return Data_Wrap_Struct(self, NULL, free_redeye, new_redeye());
|
538
538
|
end
|
539
|
-
|
539
|
+
|
540
540
|
def initialize(GdkPixbuf *pixbuf, int minX, int minY, int maxX, int maxY)
|
541
541
|
redeyeop_t *op;
|
542
|
-
|
542
|
+
|
543
543
|
Data_Get_Struct(self, redeyeop_t, op);
|
544
|
-
|
544
|
+
|
545
545
|
op->pixbuf = pixbuf;
|
546
546
|
op->preview = NULL;
|
547
547
|
g_object_ref(op->pixbuf);
|
548
|
-
|
548
|
+
|
549
549
|
op->area.minX = minX;
|
550
550
|
op->area.maxX = maxX;
|
551
551
|
op->area.minY = minY;
|
@@ -561,25 +561,25 @@ class RedEye
|
|
561
561
|
assert(op->area.minY >= 0);
|
562
562
|
assert(op->area.minY < op->area.maxY);
|
563
563
|
|
564
|
-
|
564
|
+
|
565
565
|
op->mask = ALLOC_N(int, op->area.width * op->area.height);
|
566
|
-
|
566
|
+
|
567
567
|
op->regions.data = ALLOC_N(int, op->area.width * op->area.height);
|
568
|
-
|
568
|
+
|
569
569
|
op->regions.region = ALLOC_N(region_info, NO_REGIONS_DEFAULT);
|
570
570
|
|
571
571
|
op->regions.len = 0;
|
572
572
|
op->regions.size = NO_REGIONS_DEFAULT;
|
573
573
|
end
|
574
|
-
|
574
|
+
|
575
575
|
def identify_blobs(double green_sensitivity=2.0, double blue_sensitivity=0.0, int min_red_val = MIN_RED_VAL)
|
576
576
|
redeyeop_t *op;
|
577
|
-
|
577
|
+
|
578
578
|
Data_Get_Struct(self, redeyeop_t, op);
|
579
579
|
|
580
580
|
MEMZERO(op->mask, int, op->area.width * op->area.height);
|
581
581
|
MEMZERO(op->regions.data, int, op->area.width * op->area.height);
|
582
|
-
|
582
|
+
|
583
583
|
identify_possible_redeye_pixels(op, green_sensitivity, blue_sensitivity, min_red_val);
|
584
584
|
identify_blob_groupings(op);
|
585
585
|
|
@@ -596,54 +596,54 @@ class RedEye
|
|
596
596
|
}
|
597
597
|
return ary;
|
598
598
|
end
|
599
|
-
|
599
|
+
|
600
600
|
def correct_blob(int blob_id)
|
601
601
|
redeyeop_t *op;
|
602
|
-
|
602
|
+
|
603
603
|
Data_Get_Struct(self, redeyeop_t, op);
|
604
|
-
|
604
|
+
|
605
605
|
if (op->regions.len <= blob_id)
|
606
606
|
rb_raise(rb_eIndexError, "Only %i blobs in region - %i is invalid", op->regions.len, blob_id);
|
607
|
-
|
608
|
-
|
607
|
+
|
608
|
+
|
609
609
|
desaturate_blob(op, blob_id);
|
610
610
|
end
|
611
|
-
|
611
|
+
|
612
612
|
def highlight_blob(int blob_id, int col = 0x00ff00)
|
613
613
|
redeyeop_t *op;
|
614
|
-
|
614
|
+
|
615
615
|
Data_Get_Struct(self, redeyeop_t, op);
|
616
|
-
|
616
|
+
|
617
617
|
if (op->regions.len <= blob_id)
|
618
618
|
rb_raise(rb_eIndexError, "Only %i blobs in region - %i is invalid", op->regions.len, blob_id);
|
619
|
-
|
619
|
+
|
620
620
|
highlight_blob(op, blob_id, col);
|
621
621
|
end
|
622
622
|
|
623
623
|
def GdkPixbuf*:preview_blob(int blob_id, int col = 0x00ff00, gboolean reset_preview = TRUE)
|
624
624
|
redeyeop_t *op;
|
625
|
-
|
625
|
+
|
626
626
|
Data_Get_Struct(self, redeyeop_t, op);
|
627
|
-
|
627
|
+
|
628
628
|
if (op->regions.len <= blob_id)
|
629
629
|
rb_raise(rb_eIndexError, "Only %i blobs in region - %i is invalid", op->regions.len, blob_id);
|
630
|
-
|
630
|
+
|
631
631
|
preview_blob(op, blob_id, col, reset_preview);
|
632
|
-
|
632
|
+
|
633
633
|
return op->preview;
|
634
634
|
end
|
635
635
|
def GdkPixbuf*:preview
|
636
636
|
redeyeop_t *op;
|
637
|
-
|
637
|
+
|
638
638
|
Data_Get_Struct(self, redeyeop_t, op);
|
639
|
-
|
639
|
+
|
640
640
|
return redeye_preview(op, FALSE);
|
641
641
|
end
|
642
642
|
def GdkPixbuf*:pixbuf
|
643
643
|
redeyeop_t *op;
|
644
|
-
|
644
|
+
|
645
645
|
Data_Get_Struct(self, redeyeop_t, op);
|
646
|
-
|
646
|
+
|
647
647
|
return op->pixbuf;
|
648
648
|
end
|
649
649
|
end
|
metadata
CHANGED
@@ -1,120 +1,93 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: redeye
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 1.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Geoff Youngs
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
hash: 61
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
- 0
|
31
|
-
- 17
|
11
|
+
date: 2016-01-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubber-generate
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
32
19
|
version: 0.0.17
|
33
20
|
type: :runtime
|
34
|
-
name: rubber-generate
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
21
|
prerelease: false
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.17
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: glib2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
48
33
|
version: 1.1.9
|
49
34
|
type: :runtime
|
50
|
-
name: glib2
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
35
|
prerelease: false
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
hash: 1
|
60
|
-
segments:
|
61
|
-
- 1
|
62
|
-
- 1
|
63
|
-
- 9
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
64
40
|
version: 1.1.9
|
65
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
66
42
|
name: gdk_pixbuf2
|
67
|
-
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.1.9
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.1.9
|
68
55
|
description: |
|
69
56
|
Redeye correction methods for redeye
|
70
|
-
|
71
57
|
email: git@intersect-uk.co.uk
|
72
58
|
executables: []
|
73
|
-
|
74
|
-
extensions:
|
59
|
+
extensions:
|
75
60
|
- ext/redeye/extconf.rb
|
76
61
|
extra_rdoc_files: []
|
77
|
-
|
78
|
-
|
62
|
+
files:
|
63
|
+
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- ext/redeye/extconf.rb
|
79
66
|
- ext/redeye/redeye.c
|
80
67
|
- ext/redeye/redeye.cr
|
81
68
|
- ext/redeye/redeye.rd
|
82
|
-
- Rakefile
|
83
|
-
- README.md
|
84
69
|
- lib/redeye.rb
|
85
|
-
- ext/redeye/extconf.rb
|
86
70
|
homepage: http://github.com/geoffyoungs/redeye
|
87
71
|
licenses: []
|
88
|
-
|
72
|
+
metadata: {}
|
89
73
|
post_install_message:
|
90
74
|
rdoc_options: []
|
91
|
-
|
92
|
-
require_paths:
|
75
|
+
require_paths:
|
93
76
|
- lib
|
94
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
none: false
|
105
|
-
requirements:
|
106
|
-
- - ">="
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
hash: 3
|
109
|
-
segments:
|
110
|
-
- 0
|
111
|
-
version: "0"
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
112
87
|
requirements: []
|
113
|
-
|
114
88
|
rubyforge_project:
|
115
|
-
rubygems_version:
|
89
|
+
rubygems_version: 2.2.1
|
116
90
|
signing_key:
|
117
|
-
specification_version:
|
91
|
+
specification_version: 4
|
118
92
|
summary: Redeye correction for Gdk::Pixbuf
|
119
93
|
test_files: []
|
120
|
-
|