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.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +22 -0
  3. data/CHANGELOG.md +4 -0
  4. data/Gemfile +15 -0
  5. data/Gemfile.lock +46 -31
  6. data/{LICENSE → LICENSE.txt} +1 -1
  7. data/README.md +101 -145
  8. data/Rakefile +45 -0
  9. data/TODO +8 -32
  10. data/VERSION +1 -0
  11. data/example/annotate.rb +17 -0
  12. data/example/daltonize8.rb +75 -0
  13. data/example/example1.rb +84 -0
  14. data/example/example2.rb +31 -0
  15. data/example/example3.rb +19 -0
  16. data/example/example4.rb +18 -0
  17. data/example/example5.rb +31 -0
  18. data/example/trim8.rb +41 -0
  19. data/example/watermark.rb +44 -0
  20. data/example/wobble.rb +36 -0
  21. data/lib/vips.rb +151 -14
  22. data/lib/vips/access.rb +14 -0
  23. data/lib/vips/align.rb +11 -0
  24. data/lib/vips/angle.rb +12 -0
  25. data/lib/vips/angle45.rb +16 -0
  26. data/lib/vips/argument.rb +163 -0
  27. data/lib/vips/bandformat.rb +20 -0
  28. data/lib/vips/call.rb +302 -0
  29. data/lib/vips/coding.rb +14 -0
  30. data/lib/vips/demandstyle.rb +35 -0
  31. data/lib/vips/direction.rb +11 -0
  32. data/lib/vips/error.rb +30 -0
  33. data/lib/vips/extend.rb +22 -0
  34. data/lib/vips/foreignflags.rb +20 -0
  35. data/lib/vips/image.rb +1382 -0
  36. data/lib/vips/interpolate.rb +37 -0
  37. data/lib/vips/interpretation.rb +28 -0
  38. data/lib/vips/methods.rb +1807 -0
  39. data/lib/vips/operation.rb +19 -0
  40. data/ruby-vips8.gemspec +112 -0
  41. data/spec/image_spec.rb +515 -0
  42. data/spec/samples/balloon.v +0 -0
  43. data/spec/samples/ghost.ppm +405 -0
  44. data/spec/samples/huge.jpg +0 -0
  45. data/spec/samples/icc.jpg +0 -0
  46. data/spec/samples/lcd.icc +0 -0
  47. data/spec/samples/lion.svg +154 -0
  48. data/spec/samples/sample.csv +7 -0
  49. data/spec/samples/sample.exr +0 -0
  50. data/spec/samples/wagon.jpg +0 -0
  51. data/spec/samples/wagon.v +0 -0
  52. data/spec/spec_helper.rb +49 -0
  53. data/spec/vips_spec.rb +74 -0
  54. metadata +110 -70
  55. data/ext/extconf.rb +0 -31
  56. data/ext/header.c +0 -457
  57. data/ext/header.h +0 -9
  58. data/ext/image.c +0 -629
  59. data/ext/image.h +0 -72
  60. data/ext/image_arithmetic.c +0 -936
  61. data/ext/image_arithmetic.h +0 -38
  62. data/ext/image_boolean.c +0 -301
  63. data/ext/image_boolean.h +0 -8
  64. data/ext/image_colour.c +0 -590
  65. data/ext/image_colour.h +0 -36
  66. data/ext/image_conversion.c +0 -884
  67. data/ext/image_conversion.h +0 -38
  68. data/ext/image_convolution.c +0 -368
  69. data/ext/image_convolution.h +0 -13
  70. data/ext/image_freq_filt.c +0 -740
  71. data/ext/image_freq_filt.h +0 -27
  72. data/ext/image_histograms_lut.c +0 -643
  73. data/ext/image_histograms_lut.h +0 -28
  74. data/ext/image_morphology.c +0 -327
  75. data/ext/image_morphology.h +0 -13
  76. data/ext/image_mosaicing.c +0 -554
  77. data/ext/image_mosaicing.h +0 -15
  78. data/ext/image_relational.c +0 -384
  79. data/ext/image_relational.h +0 -8
  80. data/ext/image_resample.c +0 -249
  81. data/ext/image_resample.h +0 -9
  82. data/ext/interpolator.c +0 -106
  83. data/ext/interpolator.h +0 -7
  84. data/ext/mask.c +0 -347
  85. data/ext/mask.h +0 -18
  86. data/ext/reader.c +0 -261
  87. data/ext/reader.h +0 -2
  88. data/ext/ruby_vips.c +0 -188
  89. data/ext/ruby_vips.h +0 -72
  90. data/ext/tags +0 -450
  91. data/ext/writer.c +0 -371
  92. data/ext/writer.h +0 -2
  93. data/lib/vips/reader.rb +0 -272
  94. data/lib/vips/version.rb +0 -3
  95. data/lib/vips/writer.rb +0 -342
  96. data/ruby-vips.gemspec +0 -100
  97. data/ruby.supp +0 -134
