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,38 +0,0 @@
1
- VALUE img_measure_area(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
2
- VALUE img_stats(VALUE);
3
- VALUE img_max(VALUE);
4
- VALUE img_min(VALUE);
5
- VALUE img_avg(VALUE);
6
- VALUE img_deviate(VALUE);
7
- VALUE img_maxpos_avg(VALUE);
8
- VALUE img_maxpos(int, VALUE*, VALUE);
9
- VALUE img_minpos(int, VALUE*, VALUE);
10
- VALUE img_bandmean(VALUE);
11
- VALUE img_add(VALUE, VALUE);
12
- VALUE img_subtract(VALUE, VALUE);
13
- VALUE img_invert(VALUE);
14
- VALUE img_lin(VALUE, VALUE, VALUE);
15
- VALUE img_multiply(VALUE, VALUE);
16
- VALUE img_remainder(int, VALUE*, VALUE);
17
- VALUE img_remainder_binop(VALUE, VALUE);
18
- VALUE img_divide(VALUE, VALUE);
19
- VALUE img_recomb(VALUE, VALUE);
20
- VALUE img_sign(VALUE);
21
- VALUE img_abs(VALUE);
22
- VALUE img_floor(VALUE);
23
- VALUE img_rint(VALUE);
24
- VALUE img_ceil(VALUE);
25
- VALUE img_s_linreg(int, VALUE*, VALUE);
26
- VALUE img_point(VALUE, VALUE, VALUE, VALUE, VALUE);
27
- VALUE img_pow(int, VALUE*, VALUE);
28
- VALUE img_pow_binop(VALUE obj, VALUE arg);
29
- VALUE img_expn(int, VALUE*, VALUE);
30
- VALUE img_log(VALUE);
31
- VALUE img_log10(VALUE);
32
- VALUE img_sin(VALUE);
33
- VALUE img_asin(VALUE);
34
- VALUE img_cos(VALUE);
35
- VALUE img_acos(VALUE);
36
- VALUE img_tan(VALUE);
37
- VALUE img_atan(VALUE);
38
- VALUE img_cross_phase(VALUE, VALUE);
@@ -1,301 +0,0 @@
1
- #include "ruby_vips.h"
2
-
3
- static VALUE
4
- img_and_img(VALUE obj, VALUE obj2)
5
- {
6
- RUBY_VIPS_BINARY(im_andimage);
7
- }
8
-
9
- static VALUE
10
- img_and_const(int argc, VALUE *argv, VALUE obj)
11
- {
12
- int i;
13
- double *c;
14
-
15
- GetImg(obj, data, im);
16
- OutImg(obj, new, data_new, im_new);
17
-
18
- c = IM_ARRAY(im_new, argc, double);
19
- for (i = 0; i < argc; i++)
20
- c[i] = NUM2DBL(argv[i]);
21
-
22
- if (im_andimage_vec(im, im_new, argc, c))
23
- vips_lib_error();
24
-
25
- return new;
26
- }
27
-
28
- /*
29
- * call-seq:
30
- * im & other_image -> image
31
- * im & c -> image
32
- * im & [ c1, ... ] -> image
33
- *
34
- * In the first form, this operation calculates the bitwise and between each
35
- * pixel in this image and <i>other_image</i>. The images must be the same
36
- * size. They may have any format.
37
- *
38
- * If the number of bands differs, one of the images must have one band. In
39
- * this case, an n-band image is formed from the one-band image by joining n
40
- * copies of the one-band image together and then the two n-band images are
41
- * operated upon.
42
- *
43
- * In the second form, it calculates the bitwise and of image pixels with a
44
- * constant. If the image has multiple bands, then the constant is applied to
45
- * all bands.
46
- *
47
- * In the third form, it calculates the bitwise and of image pixels with an
48
- * array of constants. If the image has one band, then the output will have as
49
- * many bands as constants. Otherwise, the number of constants must match the
50
- * number of bands in the image.
51
- */
52
-
53
- VALUE
54
- img_and(int argc, VALUE *argv, VALUE obj)
55
- {
56
- if (argc < 1)
57
- rb_raise(rb_eArgError, "Expected at least one argument");
58
- else if (argc == 1 && CLASS_OF(argv[0]) == cVIPSImage)
59
- return img_and_img(obj, argv[0]);
60
- else
61
- return img_and_const(argc, argv, obj);
62
- }
63
-
64
- VALUE
65
- img_and_binop(VALUE obj, VALUE arg)
66
- {
67
- int argc = 1;
68
- VALUE *argv = &arg;
69
-
70
- if (TYPE(arg) == T_ARRAY) {
71
- argc = RARRAY_LEN(arg);
72
- argv = RARRAY_PTR(arg);
73
- }
74
-
75
- return img_and(argc, argv, obj);
76
- }
77
-
78
- static VALUE
79
- img_or_img(VALUE obj, VALUE obj2)
80
- {
81
- RUBY_VIPS_BINARY(im_orimage);
82
- }
83
-
84
- static VALUE
85
- img_or_const(int argc, VALUE *argv, VALUE obj)
86
- {
87
- int i;
88
- double *c;
89
-
90
- GetImg(obj, data, im);
91
- OutImg(obj, new, data_new, im_new);
92
-
93
- c = IM_ARRAY(im_new, argc, double);
94
- for (i = 0; i < argc; i++)
95
- c[i] = NUM2DBL(argv[i]);
96
-
97
- if (im_orimage_vec(im, im_new, argc, c))
98
- vips_lib_error();
99
-
100
- return new;
101
- }
102
-
103
- /*
104
- * call-seq:
105
- * im | other_image -> image
106
- * im | c -> image
107
- * im | [ c1, ... ] -> image
108
- *
109
- * In the first form, this operation calculates the bitwise or between each
110
- * pixel in this image and <i>other_image</i>. The images must be the same
111
- * size. They may have any format.
112
- *
113
- * If the number of bands differs, one of the images must have one band. In
114
- * this case, an n-band image is formed from the one-band image by joining n
115
- * copies of the one-band image together and then the two n-band images are
116
- * operated upon.
117
- *
118
- * In the second form, it calculates the bitwise or of image pixels with a
119
- * constant. If the image has multiple bands, then the constant is applied to
120
- * all bands.
121
- *
122
- * In the third form, it calculates the bitwise or of image pixels with an
123
- * array of constants. If the image has one band, then the output will have as
124
- * many bands as constants. Otherwise, the number of constants must match the
125
- * number of bands in the image.
126
- */
127
-
128
- VALUE
129
- img_or(int argc, VALUE *argv, VALUE obj)
130
- {
131
- if (argc < 1)
132
- rb_raise(rb_eArgError, "Expected at least one argument");
133
- else if (argc == 1 && CLASS_OF(argv[0]) == cVIPSImage)
134
- return img_or_img(obj, argv[0]);
135
- else
136
- return img_or_const(argc, argv, obj);
137
- }
138
-
139
- VALUE
140
- img_or_binop(VALUE obj, VALUE arg)
141
- {
142
- int argc = 1;
143
- VALUE *argv = &arg;
144
-
145
- if (TYPE(arg) == T_ARRAY) {
146
- argc = RARRAY_LEN(arg);
147
- argv = RARRAY_PTR(arg);
148
- }
149
-
150
- return img_or(argc, argv, obj);
151
- }
152
-
153
- static VALUE
154
- img_xor_img(VALUE obj, VALUE obj2)
155
- {
156
- RUBY_VIPS_BINARY(im_eorimage);
157
- }
158
-
159
- static VALUE
160
- img_xor_const(int argc, VALUE *argv, VALUE obj)
161
- {
162
- int i;
163
- double *c;
164
-
165
- GetImg(obj, data, im);
166
- OutImg(obj, new, data_new, im_new);
167
-
168
- c = IM_ARRAY(im_new, argc, double);
169
- for (i = 0; i < argc; i++)
170
- c[i] = NUM2DBL(argv[i]);
171
-
172
- if (im_eorimage_vec(im, im_new, argc, c))
173
- vips_lib_error();
174
-
175
- return new;
176
- }
177
-
178
- /*
179
- * call-seq:
180
- * im ^ other_image -> image
181
- * im ^ c -> image
182
- * im ^ [ c1, ... ] -> image
183
- *
184
- * In the first form, this operation calculates the bitwise xor between each
185
- * pixel in this image and <i>other_image</i>. The images must be the same
186
- * size. They may have any format.
187
- *
188
- * If the number of bands differs, one of the images must have one band. In
189
- * this case, an n-band image is formed from the one-band image by joining n
190
- * copies of the one-band image together and then the two n-band images are
191
- * operated upon.
192
- *
193
- * In the second form, it calculates the bitwise xor of image pixels with a
194
- * constant. If the image has multiple bands, then the constant is applied to
195
- * all bands.
196
- *
197
- * In the third form, it calculates the bitwise xor of image pixels with an
198
- * array of constants. If the image has one band, then the output will have as
199
- * many bands as constants. Otherwise, the number of constants must match the
200
- * number of bands in the image.
201
- */
202
-
203
-
204
- VALUE
205
- img_xor(int argc, VALUE *argv, VALUE obj)
206
- {
207
- if (argc < 1)
208
- rb_raise(rb_eArgError, "Expected at least one argument");
209
- else if (argc == 1 && CLASS_OF(argv[0]) == cVIPSImage)
210
- return img_xor_img(obj, argv[0]);
211
- else
212
- return img_xor_const(argc, argv, obj);
213
- }
214
-
215
- VALUE
216
- img_xor_binop(VALUE obj, VALUE arg)
217
- {
218
- int argc = 1;
219
- VALUE *argv = &arg;
220
-
221
- if (TYPE(arg) == T_ARRAY) {
222
- argc = RARRAY_LEN(arg);
223
- argv = RARRAY_PTR(arg);
224
- }
225
-
226
- return img_xor(argc, argv, obj);
227
- }
228
-
229
- /*
230
- * call-seq:
231
- * im << c -> image
232
- * im << [ c1, ... ] -> image
233
- *
234
- * Calculates the bitwise left-shift by <i>c</i> bits.
235
- *
236
- * If only one constant is given, it calculates the left-shift for all bands
237
- * in the image. If an array of constants is given, it applies each constant
238
- * to an image band.
239
- */
240
-
241
- VALUE
242
- img_shiftleft(VALUE obj, VALUE arg)
243
- {
244
- double *c;
245
- int i, len = 1;
246
- VALUE *argv = &arg;
247
-
248
- GetImg(obj, data, im);
249
- OutImg(obj, new, data_new, im_new);
250
-
251
- if (TYPE(arg) == T_ARRAY) {
252
- len = RARRAY_LEN(arg);
253
- argv = RARRAY_PTR(arg);
254
- }
255
-
256
- c = IM_ARRAY(im_new, len, double);
257
- for (i = 0; i < len; i++)
258
- c[i] = NUM2DBL(argv[i]);
259
-
260
- if (im_shiftleft_vec(im, im_new, len, c))
261
- vips_lib_error();
262
-
263
- return new;
264
- }
265
-
266
- /*
267
- * call-seq:
268
- * im >> c -> image
269
- * im >> [ c1, ... ] -> image
270
- *
271
- * Calculates the bitwise right-shift by <i>c</i> bits.
272
- *
273
- * If only one constant is given, it calculates the right-shift for all bands
274
- * in the image. If an array of constants is given, it applies each constant
275
- * to an image band.
276
- */
277
-
278
- VALUE
279
- img_shiftright(VALUE obj, VALUE arg)
280
- {
281
- double *c;
282
- int i, len = 1;
283
- VALUE *argv = &arg;
284
-
285
- GetImg(obj, data, im);
286
- OutImg(obj, new, data_new, im_new);
287
-
288
- if (TYPE(arg) == T_ARRAY) {
289
- len = RARRAY_LEN(arg);
290
- argv = RARRAY_PTR(arg);
291
- }
292
-
293
- c = IM_ARRAY(im_new, len, double);
294
- for (i = 0; i < len; i++)
295
- c[i] = NUM2DBL(argv[i]);
296
-
297
- if (im_shiftright_vec(im, im_new, len, c))
298
- vips_lib_error();
299
-
300
- return new;
301
- }
@@ -1,8 +0,0 @@
1
- VALUE img_and(int, VALUE*, VALUE);
2
- VALUE img_and_binop(VALUE, VALUE);
3
- VALUE img_or(int, VALUE*, VALUE);
4
- VALUE img_or_binop(VALUE, VALUE arg);
5
- VALUE img_xor(int, VALUE*, VALUE);
6
- VALUE img_xor_binop(VALUE, VALUE arg);
7
- VALUE img_shiftleft(VALUE obj, VALUE arg);
8
- VALUE img_shiftright(VALUE obj, VALUE arg);
@@ -1,590 +0,0 @@
1
- #include "ruby_vips.h"
2
-
3
- static ID id_perceptual, id_relative_colorimetric, id_saturation,
4
- id_absolute_colorimetric;
5
-
6
- /*
7
- * call-seq:
8
- * im.lab_to_lch -> image
9
- *
10
- * Turn Lab to LCh.
11
- */
12
-
13
- VALUE
14
- img_lab_to_lch(VALUE obj)
15
- {
16
- RUBY_VIPS_UNARY(im_Lab2LCh);
17
- }
18
-
19
- /*
20
- * call-seq:
21
- * im.lch_to_lab -> image
22
- *
23
- * Turn LCh to Lab.
24
- */
25
-
26
- VALUE
27
- img_lch_to_lab(VALUE obj)
28
- {
29
- RUBY_VIPS_UNARY(im_LCh2Lab);
30
- }
31
-
32
- /*
33
- * call-seq:
34
- * im.labq_to_xyz -> image
35
- *
36
- * Turn LabQ to XYZ.
37
- */
38
-
39
- VALUE
40
- img_labq_to_xyz(VALUE obj)
41
- {
42
- RUBY_VIPS_UNARY(im_LabQ2XYZ);
43
- }
44
-
45
- /*
46
- * call-seq:
47
- * im.rad_to_float -> image
48
- *
49
- * Unpack a RAD image to a three-band float image.
50
- */
51
-
52
- VALUE
53
- img_rad_to_float(VALUE obj)
54
- {
55
- RUBY_VIPS_UNARY(im_rad2float);
56
- }
57
-
58
- /*
59
- * call-seq:
60
- * im.float_to_rad -> image
61
- *
62
- * Convert a three-band float image to Radiance 32-bit packed format.
63
- */
64
-
65
- VALUE
66
- img_float_to_rad(VALUE obj)
67
- {
68
- RUBY_VIPS_UNARY(im_float2rad);
69
- }
70
-
71
- /*
72
- * call-seq:
73
- * im.lch_to_ucs -> image
74
- *
75
- * Turn LCh to UCS.
76
- */
77
-
78
- VALUE
79
- img_lch_to_ucs(VALUE obj)
80
- {
81
- RUBY_VIPS_UNARY(im_LCh2UCS);
82
- }
83
-
84
- /*
85
- * call-seq:
86
- * im.lab_to_labq -> image
87
- *
88
- * Turn Lab to LabQ.
89
- */
90
-
91
- VALUE
92
- img_lab_to_labq(VALUE obj)
93
- {
94
- RUBY_VIPS_UNARY(im_Lab2LabQ);
95
- }
96
-
97
- /*
98
- * call-seq:
99
- * im.lab_to_labs -> image
100
- *
101
- * Turn Lab to LabS.
102
- */
103
-
104
- VALUE
105
- img_lab_to_labs(VALUE obj)
106
- {
107
- RUBY_VIPS_UNARY(im_Lab2LabS);
108
- }
109
-
110
- /*
111
- * call-seq:
112
- * im.lab_to_xyz -> image
113
- *
114
- * Turn Lab to XYZ.
115
- */
116
-
117
- VALUE
118
- img_lab_to_xyz(VALUE obj)
119
- {
120
- RUBY_VIPS_UNARY(im_Lab2XYZ);
121
- }
122
-
123
- /*
124
- * call-seq:
125
- * im.lab_to_xyz_temp(x0, y0, z0) -> image
126
- *
127
- * Turn Lab to XYZ. <i>x0</i>, <i>y0</i>, <i>z0</i> give the Lab colour
128
- * temperature.
129
- */
130
-
131
- VALUE
132
- img_lab_to_xyz_temp(VALUE obj, VALUE x0, VALUE y0, VALUE z0)
133
- {
134
- GetImg(obj, data, im);
135
- OutImg(obj, new, data_new, im_new);
136
-
137
- if (im_Lab2XYZ_temp(im, im_new, NUM2DBL(x0), NUM2DBL(y0), NUM2DBL(z0)))
138
- vips_lib_error();
139
-
140
- return new;
141
- }
142
-
143
- /*
144
- * call-seq:
145
- * im.lab_to_ucs -> image
146
- *
147
- * Turn Lab to UCS.
148
- */
149
-
150
- VALUE
151
- img_lab_to_ucs(VALUE obj)
152
- {
153
- RUBY_VIPS_UNARY(im_Lab2UCS);
154
- }
155
-
156
- /*
157
- * call-seq:
158
- * im.labq_to_lab -> image
159
- *
160
- * Turn LabQ to Lab.
161
- */
162
-
163
- VALUE
164
- img_labq_to_lab(VALUE obj)
165
- {
166
- RUBY_VIPS_UNARY(im_LabQ2Lab);
167
- }
168
-
169
- /*
170
- * call-seq:
171
- * im.labq_to_labs -> image
172
- *
173
- * Turn LabQ to LabS.
174
- */
175
-
176
- VALUE
177
- img_labq_to_labs(VALUE obj)
178
- {
179
- RUBY_VIPS_UNARY(im_LabQ2LabS);
180
- }
181
-
182
- /*
183
- * call-seq:
184
- * im.labs_to_labq -> image
185
- *
186
- * Turn LabS to LabQ.
187
- */
188
-
189
- VALUE
190
- img_labs_to_labq(VALUE obj)
191
- {
192
- RUBY_VIPS_UNARY(im_LabS2LabQ);
193
- }
194
-
195
- /*
196
- * call-seq:
197
- * im.labs_to_lab -> image
198
- *
199
- * Turn LabS to Lab.
200
- */
201
-
202
- VALUE
203
- img_labs_to_lab(VALUE obj)
204
- {
205
- RUBY_VIPS_UNARY(im_LabS2Lab);
206
- }
207
-
208
- /*
209
- * call-seq:
210
- * im.ucs_to_xyz -> image
211
- *
212
- * Turn UCS to XYZ.
213
- */
214
-
215
- VALUE
216
- img_ucs_to_xyz(VALUE obj)
217
- {
218
- RUBY_VIPS_UNARY(im_UCS2XYZ);
219
- }
220
-
221
- /*
222
- * call-seq:
223
- * im.ucs_to_lch -> image
224
- *
225
- * Turn UCS to LCh.
226
- */
227
-
228
- VALUE
229
- img_ucs_to_lch(VALUE obj)
230
- {
231
- RUBY_VIPS_UNARY(im_UCS2LCh);
232
- }
233
-
234
- /*
235
- * call-seq:
236
- * im.ucs_to_lab -> image
237
- *
238
- * Turn UCS to Lab.
239
- */
240
-
241
- VALUE
242
- img_ucs_to_lab(VALUE obj)
243
- {
244
- RUBY_VIPS_UNARY(im_UCS2Lab);
245
- }
246
-
247
- /*
248
- * call-seq:
249
- * im.xyz_to_lab -> image
250
- *
251
- * Turn XYZ to Lab.
252
- */
253
-
254
- VALUE
255
- img_xyz_to_lab(VALUE obj)
256
- {
257
- RUBY_VIPS_UNARY(im_XYZ2Lab);
258
- }
259
-
260
- /*
261
- * call-seq:
262
- * im.xyz_to_lab_temp(x0, y0, z0) -> image
263
- *
264
- * Turn XYZ to LAB. <i>x0</i>, <i>y0</i>, <i>z0</i> give the Lab colour
265
- * temperature.
266
- */
267
-
268
- VALUE
269
- img_xyz_to_lab_temp(VALUE obj, VALUE x0, VALUE y0, VALUE z0)
270
- {
271
- GetImg(obj, data, im);
272
- OutImg(obj, new, data_new, im_new);
273
-
274
- if (im_XYZ2Lab_temp(im, im_new, NUM2DBL(x0), NUM2DBL(y0), NUM2DBL(z0)))
275
- vips_lib_error();
276
-
277
- return new;
278
- }
279
-
280
- /*
281
- * call-seq:
282
- * im.xyz_to_ucs -> image
283
- *
284
- * Turn XYZ to UCS.
285
- */
286
-
287
- VALUE
288
- img_xyz_to_ucs(VALUE obj)
289
- {
290
- RUBY_VIPS_UNARY(im_XYZ2UCS);
291
- }
292
-
293
- /*
294
- * call-seq:
295
- * im.srgb_to_xyz -> image
296
- *
297
- * Turn sRGB to XYZ.
298
- */
299
-
300
- VALUE
301
- img_srgb_to_xyz(VALUE obj)
302
- {
303
- RUBY_VIPS_UNARY(im_sRGB2XYZ);
304
- }
305
-
306
- /*
307
- * call-seq:
308
- * im.xyz_to_srgb -> image
309
- *
310
- * Turn XYZ to sRGB.
311
- */
312
-
313
- VALUE
314
- img_xyz_to_srgb(VALUE obj)
315
- {
316
- RUBY_VIPS_UNARY(im_XYZ2sRGB);
317
- }
318
-
319
- /*
320
- * call-seq:
321
- * im.yxy_to_xyz -> image
322
- *
323
- * Turn Yxy to XYZ.
324
- */
325
-
326
- VALUE
327
- img_yxy_to_xyz(VALUE obj)
328
- {
329
- RUBY_VIPS_UNARY(im_Yxy2XYZ);
330
- }
331
-
332
- /*
333
- * call-seq:
334
- * im.xyz_to_yxy -> image
335
- *
336
- * Turn XYZ to Yxy.
337
- */
338
-
339
- VALUE
340
- img_xyz_to_yxy(VALUE obj)
341
- {
342
- RUBY_VIPS_UNARY(im_XYZ2Yxy);
343
- }
344
-
345
- /*
346
- * call-seq:
347
- * im.decmc_from_lab(other_image) -> image
348
- *
349
- * Calculate dE CMC from two Lab images.
350
- */
351
-
352
- VALUE
353
- img_decmc_from_lab(VALUE obj, VALUE obj2)
354
- {
355
- RUBY_VIPS_BINARY(im_dECMC_fromLab);
356
- }
357
-
358
- /*
359
- * call-seq:
360
- * im.de00_from_lab(other_image) -> image
361
- *
362
- * Calculate CIE dE00 from two Lab images.
363
- */
364
-
365
- VALUE
366
- img_de00_from_lab(VALUE obj, VALUE obj2)
367
- {
368
- RUBY_VIPS_BINARY(im_dE00_fromLab);
369
- }
370
-
371
- /*
372
- * call-seq:
373
- * im.de_from_xyz(other_image) -> image
374
- *
375
- * Calculate CIELAB dE 1976 from a pair of XYZ images.
376
- */
377
-
378
- VALUE
379
- img_de_from_xyz(VALUE obj, VALUE obj2)
380
- {
381
- RUBY_VIPS_BINARY(im_dE_fromXYZ);
382
- }
383
-
384
- /*
385
- * call-seq:
386
- * im.de_from_lab(other_image) -> image
387
- *
388
- * Calculate CIE dE 1976 from two Lab images.
389
- */
390
-
391
- VALUE
392
- img_de_from_lab(VALUE obj, VALUE obj2)
393
- {
394
- RUBY_VIPS_BINARY(im_dE_fromLab);
395
- }
396
-
397
- /*
398
- * call-seq:
399
- * im.lab_morph(mask, l_offset, l_scale, a_scale, b_scale) -> image
400
- *
401
- * Morph an image in CIELAB colour space. Useful for certain types of gamut
402
- * mapping, or correction of greyscales on some printers.
403
- *
404
- * We perform three adjustments.
405
- *
406
- * * cast
407
- *
408
- * Pass in <i>mask</i> containing CIELAB readings for a neutral greyscale.
409
- * For example:
410
- *
411
- * mask = [
412
- * [14.23, 4.8 , -3.95],
413
- * [18.74, 2.76, -2.62],
414
- * [23.46, 1.4 , -1.95],
415
- * [27.46, 1.76, -2.01]
416
- * ]
417
- *
418
- * Interpolation from this makes cast corrector. The top and tail are
419
- * interpolated towards [0, 0, 0] and [100, 0, 0], intermediate values are
420
- * interpolated along straight lines fitted between the specified points.
421
- * Rows may be in any order (ie. they need not be sorted on L*).
422
- *
423
- * Each pixel is displaced in a/b by the amount specified for that L in the
424
- * table.
425
- *
426
- * * L*
427
- *
428
- * Pass in <i>l_scale</i> and <i>l_offset</i> for L. L' = (L + offset) *
429
- * scale.
430
- *
431
- * * saturation
432
- *
433
- * scale a and b by these amounts, eg. 1.5 increases saturation.
434
- *
435
- * Find the top two by generating and printing a greyscale. Find the bottom
436
- * by printing a Macbeth and looking at a/b spread
437
- */
438
-
439
- VALUE
440
- img_lab_morph(VALUE obj, VALUE mask, VALUE l_offset, VALUE l_scale,
441
- VALUE a_scale, VALUE b_scale)
442
- {
443
- DOUBLEMASK *dmask;
444
-
445
- GetImg(obj, data, im);
446
- OutImg(obj, new, data_new, im_new);
447
-
448
- mask_arg2mask(mask, NULL, &dmask);
449
-
450
- if( im_lab_morph(im, im_new, dmask, NUM2DBL(l_offset),
451
- NUM2DBL(l_scale), NUM2DBL(a_scale), NUM2DBL(b_scale)) )
452
- vips_lib_error();
453
-
454
- return new;
455
- }
456
-
457
- VipsIntent
458
- img_id_to_intent(ID rb)
459
- {
460
- if (rb == id_perceptual) return IM_INTENT_PERCEPTUAL;
461
- else if (rb == id_relative_colorimetric) return IM_INTENT_RELATIVE_COLORIMETRIC;
462
- else if (rb == id_saturation) return IM_INTENT_SATURATION;
463
- else if (rb == id_absolute_colorimetric) return IM_INTENT_ABSOLUTE_COLORIMETRIC;
464
-
465
- return (VipsIntent)NULL;
466
- }
467
-
468
- /*
469
- * call-seq:
470
- * im.icc_transform(input_filename, output_filename, intent) -> image
471
- *
472
- * Transform an image with the ICC library. The input image is moved to
473
- * profile-connection space with the input profile and then to the output
474
- * space with the output profile.
475
- *
476
- * Use Image#icc_import and Image#icc_export_depth to do either the first or
477
- * second half of this operation in isolation.
478
- */
479
-
480
- VALUE
481
- img_icc_transform(VALUE obj, VALUE input_profile_filename,
482
- VALUE output_profile_filename, VALUE intent)
483
- {
484
- ID id_intent = SYM2ID(intent);
485
- GetImg(obj, data, im);
486
- OutImg(obj, new, data_new, im_new);
487
-
488
- if (im_icc_transform(im, im_new, StringValuePtr(input_profile_filename),
489
- StringValuePtr(output_profile_filename), img_id_to_intent(id_intent)))
490
- vips_lib_error();
491
-
492
- return new;
493
- }
494
-
495
- /*
496
- * call-seq:
497
- * im.icc_import(input_filename, intent) -> image
498
- *
499
- * Import an image with the ICC library. The input image in device space
500
- * is moved to D65 LAB with the input profile.
501
- */
502
-
503
- VALUE
504
- img_icc_import(VALUE obj, VALUE input_profile_filename, VALUE intent)
505
- {
506
- ID id_intent = SYM2ID(intent);
507
- GetImg(obj, data, im);
508
- OutImg(obj, new, data_new, im_new);
509
-
510
- if (im_icc_import(im, im_new, StringValuePtr(input_profile_filename),
511
- img_id_to_intent(id_intent)))
512
- vips_lib_error();
513
-
514
- return new;
515
- }
516
-
517
- /*
518
- * call-seq:
519
- * im.icc_import_embedded(intent) -> image
520
- *
521
- * Import an image with the ICC library. The input image in device space
522
- * is moved to D65 LAB with the input profile from the input image header
523
- * attached.
524
- */
525
-
526
- VALUE
527
- img_icc_import_embedded(VALUE obj, VALUE intent)
528
- {
529
- ID id_intent = SYM2ID(intent);
530
- GetImg(obj, data, im);
531
- OutImg(obj, new, data_new, im_new);
532
-
533
- if (im_icc_import_embedded(im, im_new, img_id_to_intent(id_intent)))
534
- vips_lib_error();
535
-
536
- return new;
537
- }
538
-
539
- /*
540
- * call-seq:
541
- * im.icc_export_depth(depth, output_filename, intent) -> image
542
- *
543
- * Export an image with the ICC library. The input image in
544
- * D65 LAB is transformed to device space using the supplied profile.
545
- * <i>depth</i> can be 8 or 16, for 8 or 16-bit image export.
546
- */
547
-
548
- VALUE
549
- img_icc_export_depth(VALUE obj, VALUE depth, VALUE output_profile_filename,
550
- VALUE intent)
551
- {
552
- ID id_intent = SYM2ID(intent);
553
- GetImg(obj, data, im);
554
- OutImg(obj, new, data_new, im_new);
555
-
556
- if (im_icc_export_depth(im, im_new, NUM2INT(depth),
557
- StringValuePtr(output_profile_filename), img_id_to_intent(id_intent)))
558
- vips_lib_error();
559
-
560
- return new;
561
- }
562
-
563
- /*
564
- * call-seq:
565
- * im.icc_ac2rc(depth, profile_filename) -> image
566
- *
567
- * Transform an image from absolute to relative colorimetry using the
568
- * MediaWhitePoint stored in the ICC profile.
569
- */
570
-
571
- VALUE
572
- img_icc_ac2rc(VALUE obj, VALUE depth, VALUE profile_filename)
573
- {
574
- GetImg(obj, data, im);
575
- OutImg(obj, new, data_new, im_new);
576
-
577
- if (im_icc_ac2rc(im, im_new, StringValuePtr(profile_filename)))
578
- vips_lib_error();
579
-
580
- return new;
581
- }
582
-
583
- void
584
- init_Image_colour()
585
- {
586
- id_perceptual = rb_intern("PERCEPTUAL");
587
- id_relative_colorimetric = rb_intern("COLORIMETRIC");
588
- id_saturation = rb_intern("SATURATION");
589
- id_absolute_colorimetric = rb_intern("ABSOLUTE_COLORIMETRIC");
590
- }