Top | Description | Object Hierarchy | ![]() | ![]() | ![]() | ![]() |
int | vips_conv () |
int | vips_convf () |
int | vips_convi () |
int | vips_conva () |
int | vips_convsep () |
int | vips_convasep () |
int | vips_compass () |
int | vips_gaussblur () |
int | vips_sharpen () |
int | vips_spcor () |
int | vips_fastcor () |
int | vips_sobel () |
int | vips_scharr () |
int | vips_prewitt () |
int | vips_canny () |
These operations convolve an image in some way, or are operations based onsimple convolution, or are useful with convolution.
intvips_conv (VipsImage *in
,VipsImage **out
,VipsImage *mask
,...
);
Optional arguments:
precision
:VipsPrecision, calculation accuracy
layers
:gint
, number of layers for approximation
cluster
:gint
, cluster lines closer than this distance
Convolution.
Perform a convolution ofin
withmask
.Each output pixel is calculated as:
1 | sigma[i]{pixel[i]*mask[i]}/scale+offset |
where scale and offset are part ofmask
.
By default,precision
isVIPS_PRECISION_FLOAT. The output imageis alwaysVIPS_FORMAT_FLOAT unlessin
isVIPS_FORMAT_DOUBLE, in which caseout
is alsoVIPS_FORMAT_DOUBLE.
Ifprecision
isVIPS_PRECISION_INTEGER, thenelements ofmask
are converted tointegers before convolution, usingrint()
,and the output imagealways has the sameVipsBandFormat as the input image.
ForVIPS_FORMAT_UCHAR images andVIPS_PRECISION_INTEGERprecision
,vips_conv()
uses a fast vector path based onhalf-float arithmetic. This can produce slightly different results.Disable the vector path with--vips-novector
orVIPS_NOVECTOR
orvips_vector_set_enabled()
.
Ifprecision
isVIPS_PRECISION_APPROXIMATE then, likeVIPS_PRECISION_INTEGER,mask
is converted to int before convolution, andthe output imagealways has the sameVipsBandFormat as the input image.
Larger values forlayers
give more accurateresults, but are slower. Aslayers
approaches the mask radius, theaccuracy will become close to exact convolution and the speed will drop tomatch. For many large masks, such as Gaussian,n_layers
need be only 10% ofthis value and accuracy will still be good.
Smaller values ofcluster
will give more accurate results, but be slowerand use more memory. 10% of the mask radius is a good rule of thumb.
See also:vips_convsep()
.
in | input image | |
out | output image. | [out] |
mask | convolve with this mask | |
... |
|
intvips_convf (VipsImage *in
,VipsImage **out
,VipsImage *mask
,...
);
Convolution. This is a low-level operation, seevips_conv()
for somethingmore convenient.
Perform a convolution ofin
withmask
.Each output pixel iscalculated as sigma[i]{pixel[i] * mask[i]} / scale + offset, where scaleand offset are part ofmask
.
The convolution is performed with floating-point arithmetic. The output imageis alwaysVIPS_FORMAT_FLOAT unlessin
isVIPS_FORMAT_DOUBLE, in which caseout
is alsoVIPS_FORMAT_DOUBLE.
See also:vips_conv()
.
in | input image | |
out | output image. | [out] |
mask | convolve with this mask | |
... |
|
intvips_convi (VipsImage *in
,VipsImage **out
,VipsImage *mask
,...
);
Integer convolution. This is a low-level operation, seevips_conv()
forsomething more convenient.
mask
is converted to an integer mask withrint()
of each element, rint ofscale and rint of offset. Each output pixel is then calculated as
1 | sigma[i]{pixel[i]*mask[i]}/scale+offset |
The output image always has the sameVipsBandFormat as the input image.
ForVIPS_FORMAT_UCHAR images,vips_convi()
uses a fast vector path based onhalf-float arithmetic. This can produce slightly different results.Disable the vector path with--vips-novector
orVIPS_NOVECTOR
orvips_vector_set_enabled()
.
See also:vips_conv()
.
in | input image | |
out | output image. | [out] |
mask | convolve with this mask | |
... |
|
intvips_conva (VipsImage *in
,VipsImage **out
,VipsImage *mask
,...
);
Optional arguments:
layers
:gint
, number of layers for approximation
cluster
:gint
, cluster lines closer than this distance
Perform an approximate integer convolution ofin
withmask
.This is a low-level operation, seevips_conv()
for something more convenient.
The output imagealways has the sameVipsBandFormat as the input image.Elements ofmask
are converted tointegers before convolution.
Larger values forlayers
give more accurateresults, but are slower. Aslayers
approaches the mask radius, theaccuracy will become close to exact convolution and the speed will drop tomatch. For many large masks, such as Gaussian,layers
need be only 10% ofthis value and accuracy will still be good.
Smaller values ofcluster
will give more accurate results, but be slowerand use more memory. 10% of the mask radius is a good rule of thumb.
See also:vips_conv()
.
in | input image | |
out | output image. | [out] |
mask | convolution mask | |
... |
|
intvips_convsep (VipsImage *in
,VipsImage **out
,VipsImage *mask
,...
);
Optional arguments:
precision
: calculation accuracy
layers
: number of layers for approximation
cluster
: cluster lines closer than this distance
Perform a separable convolution ofin
withmask
.Seevips_conv()
for a detailed description.
The mask must be 1xn or nx1 elements.
The image is convolved twice: once withmask
and then again withmask
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:vips_conv()
,vips_gaussmat()
.
in | input image | |
out | output image. | [out] |
mask | convolution mask | |
... |
|
intvips_convasep (VipsImage *in
,VipsImage **out
,VipsImage *mask
,...
);
Optional arguments:
layers
:gint
, number of layers for approximation
Approximate separable integer convolution. This is a low-level operation, seevips_convsep()
for something more convenient.
The image is convolved twice: once withmask
and then again withmask
rotated by 90 degrees.mask
must be 1xn or nx1 elements.Elements ofmask
are converted tointegers before convolution.
Larger values forlayers
give more accurateresults, but are slower. Aslayers
approaches the mask radius, theaccuracy will become close to exact convolution and the speed will drop tomatch. For many large masks, such as Gaussian,layers
need be only 10% ofthis value and accuracy will still be good.
The output imagealways has the sameVipsBandFormat as the input image.
See also:vips_convsep()
.
in | input image | |
out | output image. | [out] |
mask | convolve with this mask | |
... |
|
intvips_compass (VipsImage *in
,VipsImage **out
,VipsImage *mask
,...
);
Optional arguments:
times
:gint
, how many times to rotate and convolve
angle
:VipsAngle45, rotate mask by this much between colvolutions
combine
:VipsCombine, combine results like this
precision
:VipsPrecision, precision for blur, default float
layers
:gint
, number of layers for approximation
cluster
:gint
, cluster lines closer than this distance
This convolvesin
withmask
times
times, rotatingmask
byangle
each time. By default, it comvolves twice, rotating by 90 degrees, takingthe maximum result.
See also:vips_conv()
.
in | input image | |
out | output image. | [out] |
mask | convolve with this mask | |
... |
|
intvips_gaussblur (VipsImage *in
,VipsImage **out
,double sigma
,...
);
Optional arguments:
precision
:VipsPrecision, precision for blur, default int
min_ampl
: minimum amplitude, default 0.2
This operator runsvips_gaussmat()
andvips_convsep()
for you on an image.Setmin_ampl
smaller to generate a larger, more accurate mask. Setsigma
larger to make the blur more blurry.
See also:vips_gaussmat()
,vips_convsep()
.
in | input image | |
out | output image. | [out] |
sigma | how large a mask to use | |
... |
|
intvips_sharpen (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
sigma
: sigma of gaussian
x1
: flat/jaggy threshold
y2
: maximum amount of brightening
y3
: maximum amount of darkening
m1
: slope for flat areas
m2
: slope for jaggy areas
Selectively sharpen the L channel of a LAB image. The input image istransformed toVIPS_INTERPRETATION_LABS.
The operation performs a gaussian blur and subtracts fromin
to generate ahigh-frequency signal. This signal is passed through a lookup table formedfrom the five parameters and added back toin
.
The lookup table is formed like this:
1234567891011121314151617 | .^.y2|----------------.|/.|/slopem2.|.../.-x1|...|.-------------------...---------------------->.|...|x1.|...slopem1./|./m2|./|./|./|./|.______/______|-y3.| |
For screen output, we suggest the following settings (the defaults):
123456 | sigma==0.5x1==2y2==10(don'tbrightenbymorethan10L*)y3==20(candarkenbyupto20L*)m1==0(nosharpeninginflatareas)m2==3(somesharpeninginjaggyareas) |
If you want more or less sharpening, we suggest you just change them2 parameter.
Thesigma
parameter changes the width of the fringe and can beadjusted according to the output printing resolution. As an approximateguideline, use 0.5 for 4 pixels/mm (display resolution),1.0 for 12 pixels/mm and 1.5 for 16 pixels/mm (300 dpi == 12pixels/mm). These figures refer to the image raster, not the half-toneresolution.
See also:vips_conv()
.
intvips_spcor (VipsImage *in
,VipsImage *ref
,VipsImage **out
,...
);
Calculate a correlation surface.
ref
is placed at every position inin
and the correlation coefficientcalculated. The outputimage is always float.
The outputimage is the same size as the input. Extra input edge pixels are made bycopying the existing edges outwards.
The correlation coefficient is calculated as:
1234 | sumij(ref(i,j)-mean(ref))(inkl(i,j)-mean(inkl))c(k,l)=------------------------------------------------sqrt(sumij(ref(i,j)-mean(ref))^2)*sqrt(sumij(inkl(i,j)-mean(inkl))^2) |
where inkl is the area ofin
centred at position (k,l).
from Niblack "An Introduction to Digital Image Processing",Prentice/Hall, pp 138.
If the number of bands differs, one of the imagesmust have one band. In this case, an n-band image is formed from theone-band image by joining n copies of the one-band image together, and thenthe two n-band images are operated upon.
The output image is always float, unless either of the two inputs isdouble, in which case the output is also double.
See also:vips_fastcor()
.
in | input image | |
ref | reference image | |
out | output image. | [out] |
... |
|
intvips_fastcor (VipsImage *in
,VipsImage *ref
,VipsImage **out
,...
);
Calculate a fast correlation surface.
ref
is placed at every position inin
and the sum of squares ofdifferences calculated.
The outputimage is the same size as the input. Extra input edge pixels are made bycopying the existing edges outwards.
If the number of bands differs, one of the imagesmust have one band. In this case, an n-band image is formed from theone-band image by joining n copies of the one-band image together, and thenthe two n-band images are operated upon.
The output type is uint if both inputs are integer, float if both are floator complex, and double if either is double or double complex.In other words, the output type is just large enough to hold the wholerange of possible values.
See also:vips_spcor()
.
in | input image | |
ref | reference image | |
out | output image. | [out] |
... |
|
intvips_sobel (VipsImage *in
,VipsImage **out
,...
);
Sobel edge detector.
uchar images are computed using a fast, low-precision path. Cast to floatfor a high-precision implementation.
See also:vips_canny()
,vips_sobel()
,vips_prewitt()
,vips_scharr()
.
intvips_scharr (VipsImage *in
,VipsImage **out
,...
);
Scharr edge detector.
uchar images are computed using a fast, low-precision path. Cast to floatfor a high-precision implementation.
See also:vips_canny()
,vips_sobel()
,vips_prewitt()
,vips_scharr()
.
intvips_prewitt (VipsImage *in
,VipsImage **out
,...
);
Prewitt edge detector.
uchar images are computed using a fast, low-precision path. Cast to floatfor a high-precision implementation.
See also:vips_canny()
,vips_sobel()
,vips_prewitt()
,vips_scharr()
.
intvips_canny (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
sigma
:gdouble
, sigma for gaussian blur
precision
:VipsPrecision, calculation accuracy
Find edges by Canny's method: The maximum of the derivative of the gradientin the direction of the gradient. Output is float, except for uchar input,where output is uchar, and double input, where output is double. Non-compleximages only.
Usesigma
to control the scale over which gradient is measured. 1.4 isusually a good value.
Useprecision
to set the precision of edge detection. For uchar images,setting this toVIPS_PRECISION_INTEGER will make edge detection muchfaster, but sacrifice some sensitivity.
You will probably need to process the output further to eliminate weakedges.
See also:vips_sobel()
.