@@ -1,27 +0,0 @@
1
- VALUE img_fwfft(VALUE);
2
- VALUE img_invfft(VALUE);
3
- VALUE img_rotquad(VALUE);
4
- VALUE img_invfftr(VALUE);
5
- VALUE img_s_fmask_ideal_highpass(VALUE, VALUE, VALUE, VALUE);
6
- VALUE img_s_fmask_ideal_lowpass(VALUE, VALUE, VALUE, VALUE);
7
- VALUE img_s_fmask_butterworth_highpass(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
8
- VALUE img_s_fmask_butterworth_lowpass(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
9
- VALUE img_s_fmask_gauss_highpass(VALUE, VALUE, VALUE, VALUE, VALUE);
10
- VALUE img_s_fmask_gauss_lowpass(VALUE, VALUE, VALUE, VALUE, VALUE);
11
- VALUE img_s_fmask_ideal_ringpass(VALUE, VALUE, VALUE, VALUE, VALUE);
12
- VALUE img_s_fmask_ideal_ringreject(VALUE, VALUE, VALUE, VALUE, VALUE);
13
- VALUE img_s_fmask_butterworth_ringpass(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
14
- VALUE img_s_fmask_butterworth_ringreject(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
15
- VALUE img_s_fmask_gauss_ringpass(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
16
- VALUE img_s_fmask_gauss_ringreject(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
17
- VALUE img_s_fmask_ideal_bandpass(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
18
- VALUE img_s_fmask_ideal_bandreject(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
19
- VALUE img_s_fmask_butterworth_bandpass(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
20
- VALUE img_s_fmask_butterworth_bandreject(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
21
- VALUE img_s_fmask_gauss_bandpass(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
22
- VALUE img_s_fmask_gauss_bandreject(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
23
- VALUE img_s_fmask_fractal_flt(VALUE, VALUE, VALUE, VALUE);
24
- VALUE img_freqflt(VALUE, VALUE);
25
- VALUE img_disp_ps(VALUE);
26
- VALUE img_phasecor_fft(VALUE, VALUE);
27
- VALUE img_s_fractsurf(VALUE, VALUE, VALUE);
@@ -1,643 +0,0 @@
1
- #include "ruby_vips.h"
2
-
3
- /*
4
- * call-seq:
5
- * im.histgr([band]) -> image
6
- *
7
- * Find the histogram of *self*. If <i>band</i> is given, find the histogram
8
- * for that band (producing a one-band histogram). If <i>band</i> is not given,
9
- * find the histogram for all bands (producing an n-band histogram).
10
- *
11
- * *self* must be u8 or u16. The output image is always u32.
12
- */
13
-
14
- VALUE
15
- img_histgr(int argc, VALUE *argv, VALUE obj)
16
- {
17
- VALUE v_bandno;
18
- int bandno;
19
- GetImg(obj, data, im);
20
- OutImg(obj, new, data_new, im_new);
21
-
22
- rb_scan_args(argc, argv, "01", &v_bandno);
23
- bandno = NIL_P(v_bandno) ? -1 : NUM2INT(v_bandno);
24
-
25
- if (im_histgr(im, im_new, bandno))
26
- vips_lib_error();
27
-
28
- return new;
29
- }
30
-
31
- /*
32
- * call-seq:
33
- * im.histnd(bins) -> image
34
- *
35
- * Make a one, two or three dimensional histogram of a 1, 2 or 3 band image.
36
- * Divide each axis into a certain number of bins .. ie. output is 1 x bins,
37
- * bins x bins, or bins x bins x bins bands. uchar and ushort only.
38
- */
39
-
40
- VALUE
41
- img_histnd(VALUE obj, VALUE bins)
42
- {
43
- GetImg(obj, data, im);
44
- OutImg(obj, new, data_new, im_new);
45
-
46
- if (im_histnD(im, im_new, NUM2INT(bins)))
47
- vips_lib_error();
48
-
49
- return new;
50
- }
51
-
52
- /*
53
- * call-seq:
54
- * im.hist_indexed(other_image) -> image
55
- *
56
- * Make a histogram of <i>other_image</i>, but use *self* to pick the bins. In
57
- * other words, element zero in the output image contains the sum of all the
58
- * pixels in <i>other_image</i> whose corresponding pixel in *self* is zero.
59
- *
60
- * *self* must have just one band and be u8 or u16. <i>other_image</i> must be
61
- * non-complex. The output image always has the same size and format as
62
- * <i>other_image</i>.
63
- *
64
- * This operation is useful in conjunction with Image#label_regions. You can
65
- * use it to find the centre of gravity of blobs in an image, for example.
66
- */
67
-
68
- VALUE
69
- img_hist_indexed(VALUE obj, VALUE obj2)
70
- {
71
- RUBY_VIPS_BINARY(im_hist_indexed);
72
- }
73
-
74
- /*
75
- * call-seq:
76
- * Image.identity(bands) -> image
77
- *
78
- * Creates a image file with Xsize=256, Ysize=1, Bands=<i>bands</i>,
79
- * BandFmt= :UCHAR, Type=:HISTOGRAM.
80
- *
81
- * The created image consist of a <i>bands</i>-bands linear lut and is the
82
- * basis for building up look-up tables.
83
- */
84
-
85
- VALUE
86
- img_s_identity(VALUE obj, VALUE bands)
87
- {
88
- OutPartial(new, data, im);
89
-
90
- if (im_identity(im, NUM2INT(bands)))
91
- vips_lib_error();
92
-
93
- return new;
94
- }
95
-
96
- /*
97
- * call-seq:
98
- * Image.identity_ushort(size) -> image
99
- *
100
- * As Image.identity, but make a ushort LUT. ushort LUTs can be up to 65536
101
- * elements - <i>size</i> is the number of elements required.
102
- *
103
- * The created image consist of a <i>bands</i>-bands linear lut and is the
104
- * basis for building up look-up tables.
105
- */
106
-
107
- VALUE
108
- img_s_identity_ushort(VALUE obj, VALUE bands, VALUE sz)
109
- {
110
- OutPartial(new, data, im);
111
-
112
- if (im_identity_ushort(im, NUM2INT(bands), NUM2INT(sz)))
113
- vips_lib_error();
114
-
115
- return new;
116
- }
117
-
118
- /*
119
- * call-seq:
120
- * Image.invertlut(input, lut_size) -> image
121
- *
122
- * Given a <i>input</i> of target values and real values, generate a LUT which
123
- * will map reals to targets. Handy for linearising images from measurements of
124
- * a colour chart. All values in [0,1]. Piecewise linear interpolation,
125
- * extrapolate head and tail to 0 and 1.
126
- *
127
- * Eg. input like this:
128
- *
129
- * input = [
130
- * [0.2, 0.2, 0.3, 0.1],
131
- * [0.2, 0.4, 0.4, 0.2],
132
- * [0.7, 0.5, 0.6, 0.3]
133
- * ]
134
- *
135
- * Means a patch with 10% reflectance produces an image with 20% in channel 1,
136
- * 30% in channel 2, and 10% in channel 3, and so on.
137
- *
138
- * Inputs don't need to be sorted (we do that). Generate any precision LUT,
139
- * typically you might ask for 256 elements.
140
- *
141
- * It won't work too well for non-monotonic camera responses.
142
- *
143
- * <i>input</i> can be an array or a Mask object.
144
- */
145
-
146
- VALUE
147
- img_s_invertlut(VALUE obj, VALUE input, VALUE lut_size)
148
- {
149
- DOUBLEMASK *dmask;
150
- OutPartial(new, data, im);
151
-
152
- mask_arg2mask(input, NULL, &dmask);
153
-
154
- if (im_invertlut(dmask, im, NUM2INT(lut_size)))
155
- vips_lib_error();
156
-
157
- return new;
158
- }
159
-
160
- /*
161
- * call-seq:
162
- * Image.buildlut(input) -> image
163
- *
164
- * This operation builds a lookup table from a set of points. Intermediate
165
- * values are generated by piecewise linear interpolation.
166
- *
167
- * For example, consider this 2 x 2 matrix of (x, y) coordinates:
168
- *
169
- * input = [
170
- * [ 0, 0],
171
- * [255, 100]
172
- * ]
173
- * im = Image.invertlut(input)
174
- *
175
- * We then generate an image with the following pixel values:
176
- *
177
- * im[0, 0] # => 0
178
- * im[0, 1] # => 0.4
179
- * # ...
180
- * im[0, 255] # => 100
181
- *
182
- * This is then written as the output image, with the left column giving the
183
- * index in the image to place the value.
184
- *
185
- * The (x, y) points don't need to be sorted: we do that. You can have several
186
- * Ys, each becomes a band in the output LUT. You don't need to start at zero,
187
- * any integer will do, including negatives.
188
- */
189
-
190
- VALUE
191
- img_s_buildlut(VALUE obj, VALUE input)
192
- {
193
- DOUBLEMASK *dmask;
194
- OutPartial(new, data, im);
195
-
196
- mask_arg2mask(input, NULL, &dmask);
197
-
198
- if (im_buildlut(dmask, im))
199
- vips_lib_error();
200
-
201
- return new;
202
- }
203
-
204
- /*
205
- * call-seq:
206
- * im.project -> image
207
- *
208
- * Find the horizontal and vertical projections of an image, ie. the sum
209
- * of every row of pixels, and the sum of every column of pixels. The output
210
- * format is uint, int or double, depending on the input format.
211
- *
212
- * Non-complex images only.
213
- */
214
-
215
- VALUE
216
- img_project(VALUE obj)
217
- {
218
- GetImg(obj, data, im);
219
- OutImg(obj, new, data_new, im_new);
220
- OutImg(obj, new2, data_new2, im_new2);
221
-
222
- if (im_project(im, im_new, im_new2))
223
- vips_lib_error();
224
-
225
- return rb_ary_new3(2, new, new2);
226
- }
227
-
228
- /*
229
- * call-seq:
230
- * im.histnorm -> image
231
- *
232
- * Normalise histogram ... normalise range to make it square (ie. max ==
233
- * number of elements). Normalise each band separately.
234
- */
235
-
236
- VALUE
237
- img_histnorm(VALUE obj)
238
- {
239
- RUBY_VIPS_UNARY(im_histnorm);
240
- }
241
-
242
- /*
243
- * call-seq:
244
- * im.histcum -> image
245
- *
246
- * Form cumulative histogram.
247
- */
248
-
249
- VALUE
250
- img_histcum(VALUE obj)
251
- {
252
- RUBY_VIPS_UNARY(im_histcum);
253
- }
254
-
255
- /*
256
- * call-seq:
257
- * im.histeq -> image
258
- *
259
- * Histogram equalisation: normalised cumulative histogram.
260
- */
261
-
262
- VALUE
263
- img_histeq(VALUE obj)
264
- {
265
- RUBY_VIPS_UNARY(im_histeq);
266
- }
267
-
268
- /*
269
- * call-seq:
270
- * im.histspec(other_image) -> image
271
- *
272
- * Creates a lut which, when applied to the image from which histogram *self*
273
- * was formed, will produce an image whose PDF matches that of the image from
274
- * which <i>other_image</i> was formed.
275
- */
276
-
277
- VALUE
278
- img_histspec(VALUE obj, VALUE obj2)
279
- {
280
- RUBY_VIPS_BINARY(im_histspec);
281
- }
282
-
283
- /*
284
- * call-seq:
285
- * im.maplut(lut) -> image
286
- *
287
- * Map an image through another image acting as a LUT (Look Up Table).
288
- * The lut may have any type, and the output image will be that type.
289
- *
290
- * The input image will be cast to one of the unsigned integer types, that is,
291
- * band format :UCHAR, :USHORT or :UINT.
292
- *
293
- * If <i>lut</i> is too small for the input type (for example, if *self* is
294
- * band format :UCHAR but <i>lut</i> only has 100 elements), the lut is padded
295
- * out by copying the last element. Overflows are reported at the end of
296
- * computation.
297
- *
298
- * If <i>lut</i> is too large, extra values are ignored.
299
- *
300
- * If <i>lut</i> has one band, then all bands of *self* pass through it. If
301
- * <i>lut</i> has same number of bands as *self*, then each band is mapped
302
- * separately. If *self* has one band, then @lut may have many bands and the
303
- * output will have the same number of bands as <i>lut</i>.
304
- */
305
-
306
- VALUE
307
- img_maplut(VALUE obj, VALUE obj2)
308
- {
309
- GetImg(obj, data, im);
310
- GetImg(obj2, data2, im2);
311
- OutImg2(obj, obj2, new, data_new, im_new);
312
-
313
- if (im_maplut(im, im_new, im2))
314
- vips_lib_error();
315
-
316
- return new;
317
- }
318
-
319
- /*
320
- * call-seq:
321
- * im.histplot -> image
322
- *
323
- * Plot a 1 by any or any by 1 image as a max by any or any by max image using
324
- * these rules:
325
- *
326
- * * unsigned char max is always 256
327
- * * other unsigned integer types output 0 - maxium value of *self*.
328
- * * signed int types - min moved to 0, max moved to max + min.
329
- * * float types - min moved to 0, max moved to any (square output).
330
- */
331
-
332
- VALUE
333
- img_histplot(VALUE obj)
334
- {
335
- RUBY_VIPS_UNARY(im_histplot);
336
- }
337
-
338
- /*
339
- * call-seq:
340
- * im.monotonic? -> true or false
341
- *
342
- * Test *self* for monotonicity. Returns true if *self* is monotonic.
343
- */
344
-
345
- VALUE
346
- img_monotonic_p(VALUE obj)
347
- {
348
- int ret;
349
- GetImg(obj, data, im);
350
-
351
- if( im_ismonotonic(im, &ret) )
352
- vips_lib_error();
353
-
354
- return( ret == 0 ? Qfalse : Qtrue );
355
- }
356
-
357
- /*
358
- * call-seq:
359
- * im.hist([band])
360
- *
361
- * Find and plot the histogram of *self*. If <i>band</i> is not given, plot all
362
- * bands. Otherwise plot the specified band.
363
- */
364
-
365
- VALUE
366
- img_hist(int argc, VALUE *argv, VALUE obj)
367
- {
368
- VALUE v_bandno;
369
- int bandno;
370
- GetImg(obj, data, im);
371
- OutImg(obj, new, data_new, im_new);
372
-
373
- rb_scan_args(argc, argv, "01", &v_bandno);
374
- bandno = NIL_P(v_bandno) ? -1 : NUM2INT(v_bandno);
375
-
376
- if (im_hist(im, im_new, bandno))
377
- vips_lib_error();
378
-
379
- return new;
380
- }
381
-
382
- /*
383
- * call-seq:
384
- * im.hsp(other_image) -> image
385
- *
386
- * Maps *self* to the output image,, adjusting the histogram to match image
387
- * <i>other_image</i>.
388
- *
389
- * Both images should have the same number of bands.
390
- */
391
-
392
- VALUE
393
- img_hsp(VALUE obj, VALUE obj2)
394
- {
395
- RUBY_VIPS_BINARY(im_hsp);
396
- }
397
-
398
- /*
399
- * call-seq:
400
- * im.gammacorrect(exponent) -> image
401
- *
402
- * Gamma-correct an 8- or 16-bit unsigned image with a lookup table. The
403
- * output format is the same as the input format.
404
- */
405
-
406
- VALUE
407
- img_gammacorrect(VALUE obj, VALUE exponent)
408
- {
409
- GetImg(obj, data, im);
410
- OutImg(obj, new, data_new, im_new);
411
-
412
- if (im_gammacorrect(im, im_new, NUM2DBL(exponent)))
413
- vips_lib_error();
414
-
415
- return new;
416
- }
417
-
418
- /*
419
- * call-seq:
420
- * im.mpercent_hist(percent) -> number
421
- *
422
- * Just like Image#mpercent, except it works on an image histogram. Handy if
423
- * you want to run Image#mpercent several times without having to recompute the
424
- * histogram each time.
425
- */
426
-
427
- VALUE
428
- img_mpercent_hist(VALUE obj, VALUE percent)
429
- {
430
- #if ATLEAST_VIPS( 7, 22 )
431
- int ret;
432
- GetImg(obj, data, im);
433
-
434
- if (im_mpercent_hist(im, NUM2DBL(percent), &ret))
435
- vips_lib_error();
436
-
437
- return INT2NUM(ret);
438
- #else
439
- rb_raise(eVIPSError, "This operation is not supported by your version of VIPS");
440
- #endif
441
- }
442
-
443
- /*
444
- * call-seq:
445
- * im.mpercent(percent) -> number
446
- *
447
- * Returns the threshold above which there are <i>percent</i> values of *self*.
448
- * If for example percent=.1, the number of pels of the input image with values
449
- * greater than the returned int will correspond to 10% of all pels of the
450
- * image.
451
- *
452
- * The function works for uchar and ushort images only. It can be used to
453
- * threshold the scaled result of a filtering operation.
454
- */
455
-
456
- VALUE
457
- img_mpercent(VALUE obj, VALUE percent)
458
- {
459
- int ret;
460
- GetImg(obj, data, im);
461
-
462
- if (im_mpercent(im, NUM2DBL(percent), &ret))
463
- vips_lib_error();
464
-
465
- return INT2NUM(ret);
466
- }
467
-
468
- /*
469
- * call-seq:
470
- * im.heq([band]) -> image
471
- *
472
- * Histogram-equalise *self*. Equalise using band <i>band</i>, or if not given,
473
- * equalise all bands.
474
- */
475
-
476
- VALUE
477
- img_heq(int argc, VALUE *argv, VALUE obj)
478
- {
479
- VALUE v_bandno;
480
- int bandno;
481
- GetImg(obj, data, im);
482
- OutImg(obj, new, data_new, im_new);
483
-
484
- rb_scan_args(argc, argv, "01", &v_bandno);
485
- bandno = NIL_P(v_bandno) ? -1 : NUM2INT(v_bandno);
486
-
487
- if (im_heq(im, im_new, bandno))
488
- vips_lib_error();
489
-
490
- return new;
491
- }
492
-
493
- /*
494
- * call-seq:
495
- * im.lhisteq(xwin, ywin) -> image
496
- *
497
- * Performs local histogram equalisation on *self* using a window of size
498
- * <i>xwin</i> by <i>ywin</i> centered on the input pixel. Works only on
499
- * monochrome images.
500
- *
501
- * The output image is the same size as the input image. The edge pixels are
502
- * created by copy edge pixels of the input image outwards.
503
- */
504
-
505
- VALUE
506
- img_lhisteq(VALUE obj, VALUE xwin, VALUE ywin)
507
- {
508
- GetImg(obj, data, im);
509
- OutImg(obj, new, data_new, im_new);
510
-
511
- if (im_lhisteq(im, im_new, NUM2INT(xwin), NUM2INT(ywin)))
512
- vips_lib_error();
513
-
514
- return new;
515
- }
516
-
517
- /*
518
- * call-seq:
519
- * im.stdif(a, m0, b, s, xwin, ywin) -> image
520
- *
521
- * Preforms statistical differencing according to the formula given in page 45
522
- * of the book "An Introduction to Digital Image Processing" by Wayne Niblack.
523
- * This transformation emphasises the way in which a pel differs statistically
524
- * from its neighbours. It is useful for enhancing low-contrast images with
525
- * lots of detail, such as X-ray plates.
526
- *
527
- * At point (i,j) the output is given by the equation:
528
- *
529
- * vout(i,j) = a * m0 + (1 - a) * meanv +
530
- * (vin(i,j) - meanv) * (b * s0) / (s0 + b * stdv)
531
- *
532
- * Values <i>a</i>, <i>m0</i>, <i>b</i> and <i>s0</i> are entered, while meanv
533
- * and stdv are the values calculated over a moving window of size <i>xwin</i>,
534
- * <i>ywin</i> centred on pixel (i,j).
535
- *
536
- * <i>m0</i> is the new mean, <i>a</i> is the weight given to it. <i>s0</i> is
537
- * the new standard deviation, <i>b</i> is the weight given to it.
538
- *
539
- * Try:
540
- *
541
- * im.stdif(0.5, 128, 0.5, 50, 11, 11)
542
- *
543
- * The operation works on one-band uchar images only, and writes a one-band
544
- * uchar image as its result. The output image has the same size as the
545
- * input.
546
- */
547
-
548
- VALUE
549
- img_stdif(VALUE obj,
550
- VALUE a, VALUE m0, VALUE b, VALUE s0, VALUE xwin, VALUE ywin)
551
- {
552
- GetImg(obj, data, im);
553
- OutImg(obj, new, data_new, im_new);
554
-
555
- if (im_stdif(im, im_new,
556
- NUM2DBL(a), NUM2DBL(m0), NUM2DBL(b), NUM2DBL(s0),
557
- NUM2INT(xwin), NUM2INT(ywin)))
558
- vips_lib_error();
559
-
560
- return new;
561
- }
562
-
563
- /*
564
- * call-seq:
565
- * Image.tone_build_range(in_max, out_max, lb, lw, ps, pm, ph, s, m, h) -> image
566
- *
567
- * Generates a tone curve for the adjustment of image levels. It is mostly
568
- * designed for adjusting the L* part of a LAB image in way suitable for print
569
- * work, but you can use it for other things too.
570
- *
571
- * The curve is an unsigned 16-bit image with (<i>in_max</i> + 1) entries, each
572
- * in the range [0, <i>out_max</i>].
573
- *
574
- * <i>lb</i>, <i>lw</i> are expressed as 0-100, as in LAB colour space. You
575
- * specify the scaling for the input and output images with the <i>in_max</i>
576
- * and <i>out_max</i> parameters.
577
- */
578
-
579
- VALUE
580
- img_s_tone_build_range(VALUE obj,
581
- VALUE in_max, VALUE out_max,
582
- VALUE lb, VALUE lw, VALUE ps, VALUE pm, VALUE ph, VALUE s, VALUE m, VALUE h)
583
- {
584
- OutPartial(new, data, im);
585
-
586
- if (im_tone_build_range(im,
587
- NUM2DBL(in_max), NUM2DBL(out_max),
588
- NUM2DBL(lb), NUM2DBL(lw), NUM2DBL(ps), NUM2DBL(pm), NUM2DBL(ph),
589
- NUM2DBL(s), NUM2DBL(m), NUM2DBL(h)))
590
- vips_lib_error();
591
-
592
- return new;
593
- }
594
-
595
- /*
596
- * call-seq:
597
- * Image.tone_build(lb, lw, ps, pm, ph, s, m, h) -> image
598
- *
599
- * As Image#tone_build_range, but set 32767 and 32767 as values for
600
- * <i>in_max</i> and <i>out_max</i>. This makes a curve suitable for correcting
601
- * LABS images, the most common case.
602
- */
603
-
604
- VALUE
605
- img_s_tone_build(VALUE obj,
606
- VALUE lb, VALUE lw, VALUE ps, VALUE pm, VALUE ph, VALUE s, VALUE m, VALUE h)
607
- {
608
- OutPartial(new, data, im);
609
-
610
- if (im_tone_build(im,
611
- NUM2DBL(lb), NUM2DBL(lw), NUM2DBL(ps), NUM2DBL(pm), NUM2DBL(ph),
612
- NUM2DBL(s), NUM2DBL(m), NUM2DBL(h)))
613
- vips_lib_error();
614
-
615
- return new;
616
- }
617
-
618
- /*
619
- * call-seq:
620
- * im.tone_analyse(ps, pm, ph, s, m, h) -> image
621
- *
622
- * As Image#tone_build, but analyse the histogram of *self* and use it to pick
623
- * the 0.1% and 99.9% points for <i>lb</i> and <i>lw</i>.
624
- */
625
-
626
- VALUE
627
- img_tone_analyse(VALUE obj,
628
- VALUE ps, VALUE pm, VALUE ph, VALUE s, VALUE m, VALUE h)
629
- {
630
- #if ATLEAST_VIPS( 7, 23 )
631
- GetImg(obj, data, im);
632
- OutImg(obj, new, data_new, im_new);
633
-
634
- if (im_tone_analyse(im, im_new,
635
- NUM2DBL(ps), NUM2DBL(pm), NUM2DBL(ph),
636
- NUM2DBL(s), NUM2DBL(m), NUM2DBL(h)) )
637
- vips_lib_error();
638
-
639
- return new;
640
- #else
641
- rb_raise(eVIPSError, "This operation is not supported by your version of VIPS");
642
- #endif
643
- }