ruby-vips 0.3.14 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +22 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +46 -31
- data/{LICENSE → LICENSE.txt} +1 -1
- data/README.md +101 -145
- data/Rakefile +45 -0
- data/TODO +8 -32
- data/VERSION +1 -0
- data/example/annotate.rb +17 -0
- data/example/daltonize8.rb +75 -0
- data/example/example1.rb +84 -0
- data/example/example2.rb +31 -0
- data/example/example3.rb +19 -0
- data/example/example4.rb +18 -0
- data/example/example5.rb +31 -0
- data/example/trim8.rb +41 -0
- data/example/watermark.rb +44 -0
- data/example/wobble.rb +36 -0
- data/lib/vips.rb +151 -14
- data/lib/vips/access.rb +14 -0
- data/lib/vips/align.rb +11 -0
- data/lib/vips/angle.rb +12 -0
- data/lib/vips/angle45.rb +16 -0
- data/lib/vips/argument.rb +163 -0
- data/lib/vips/bandformat.rb +20 -0
- data/lib/vips/call.rb +302 -0
- data/lib/vips/coding.rb +14 -0
- data/lib/vips/demandstyle.rb +35 -0
- data/lib/vips/direction.rb +11 -0
- data/lib/vips/error.rb +30 -0
- data/lib/vips/extend.rb +22 -0
- data/lib/vips/foreignflags.rb +20 -0
- data/lib/vips/image.rb +1382 -0
- data/lib/vips/interpolate.rb +37 -0
- data/lib/vips/interpretation.rb +28 -0
- data/lib/vips/methods.rb +1807 -0
- data/lib/vips/operation.rb +19 -0
- data/ruby-vips8.gemspec +112 -0
- data/spec/image_spec.rb +515 -0
- data/spec/samples/balloon.v +0 -0
- data/spec/samples/ghost.ppm +405 -0
- data/spec/samples/huge.jpg +0 -0
- data/spec/samples/icc.jpg +0 -0
- data/spec/samples/lcd.icc +0 -0
- data/spec/samples/lion.svg +154 -0
- data/spec/samples/sample.csv +7 -0
- data/spec/samples/sample.exr +0 -0
- data/spec/samples/wagon.jpg +0 -0
- data/spec/samples/wagon.v +0 -0
- data/spec/spec_helper.rb +49 -0
- data/spec/vips_spec.rb +74 -0
- metadata +110 -70
- data/ext/extconf.rb +0 -31
- data/ext/header.c +0 -457
- data/ext/header.h +0 -9
- data/ext/image.c +0 -629
- data/ext/image.h +0 -72
- data/ext/image_arithmetic.c +0 -936
- data/ext/image_arithmetic.h +0 -38
- data/ext/image_boolean.c +0 -301
- data/ext/image_boolean.h +0 -8
- data/ext/image_colour.c +0 -590
- data/ext/image_colour.h +0 -36
- data/ext/image_conversion.c +0 -884
- data/ext/image_conversion.h +0 -38
- data/ext/image_convolution.c +0 -368
- data/ext/image_convolution.h +0 -13
- data/ext/image_freq_filt.c +0 -740
- data/ext/image_freq_filt.h +0 -27
- data/ext/image_histograms_lut.c +0 -643
- data/ext/image_histograms_lut.h +0 -28
- data/ext/image_morphology.c +0 -327
- data/ext/image_morphology.h +0 -13
- data/ext/image_mosaicing.c +0 -554
- data/ext/image_mosaicing.h +0 -15
- data/ext/image_relational.c +0 -384
- data/ext/image_relational.h +0 -8
- data/ext/image_resample.c +0 -249
- data/ext/image_resample.h +0 -9
- data/ext/interpolator.c +0 -106
- data/ext/interpolator.h +0 -7
- data/ext/mask.c +0 -347
- data/ext/mask.h +0 -18
- data/ext/reader.c +0 -261
- data/ext/reader.h +0 -2
- data/ext/ruby_vips.c +0 -188
- data/ext/ruby_vips.h +0 -72
- data/ext/tags +0 -450
- data/ext/writer.c +0 -371
- data/ext/writer.h +0 -2
- data/lib/vips/reader.rb +0 -272
- data/lib/vips/version.rb +0 -3
- data/lib/vips/writer.rb +0 -342
- data/ruby-vips.gemspec +0 -100
- data/ruby.supp +0 -134
data/ext/image_mosaicing.h
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
VALUE img_lrmerge(int, VALUE*, VALUE);
|
2
|
-
VALUE img_tbmerge(int, VALUE*, VALUE);
|
3
|
-
VALUE img_lrmerge1(int, VALUE*, VALUE);
|
4
|
-
VALUE img_tbmerge1(int, VALUE*, VALUE);
|
5
|
-
VALUE img_lrmosaic(int, VALUE*, VALUE);
|
6
|
-
VALUE img_tbmosaic(int, VALUE*, VALUE);
|
7
|
-
VALUE img_lrmosaic1(int, VALUE*, VALUE);
|
8
|
-
VALUE img_tbmosaic1(int, VALUE*, VALUE);
|
9
|
-
VALUE img_global_balance(VALUE, VALUE);
|
10
|
-
VALUE img_global_balancef(VALUE, VALUE);
|
11
|
-
VALUE img_correl(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
12
|
-
VALUE img_remosaic(VALUE, VALUE, VALUE);
|
13
|
-
VALUE img_align_bands(VALUE);
|
14
|
-
VALUE img_maxpos_subpel(VALUE);
|
15
|
-
void init_Image_mosaicing(void);
|
data/ext/image_relational.c
DELETED
@@ -1,384 +0,0 @@
|
|
1
|
-
#include "ruby_vips.h"
|
2
|
-
|
3
|
-
static VALUE
|
4
|
-
img_equal_const(int argc, VALUE *argv, VALUE obj)
|
5
|
-
{
|
6
|
-
double *c;
|
7
|
-
int i;
|
8
|
-
GetImg(obj, data, im);
|
9
|
-
OutImg(obj, new, data_new, im_new);
|
10
|
-
|
11
|
-
c = IM_ARRAY(im_new, argc, double);
|
12
|
-
|
13
|
-
for(i = 0; i < argc; i++)
|
14
|
-
c[i] = NUM2DBL(argv[i]);
|
15
|
-
|
16
|
-
if (im_equal_vec(im, im_new, argc, c))
|
17
|
-
vips_lib_error();
|
18
|
-
|
19
|
-
return new;
|
20
|
-
}
|
21
|
-
|
22
|
-
static VALUE
|
23
|
-
img_equal_img(VALUE obj, VALUE obj2)
|
24
|
-
{
|
25
|
-
RUBY_VIPS_BINARY(im_equal);
|
26
|
-
}
|
27
|
-
|
28
|
-
/*
|
29
|
-
* call-seq:
|
30
|
-
* im.equal(other_image) -> image
|
31
|
-
* im.equal(constant, ...) -> image
|
32
|
-
*
|
33
|
-
* In the first form, this operation calculates *self* == <i>other_image</i>
|
34
|
-
* (image element equals image element) and writes the result to the output
|
35
|
-
* image.
|
36
|
-
*
|
37
|
-
* In the second form, this operation calculates *self* == <i>constant</i>
|
38
|
-
* (image element equals constant array) and writes the result to the output
|
39
|
-
* image.
|
40
|
-
*/
|
41
|
-
|
42
|
-
VALUE
|
43
|
-
img_equal(int argc, VALUE *argv, VALUE obj)
|
44
|
-
{
|
45
|
-
if (argc < 1)
|
46
|
-
rb_raise(rb_eArgError, "Need at least one argument.");
|
47
|
-
|
48
|
-
if (TYPE(argv[0]) == T_FLOAT || TYPE(argv[0]) == T_FIXNUM)
|
49
|
-
return img_equal_const(argc, argv, obj);
|
50
|
-
else if (argc != 1)
|
51
|
-
rb_raise(rb_eArgError, "Need constants or one image.");
|
52
|
-
|
53
|
-
return img_equal_img(obj, argv[0]);
|
54
|
-
}
|
55
|
-
|
56
|
-
static VALUE
|
57
|
-
img_notequal_const(int argc, VALUE *argv, VALUE obj)
|
58
|
-
{
|
59
|
-
double *c;
|
60
|
-
int i;
|
61
|
-
GetImg(obj, data, im);
|
62
|
-
OutImg(obj, new, data_new, im_new);
|
63
|
-
|
64
|
-
c = IM_ARRAY(im_new, argc, double);
|
65
|
-
|
66
|
-
for(i = 0; i < argc; i++)
|
67
|
-
c[i] = NUM2DBL(argv[i]);
|
68
|
-
|
69
|
-
if (im_notequal_vec(im, im_new, argc, c))
|
70
|
-
vips_lib_error();
|
71
|
-
|
72
|
-
return new;
|
73
|
-
}
|
74
|
-
|
75
|
-
static VALUE
|
76
|
-
img_notequal_img(VALUE obj, VALUE obj2)
|
77
|
-
{
|
78
|
-
RUBY_VIPS_BINARY(im_notequal);
|
79
|
-
}
|
80
|
-
|
81
|
-
/*
|
82
|
-
* call-seq:
|
83
|
-
* im.notequal(other_image) -> image
|
84
|
-
* im.notequal(constant, ...) -> image
|
85
|
-
*
|
86
|
-
* In the first form, this operation calculates *self* != <i>other_image</i>
|
87
|
-
* (image element equals image element) and writes the result to the output
|
88
|
-
* image.
|
89
|
-
*
|
90
|
-
* In the second form, this operation calculates *self* != <i>constant</i>
|
91
|
-
* (image element equals constant array) and writes the result to the output
|
92
|
-
* image.
|
93
|
-
*/
|
94
|
-
|
95
|
-
VALUE
|
96
|
-
img_notequal(int argc, VALUE *argv, VALUE obj)
|
97
|
-
{
|
98
|
-
if (argc < 1)
|
99
|
-
rb_raise(rb_eArgError, "Need at least one argument.");
|
100
|
-
|
101
|
-
if (TYPE(argv[0]) == T_FLOAT || TYPE(argv[0]) == T_FIXNUM)
|
102
|
-
return img_notequal_const(argc, argv, obj);
|
103
|
-
else if (argc != 1)
|
104
|
-
rb_raise(rb_eArgError, "Need constants or one image.");
|
105
|
-
|
106
|
-
return img_notequal_img(obj, argv[0]);
|
107
|
-
}
|
108
|
-
|
109
|
-
static VALUE
|
110
|
-
img_less_const(int argc, VALUE *argv, VALUE obj)
|
111
|
-
{
|
112
|
-
double *c;
|
113
|
-
int i;
|
114
|
-
GetImg(obj, data, im);
|
115
|
-
OutImg(obj, new, data_new, im_new);
|
116
|
-
|
117
|
-
c = IM_ARRAY(im_new, argc, double);
|
118
|
-
|
119
|
-
for(i = 0; i < argc; i++)
|
120
|
-
c[i] = NUM2DBL(argv[i]);
|
121
|
-
|
122
|
-
if (im_less_vec(im, im_new, argc, c))
|
123
|
-
vips_lib_error();
|
124
|
-
|
125
|
-
return new;
|
126
|
-
}
|
127
|
-
|
128
|
-
static VALUE
|
129
|
-
img_less_img(VALUE obj, VALUE obj2)
|
130
|
-
{
|
131
|
-
RUBY_VIPS_BINARY(im_less);
|
132
|
-
}
|
133
|
-
|
134
|
-
/*
|
135
|
-
* call-seq:
|
136
|
-
* im.less(other_image) -> image
|
137
|
-
* im.less(constant, ...) -> image
|
138
|
-
*
|
139
|
-
* In the first form, this operation calculates *self* < <i>other_image</i>
|
140
|
-
* (image element equals image element) and writes the result to the output
|
141
|
-
* image.
|
142
|
-
*
|
143
|
-
* In the second form, this operation calculates *self* < <i>constant</i>
|
144
|
-
* (image element equals constant array) and writes the result to the output
|
145
|
-
* image.
|
146
|
-
*/
|
147
|
-
|
148
|
-
VALUE
|
149
|
-
img_less(int argc, VALUE *argv, VALUE obj)
|
150
|
-
{
|
151
|
-
if (argc < 1)
|
152
|
-
rb_raise(rb_eArgError, "Need at least one argument.");
|
153
|
-
|
154
|
-
if (TYPE(argv[0]) == T_FLOAT || TYPE(argv[0]) == T_FIXNUM)
|
155
|
-
return img_less_const(argc, argv, obj);
|
156
|
-
else if (argc != 1)
|
157
|
-
rb_raise(rb_eArgError, "Need constants or one image.");
|
158
|
-
|
159
|
-
return img_less_img(obj, argv[0]);
|
160
|
-
}
|
161
|
-
|
162
|
-
static VALUE
|
163
|
-
img_lesseq_const(int argc, VALUE *argv, VALUE obj)
|
164
|
-
{
|
165
|
-
double *c;
|
166
|
-
int i;
|
167
|
-
GetImg(obj, data, im);
|
168
|
-
OutImg(obj, new, data_new, im_new);
|
169
|
-
|
170
|
-
c = IM_ARRAY(im_new, argc, double);
|
171
|
-
|
172
|
-
for(i = 0; i < argc; i++)
|
173
|
-
c[i] = NUM2DBL(argv[i]);
|
174
|
-
|
175
|
-
if (im_lesseq_vec(im, im_new, argc, c))
|
176
|
-
vips_lib_error();
|
177
|
-
|
178
|
-
return new;
|
179
|
-
}
|
180
|
-
|
181
|
-
static VALUE
|
182
|
-
img_lesseq_img(VALUE obj, VALUE obj2)
|
183
|
-
{
|
184
|
-
RUBY_VIPS_BINARY(im_lesseq);
|
185
|
-
}
|
186
|
-
|
187
|
-
/*
|
188
|
-
* call-seq:
|
189
|
-
* im.lesseq(other_image) -> image
|
190
|
-
* im.lesseq(constant, ...) -> image
|
191
|
-
*
|
192
|
-
* In the first form, this operation calculates *self* <= <i>other_image</i>
|
193
|
-
* (image element equals image element) and writes the result to the output
|
194
|
-
* image.
|
195
|
-
*
|
196
|
-
* In the second form, this operation calculates *self* <= <i>constant</i>
|
197
|
-
* (image element equals constant array) and writes the result to the output
|
198
|
-
* image.
|
199
|
-
*/
|
200
|
-
|
201
|
-
VALUE
|
202
|
-
img_lesseq(int argc, VALUE *argv, VALUE obj)
|
203
|
-
{
|
204
|
-
if (argc < 1)
|
205
|
-
rb_raise(rb_eArgError, "Need at least one argument.");
|
206
|
-
|
207
|
-
if (TYPE(argv[0]) == T_FLOAT || TYPE(argv[0]) == T_FIXNUM)
|
208
|
-
return img_lesseq_const(argc, argv, obj);
|
209
|
-
else if (argc != 1)
|
210
|
-
rb_raise(rb_eArgError, "Need constants or one image.");
|
211
|
-
|
212
|
-
return img_lesseq_img(obj, argv[0]);
|
213
|
-
}
|
214
|
-
|
215
|
-
static VALUE
|
216
|
-
img_more_const(int argc, VALUE *argv, VALUE obj)
|
217
|
-
{
|
218
|
-
double *c;
|
219
|
-
int i;
|
220
|
-
GetImg(obj, data, im);
|
221
|
-
OutImg(obj, new, data_new, im_new);
|
222
|
-
|
223
|
-
c = IM_ARRAY(im_new, argc, double);
|
224
|
-
|
225
|
-
for(i = 0; i < argc; i++)
|
226
|
-
c[i] = NUM2DBL(argv[i]);
|
227
|
-
|
228
|
-
if (im_more_vec(im, im_new, argc, c))
|
229
|
-
vips_lib_error();
|
230
|
-
|
231
|
-
return new;
|
232
|
-
}
|
233
|
-
|
234
|
-
static VALUE
|
235
|
-
img_more_img(VALUE obj, VALUE obj2)
|
236
|
-
{
|
237
|
-
RUBY_VIPS_BINARY(im_more);
|
238
|
-
}
|
239
|
-
|
240
|
-
/*
|
241
|
-
* call-seq:
|
242
|
-
* im.more(other_image) -> image
|
243
|
-
* im.more(constant, ...) -> image
|
244
|
-
*
|
245
|
-
* In the first form, this operation calculates *self* > <i>other_image</i>
|
246
|
-
* (image element equals image element) and writes the result to the output
|
247
|
-
* image.
|
248
|
-
*
|
249
|
-
* In the second form, this operation calculates *self* > <i>constant</i>
|
250
|
-
* (image element equals constant array) and writes the result to the output
|
251
|
-
* image.
|
252
|
-
*/
|
253
|
-
|
254
|
-
VALUE
|
255
|
-
img_more(int argc, VALUE *argv, VALUE obj)
|
256
|
-
{
|
257
|
-
if (argc < 1)
|
258
|
-
rb_raise(rb_eArgError, "Need at least one argument.");
|
259
|
-
|
260
|
-
if (TYPE(argv[0]) == T_FLOAT || TYPE(argv[0]) == T_FIXNUM)
|
261
|
-
return img_more_const(argc, argv, obj);
|
262
|
-
else if (argc != 1)
|
263
|
-
rb_raise(rb_eArgError, "Need constants or one image.");
|
264
|
-
|
265
|
-
return img_more_img(obj, argv[0]);
|
266
|
-
}
|
267
|
-
|
268
|
-
static VALUE
|
269
|
-
img_moreeq_const(int argc, VALUE *argv, VALUE obj)
|
270
|
-
{
|
271
|
-
double *c;
|
272
|
-
int i;
|
273
|
-
GetImg(obj, data, im);
|
274
|
-
OutImg(obj, new, data_new, im_new);
|
275
|
-
|
276
|
-
c = IM_ARRAY(im_new, argc, double);
|
277
|
-
|
278
|
-
for(i = 0; i < argc; i++)
|
279
|
-
c[i] = NUM2DBL(argv[i]);
|
280
|
-
|
281
|
-
if (im_moreeq_vec(im, im_new, argc, c))
|
282
|
-
vips_lib_error();
|
283
|
-
|
284
|
-
return new;
|
285
|
-
}
|
286
|
-
|
287
|
-
static VALUE
|
288
|
-
img_moreeq_img(VALUE obj, VALUE obj2)
|
289
|
-
{
|
290
|
-
RUBY_VIPS_BINARY(im_moreeq);
|
291
|
-
}
|
292
|
-
|
293
|
-
/*
|
294
|
-
* call-seq:
|
295
|
-
* im.moreeq(other_image) -> image
|
296
|
-
* im.moreeq(constant, ...) -> image
|
297
|
-
*
|
298
|
-
* In the first form, this operation calculates *self* >= <i>other_image</i>
|
299
|
-
* (image element equals image element) and writes the result to the output
|
300
|
-
* image.
|
301
|
-
*
|
302
|
-
* In the second form, this operation calculates *self* >= <i>constant</i>
|
303
|
-
* (image element equals constant array) and writes the result to the output
|
304
|
-
* image.
|
305
|
-
*/
|
306
|
-
|
307
|
-
VALUE
|
308
|
-
img_moreeq(int argc, VALUE *argv, VALUE obj)
|
309
|
-
{
|
310
|
-
if (argc < 1)
|
311
|
-
rb_raise(rb_eArgError, "Need at least one argument.");
|
312
|
-
|
313
|
-
if (TYPE(argv[0]) == T_FLOAT || TYPE(argv[0]) == T_FIXNUM)
|
314
|
-
return img_moreeq_const(argc, argv, obj);
|
315
|
-
else if (argc != 1)
|
316
|
-
rb_raise(rb_eArgError, "Need constants or one image.");
|
317
|
-
|
318
|
-
return img_moreeq_img(obj, argv[0]);
|
319
|
-
}
|
320
|
-
|
321
|
-
/*
|
322
|
-
* call-seq:
|
323
|
-
* im.ifthenelse(a_image, b_image) -> image
|
324
|
-
*
|
325
|
-
* This operation scans the condition image *self* and uses it to select pixels
|
326
|
-
* from either the then image <i>a_image</i> or the else image <i>b_image</i>.
|
327
|
-
* Non-zero means <i>a_image</i>, 0 means <i>b_image</i>.
|
328
|
-
*
|
329
|
-
* Any image can have either 1 band or n bands, where n is the same for all
|
330
|
-
* the non-1-band images. Single band images are then effectively copied to
|
331
|
-
* make n-band images.
|
332
|
-
*
|
333
|
-
* Images <i>a_image</i> and <i>b_image</i> are cast up to the smallest common
|
334
|
-
* format.
|
335
|
-
*
|
336
|
-
* Images <i>a_image</i> and <i>b_image</i> must match exactly in size.
|
337
|
-
*/
|
338
|
-
|
339
|
-
VALUE
|
340
|
-
img_ifthenelse(VALUE obj, VALUE obj2, VALUE obj3)
|
341
|
-
{
|
342
|
-
GetImg(obj, data, im);
|
343
|
-
GetImg(obj2, data2, im2);
|
344
|
-
GetImg(obj3, data3, im3);
|
345
|
-
OutImg3(obj, obj2, obj3, new, data_new, im_new);
|
346
|
-
|
347
|
-
if (im_ifthenelse(im, im2, im3, im_new))
|
348
|
-
vips_lib_error();
|
349
|
-
|
350
|
-
return new;
|
351
|
-
}
|
352
|
-
|
353
|
-
/*
|
354
|
-
* call-seq:
|
355
|
-
* im.blend(a_image, b_image) -> image
|
356
|
-
*
|
357
|
-
* This operation scans the condition image *self* (which must be unsigned
|
358
|
-
* char) and uses it to blend pixels from either the then image <i>a_image</i>
|
359
|
-
* or the else image <i>b_image</i>. 255 means <i>a_image</i> only, 0 means
|
360
|
-
* <i>b_image</i> only, and intermediate values are a mixture.
|
361
|
-
*
|
362
|
-
* Any image can have either 1 band or n bands, where n is the same for all
|
363
|
-
* the non-1-band images. Single band images are then effectively copied to
|
364
|
-
* make n-band images.
|
365
|
-
*
|
366
|
-
* Images <i>a_image</i> and <i>b_image</i> are cast up to the smallest common
|
367
|
-
* format.
|
368
|
-
*
|
369
|
-
* Images <i>a_image</i> and <i>b_image</i> must match exactly in size.
|
370
|
-
*/
|
371
|
-
|
372
|
-
VALUE
|
373
|
-
img_blend(VALUE obj, VALUE obj2, VALUE obj3)
|
374
|
-
{
|
375
|
-
GetImg(obj, data, im);
|
376
|
-
GetImg(obj2, data2, im2);
|
377
|
-
GetImg(obj3, data3, im3);
|
378
|
-
OutImg3(obj, obj2, obj3, new, data_new, im_new);
|
379
|
-
|
380
|
-
if (im_blend(im, im2, im3, im_new))
|
381
|
-
vips_lib_error();
|
382
|
-
|
383
|
-
return new;
|
384
|
-
}
|
data/ext/image_relational.h
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
VALUE img_equal(int , VALUE*, VALUE);
|
2
|
-
VALUE img_notequal(int , VALUE*, VALUE);
|
3
|
-
VALUE img_less(int , VALUE*, VALUE);
|
4
|
-
VALUE img_lesseq(int , VALUE*, VALUE);
|
5
|
-
VALUE img_more(int , VALUE*, VALUE);
|
6
|
-
VALUE img_moreeq(int , VALUE*, VALUE);
|
7
|
-
VALUE img_ifthenelse(VALUE , VALUE , VALUE);
|
8
|
-
VALUE img_blend(VALUE , VALUE , VALUE);
|
data/ext/image_resample.c
DELETED
@@ -1,249 +0,0 @@
|
|
1
|
-
#include "ruby_vips.h"
|
2
|
-
|
3
|
-
/*
|
4
|
-
* call-seq:
|
5
|
-
* im.affinei(interpolator, a, b, c, d, dx, dy) -> image
|
6
|
-
* im.affinei(interpolator, a, b, c, d, dx, dy, ox, oy, ow, oh) -> image
|
7
|
-
*
|
8
|
-
* Applies an affine transformation on *self*. *self* many have any number of
|
9
|
-
* bands, be any size, and have any non-complex type.
|
10
|
-
*
|
11
|
-
* The transformation is described by <i>a</i>, <i>b</i>, <i>c</i>, <i>d</i>,
|
12
|
-
* <i>dx</i>, <i>dy</i>. The point (x,y) in
|
13
|
-
* the input is mapped onto point (X,Y) in the output by
|
14
|
-
*
|
15
|
-
* X = a * x + b * y + dx
|
16
|
-
* Y = c * x + d * y + dy
|
17
|
-
*
|
18
|
-
* In the first form, the entire image is transformed. In the second form, the
|
19
|
-
* area of the output image given by <i>ow</i>, <i>oh</i>, <i>ox</i>, <i>oy</i>
|
20
|
-
* is generated. (0,0) is the position of the transformed top-left-hand corner
|
21
|
-
* of the input image.
|
22
|
-
*
|
23
|
-
* Points are generated using the supplied interpolator.
|
24
|
-
*/
|
25
|
-
|
26
|
-
VALUE
|
27
|
-
img_affinei(int argc, VALUE *argv, VALUE obj)
|
28
|
-
{
|
29
|
-
VALUE interpolator, a, b, c, d, dx, dy, ox, oy, ow, oh;
|
30
|
-
VipsInterpolate *itrp_vips;
|
31
|
-
|
32
|
-
rb_scan_args(argc, argv, "74", &interpolator, &a, &b, &c, &d, &dx, &dy, &ox,
|
33
|
-
&oy, &ow, &oh);
|
34
|
-
|
35
|
-
itrp_vips = interp_lookup(interpolator);
|
36
|
-
GetImg(obj, data, im);
|
37
|
-
OutImg(obj, new, data_new, im_new);
|
38
|
-
|
39
|
-
if (NIL_P(ox)) {
|
40
|
-
if (im_affinei_all(im, im_new, itrp_vips,
|
41
|
-
NUM2DBL(a), NUM2DBL(b), NUM2DBL(c), NUM2DBL(d),
|
42
|
-
NUM2DBL(dx), NUM2DBL(dy)))
|
43
|
-
vips_lib_error();
|
44
|
-
} else {
|
45
|
-
if (NIL_P(oh))
|
46
|
-
rb_raise(rb_eArgError, "If you supply any output parameters, you have to supply them all");
|
47
|
-
|
48
|
-
if (im_affinei(im, im_new, itrp_vips,
|
49
|
-
NUM2DBL(a), NUM2DBL(b), NUM2DBL(c), NUM2DBL(d),
|
50
|
-
NUM2DBL(dx), NUM2DBL(dy),
|
51
|
-
NUM2INT(ox), NUM2INT(oy), NUM2INT(ow), NUM2INT(oh)))
|
52
|
-
vips_lib_error();
|
53
|
-
}
|
54
|
-
|
55
|
-
return new;
|
56
|
-
}
|
57
|
-
|
58
|
-
/*
|
59
|
-
* call-seq:
|
60
|
-
* im.affinei_resize(interpolator, x [,y]) -> image
|
61
|
-
*
|
62
|
-
* Applies an affine resize using the supplied interpolator. If <i>y</i> is
|
63
|
-
* ommitted then the aspect ratio of *self* will be maintained.
|
64
|
-
*/
|
65
|
-
|
66
|
-
VALUE
|
67
|
-
img_affinei_resize(int argc, VALUE *argv, VALUE obj)
|
68
|
-
{
|
69
|
-
VALUE interpolator, x_scale, y_scale;
|
70
|
-
VipsInterpolate *itrp_vips;
|
71
|
-
|
72
|
-
rb_scan_args(argc, argv, "21", &interpolator, &x_scale, &y_scale);
|
73
|
-
|
74
|
-
GetImg(obj, data, im);
|
75
|
-
OutImg(obj, new, data_new, im_new);
|
76
|
-
|
77
|
-
itrp_vips = interp_lookup(interpolator);
|
78
|
-
|
79
|
-
if (NIL_P(y_scale))
|
80
|
-
y_scale = x_scale;
|
81
|
-
|
82
|
-
if (im_affinei_all(im, im_new, itrp_vips, NUM2DBL(x_scale), 0, 0,
|
83
|
-
NUM2DBL(y_scale), 0, 0))
|
84
|
-
vips_lib_error();
|
85
|
-
|
86
|
-
return new;
|
87
|
-
}
|
88
|
-
|
89
|
-
/*
|
90
|
-
* call-seq:
|
91
|
-
* im.stretch3(dx [,dy]) -> image
|
92
|
-
*
|
93
|
-
* Stretches the input image by 3% horizontally, and displaces it by
|
94
|
-
* <i>dx</i>/<i>dy</i>. It uses bi-cubic interpolation, but runs quickly. It
|
95
|
-
* works only for unsigned short images.
|
96
|
-
*
|
97
|
-
* This function is part of the MARC acquisition software, but is generally
|
98
|
-
* useful for squaring up the pixels in images from the Kontron ProgRes camera
|
99
|
-
* range.
|
100
|
-
*/
|
101
|
-
|
102
|
-
VALUE
|
103
|
-
img_stretch3(int argc, VALUE *argv, VALUE obj)
|
104
|
-
{
|
105
|
-
VALUE dx, dy;
|
106
|
-
|
107
|
-
rb_scan_args(argc, argv, "11", &dx, &dy);
|
108
|
-
if (NIL_P(dy))
|
109
|
-
dy = dx;
|
110
|
-
|
111
|
-
GetImg(obj, data, im);
|
112
|
-
OutImg(obj, new, data_new, im_new);
|
113
|
-
|
114
|
-
if (im_stretch3(im, im_new, NUM2DBL(dx), NUM2DBL(dy)))
|
115
|
-
vips_lib_error();
|
116
|
-
|
117
|
-
return new;
|
118
|
-
}
|
119
|
-
|
120
|
-
/*
|
121
|
-
* call-seq:
|
122
|
-
* im.shrink(width_ratio [,height_ratio]) -> image
|
123
|
-
*
|
124
|
-
* Shrink *self* by <i>width_ratio</i> along the horizontal and
|
125
|
-
* <i>height_ratio</i> along the vertical direction. If <i>height_ratio</i> is
|
126
|
-
* not given, it uses <i>width_ratio</i>. The function does not perform
|
127
|
-
* subpixel interpolation and therefore the resultant image can present
|
128
|
-
* aliasing especially for small x and y factors. Any size image, any
|
129
|
-
* non-complex type, any number of bands.
|
130
|
-
*/
|
131
|
-
|
132
|
-
VALUE
|
133
|
-
img_shrink(int argc, VALUE *argv, VALUE obj)
|
134
|
-
{
|
135
|
-
VALUE width_ratio, height_ratio;
|
136
|
-
|
137
|
-
rb_scan_args(argc, argv, "11", &width_ratio, &height_ratio);
|
138
|
-
if (NIL_P(height_ratio))
|
139
|
-
height_ratio = width_ratio;
|
140
|
-
|
141
|
-
GetImg(obj, data, im);
|
142
|
-
OutImg(obj, new, data_new, im_new);
|
143
|
-
|
144
|
-
if (im_shrink(im, im_new, NUM2DBL(width_ratio), NUM2DBL(height_ratio)))
|
145
|
-
vips_lib_error();
|
146
|
-
|
147
|
-
return new;
|
148
|
-
}
|
149
|
-
|
150
|
-
/*
|
151
|
-
* call-seq:
|
152
|
-
* im.rightshift_size(xshift, yshift, fmt) -> image
|
153
|
-
*
|
154
|
-
* Decreases the size of an integer type image by a power-of-two factor, very
|
155
|
-
* quickly, by summing the values of adjacent pixels. The sum is shifted to
|
156
|
-
* produce output of the specified band format.
|
157
|
-
*
|
158
|
-
* <i>xshift</i> and <i>yshift</i> are positive and give the base-two
|
159
|
-
* logarithms of the scale factors.
|
160
|
-
*
|
161
|
-
* If the input image is a signed type, then the band format must be one of
|
162
|
-
* :CHAR, :SHORT or :INT. If it is an unsigned type, then the band format must
|
163
|
-
* be one of :UCHAR, :USHORT or :UINT.
|
164
|
-
*/
|
165
|
-
|
166
|
-
VALUE
|
167
|
-
img_rightshift_size(VALUE obj, VALUE xshift, VALUE yshift, VALUE fmt)
|
168
|
-
{
|
169
|
-
GetImg(obj, data, im);
|
170
|
-
OutImg(obj, new, data_new, im_new);
|
171
|
-
|
172
|
-
if(im_rightshift_size(im, im_new, NUM2DBL(xshift), NUM2DBL(yshift),
|
173
|
-
header_id_to_band_fmt(SYM2ID(fmt))))
|
174
|
-
vips_lib_error();
|
175
|
-
|
176
|
-
return new;
|
177
|
-
}
|
178
|
-
|
179
|
-
|
180
|
-
/*
|
181
|
-
* call-seq:
|
182
|
-
* im.match_linear(other_image, xr1, yr1, xs1, ys1, xr2, yr2, xs2,
|
183
|
-
* ys2) -> image
|
184
|
-
*
|
185
|
-
* Works exactly as Image#match_linear_search, but does not attempt to
|
186
|
-
* correlate to correct your tie points. It can thus be used for any angle and
|
187
|
-
* any scale, but you must be far more careful in your selection.
|
188
|
-
*/
|
189
|
-
|
190
|
-
VALUE
|
191
|
-
img_match_linear(VALUE obj, VALUE obj2,
|
192
|
-
VALUE xr1, VALUE yr1, VALUE xs1, VALUE ys1,
|
193
|
-
VALUE xr2, VALUE yr2, VALUE xs2, VALUE ys2)
|
194
|
-
{
|
195
|
-
GetImg(obj, data, im);
|
196
|
-
GetImg(obj2, data2, im2);
|
197
|
-
OutImg(obj, new, data_new, im_new);
|
198
|
-
|
199
|
-
if (im_match_linear(im, im2, im_new,
|
200
|
-
NUM2INT(xr1), NUM2INT(yr1), NUM2INT(xs1), NUM2INT(ys1),
|
201
|
-
NUM2INT(xr2), NUM2INT(yr2), NUM2INT(xs2), NUM2INT(ys2)))
|
202
|
-
vips_lib_error();
|
203
|
-
|
204
|
-
return new;
|
205
|
-
}
|
206
|
-
|
207
|
-
/*
|
208
|
-
* call-seq:
|
209
|
-
* im.match_linear_search(other_image, xr1, yr1, xs1, ys1, xr2, yr2, xs2,
|
210
|
-
* ys2, hwindowsize, hsearchsize) -> image
|
211
|
-
*
|
212
|
-
* Attempts to transform sec to make it match ref. The transformation is
|
213
|
-
* linear, that is, it only involves scale, rotate and translate.
|
214
|
-
*
|
215
|
-
* Requires a pair of tie points to fix the parameters of its transformation.
|
216
|
-
* You should pick points as far apart as possible to increase accuracy. It
|
217
|
-
* will search the area in the image around each tie point for a good fit, so
|
218
|
-
* your selection of points need not be exact. WARNING! This searching process
|
219
|
-
* will fail for rotations of more than about 10 degrees or for scales of more
|
220
|
-
* than about 10 percent.
|
221
|
-
*
|
222
|
-
* The best you can hope for is < 1 pixel error, since the command does not
|
223
|
-
* attempt sub-pixel correlation.
|
224
|
-
*
|
225
|
-
* <i>hwindowsize</i> and <i>hsearchsize</i> set the size of the area to be
|
226
|
-
* searched: we recommend values of 5 and 14.
|
227
|
-
*
|
228
|
-
* The output image is positioned and clipped so that you can immediately
|
229
|
-
* subtract it from orig to obtain pixel difference images.
|
230
|
-
*/
|
231
|
-
|
232
|
-
VALUE
|
233
|
-
img_match_linear_search(VALUE obj, VALUE obj2,
|
234
|
-
VALUE xr1, VALUE yr1, VALUE xs1, VALUE ys1,
|
235
|
-
VALUE xr2, VALUE yr2, VALUE xs2, VALUE ys2,
|
236
|
-
VALUE hwindowsize, VALUE hsearchsize)
|
237
|
-
{
|
238
|
-
GetImg(obj, data, im);
|
239
|
-
GetImg(obj2, data2, im2);
|
240
|
-
OutImg(obj, new, data_new, im_new);
|
241
|
-
|
242
|
-
if (im_match_linear_search(im, im2, im_new,
|
243
|
-
NUM2INT(xr1), NUM2INT(yr1), NUM2INT(xs1), NUM2INT(ys1),
|
244
|
-
NUM2INT(xr2), NUM2INT(yr2), NUM2INT(xs2), NUM2INT(ys2),
|
245
|
-
NUM2INT(hwindowsize), NUM2INT(hsearchsize)))
|
246
|
-
vips_lib_error();
|
247
|
-
|
248
|
-
return new;
|
249
|
-
}
|