![]() |
![]() |
![]() |
VIPS Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
#include <vips/vips.h> enum VipsPrecision; int vips_conv (VipsImage *in
,VipsImage **out
,VipsImage *mask
,...
); void vips_convolution_operation_init (void
); int im_aconvsep (VipsImage *in
,VipsImage *out
,DOUBLEMASK *mask
,int n_layers
); int im_aconv (VipsImage *in
,VipsImage *out
,DOUBLEMASK *mask
,int n_layers
,int cluster
); int im_conv (VipsImage *in
,VipsImage *out
,INTMASK *mask
); int im_conv_f (VipsImage *in
,VipsImage *out
,DOUBLEMASK *mask
); int im_convsep (VipsImage *in
,VipsImage *out
,INTMASK *mask
); int im_convsep_f (VipsImage *in
,VipsImage *out
,DOUBLEMASK *mask
); int im_compass (VipsImage *in
,VipsImage *out
,INTMASK *mask
); int im_gradient (VipsImage *in
,VipsImage *out
,INTMASK *mask
); int im_lindetect (VipsImage *in
,VipsImage *out
,INTMASK *mask
); int im_sharpen (VipsImage *in
,VipsImage *out
,int mask_size
,double x1
,double y2
,double y3
,double m1
,double m2
); int im_grad_x (VipsImage *in
,VipsImage *out
); int im_grad_y (VipsImage *in
,VipsImage *out
); int im_fastcor (VipsImage *in
,VipsImage *ref
,VipsImage *out
); int im_spcor (VipsImage *in
,VipsImage *ref
,VipsImage *out
); int im_gradcor (VipsImage *in
,VipsImage *ref
,VipsImage *out
); int im_contrast_surface (VipsImage *in
,VipsImage *out
,int half_win_size
,int spacing
); int im_addgnoise (VipsImage *in
,VipsImage *out
,double sigma
);
These operations convolve an image in some way, or are operations based on simple convolution, or are useful with convolution.
typedef enum { VIPS_PRECISION_INTEGER, VIPS_PRECISION_FLOAT, VIPS_PRECISION_APPROXIMATE } VipsPrecision;
How accurate an operation should be.
int vips_conv (VipsImage *in
,VipsImage **out
,VipsImage *mask
,...
);
Optional arguments:
precision
: calculation accuracy
layers
: number of layers for approximation
cluster
: cluster lines closer than this distance
Convolution.
Perform a convolution of in
with mask
.
Each output pixel is
calculated as sigma[i]{pixel[i] * mask[i]} / scale + offset, where scale
and offset are part of mask
.
If precision
is VIPS_PRECISION_INTEGER then the convolution is performed
with integer arithmetic and the output image
always has the same VipsBandFmt as the input image.
Convolutions on unsigned 8-bit images are calculated with the processor's vector unit, if possible. Disable this with --vips-novector or IM_NOVECTOR.
If precision
is VIPS_PRECISION_FLOAT then the convolution is performed
with floating-point arithmetic. The output image
is always VIPS_FORMAT_FLOAT
unless in
is VIPS_FORMAT_DOUBLE
, in which case
out
is also VIPS_FORMAT_DOUBLE
.
If precision
is VIPS_PRECISION_APPROXIMATE then the output image
always has the same VipsBandFmt as the input image.
Larger values for layers
give more accurate
results, but are slower. As layers
approaches the mask radius, the
accuracy will become close to exact convolution and the speed will drop to
match. For many large masks, such as Gaussian, n_layers
need be only 10% of
this value and accuracy will still be good.
Smaller values of cluster
will give more accurate results, but be slower
and use more memory. 10% of the mask radius is a good rule of thumb.
|
input image |
|
output image |
|
convolve with this mask |
|
NULL -terminated list of optional named arguments |
Returns : |
0 on success, -1 on error |
int im_aconvsep (VipsImage *in
,VipsImage *out
,DOUBLEMASK *mask
,int n_layers
);
Perform an approximate separable convolution of in
with mask
.
The mask must be 1xn or nx1 elements. The output image always has the same VipsBandFmt as the input image.
The image is convolved twice: once with mask
and then again with mask
rotated by 90 degrees.
Larger values for n_layers
give more accurate
results, but are slower. As n_layers
approaches the mask radius, the
accuracy will become close to exact convolution and the speed will drop to
match. For many large masks, such as Gaussian, n_layers
need be only 10% of
this value and accuracy will still be good.
See also: im_convsep_f()
, im_create_dmaskv()
.
|
input image |
|
output image |
|
convolution mask |
|
number of layers for approximation |
Returns : |
0 on success, -1 on error |
int im_aconv (VipsImage *in
,VipsImage *out
,DOUBLEMASK *mask
,int n_layers
,int cluster
);
Perform an approximate convolution of in
with mask
.
The output image always has the same VipsBandFmt as the input image.
Larger values for n_layers
give more accurate
results, but are slower. As n_layers
approaches the mask radius, the
accuracy will become close to exact convolution and the speed will drop to
match. For many large masks, such as Gaussian, n_layers
need be only 10% of
this value and accuracy will still be good.
Smaller values of cluster
will give more accurate results, but be slower
and use more memory. 10% of the mask radius is a good rule of thumb.
See also: im_convsep_f()
, im_create_dmaskv()
.
|
input image |
|
output image |
|
convolution mask |
|
number of layers for approximation |
|
cluster lines closer than this distance |
Returns : |
0 on success, -1 on error |
int im_conv (VipsImage *in
,VipsImage *out
,INTMASK *mask
);
Convolve in
with mask
using integer arithmetic. The output image
always has the same VipsBandFmt as the input image.
Each output pixel is
calculated as sigma[i]{pixel[i] * mask[i]} / scale + offset, where scale
and offset are part of mask
. For integer in
, the division by scale
includes round-to-nearest.
Convolutions on unsigned 8-bit images are calculated with the processor's vector unit, if possible. Disable this with --vips-novector or IM_NOVECTOR.
See also: im_conv_f()
, im_convsep()
, im_create_imaskv()
.
|
input image |
|
output image |
|
convolution mask |
Returns : |
0 on success, -1 on error |
int im_conv_f (VipsImage *in
,VipsImage *out
,DOUBLEMASK *mask
);
Convolve in
with mask
using floating-point arithmetic. The output image
is always IM_BANDFMT_FLOAT
unless in
is IM_BANDFMT_DOUBLE
, in which case
out
is also IM_BANDFMT_DOUBLE
.
Each output pixel is
calculated as sigma[i]{pixel[i] * mask[i]} / scale + offset, where scale
and offset are part of mask
.
See also: im_conv()
, im_convsep_f()
, im_create_dmaskv()
.
|
input image |
|
output image |
|
convolution mask |
Returns : |
0 on success, -1 on error |
int im_convsep (VipsImage *in
,VipsImage *out
,INTMASK *mask
);
Perform a separable convolution of in
with mask
using integer arithmetic.
See im_conv()
for a detailed description.
The mask must be 1xn or nx1 elements. The output image always has the same VipsBandFmt as the input image.
The image is convolved twice: once with mask
and then again with mask
rotated by 90 degrees. This is much faster for certain types of mask
(gaussian blur, for example) than doing a full 2D convolution.
See also: im_convsep_f()
, im_conv()
, im_create_imaskv()
.
|
input image |
|
output image |
|
convolution mask |
Returns : |
0 on success, -1 on error |
int im_convsep_f (VipsImage *in
,VipsImage *out
,DOUBLEMASK *mask
);
Perform a separable convolution of in
with mask
using floating-point
arithmetic.
The mask must be 1xn or nx1 elements.
The output image
is always IM_BANDFMT_FLOAT
unless in
is IM_BANDFMT_DOUBLE
, in which case
out
is also IM_BANDFMT_DOUBLE
.
The image is convolved twice: once with mask
and then again with mask
rotated by 90 degrees. This is much faster for certain types of mask
(gaussian blur, for example) than doing a full 2D convolution.
Each output pixel is
calculated as sigma[i]{pixel[i] * mask[i]} / scale + offset, where scale
and offset are part of mask
.
See also: im_convsep()
, im_conv()
, im_create_dmaskv()
.
|
input image |
|
output image |
|
convolution mask |
Returns : |
0 on success, -1 on error |
int im_compass (VipsImage *in
,VipsImage *out
,INTMASK *mask
);
in
is convolved 8 times with mask
, each time mask
is rotated by 45
degrees. Each output pixel is the largest absolute value of the 8
convolutions.
See also: im_lindetect()
, im_gradient()
, im_conv()
.
|
input image |
|
output image |
|
convolution mask |
Returns : |
0 on success, -1 on error |
int im_gradient (VipsImage *in
,VipsImage *out
,INTMASK *mask
);
in
is convolved with mask
and with mask
after a 90 degree rotation. The
result is the sum of the absolute value of the two convolutions.
See also: im_lindetect()
, im_gradient()
, im_conv()
.
|
input image |
|
output image |
|
convolution mask |
Returns : |
0 on success, -1 on error |
int im_lindetect (VipsImage *in
,VipsImage *out
,INTMASK *mask
);
in
is convolved four times with mask
, each time mask
is rotated by 45
degrees. Each output pixel is the largest absolute value of the four
convolutions.
See also: im_compass()
, im_gradient()
, im_conv()
.
|
input image |
|
output image |
|
convolution mask |
Returns : |
0 on success, -1 on error |
int im_sharpen (VipsImage *in
,VipsImage *out
,int mask_size
,double x1
,double y2
,double y3
,double m1
,double m2
);
Selectively sharpen the L channel of a LAB image. Works for IM_CODING_LABQ
and LABS images.
The operation performs a gaussian blur of size mask_size
and subtracts
from in
to
generate a high-frequency signal. This signal is passed through a lookup
table formed from the five parameters and added back to in
.
The lookup table is formed like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |