check

check — test images for various properties

Stability Level

Stable, unless otherwise indicated

Synopsis

#include <vips/vips.h>

int                 im_rwcheck                          (IMAGE *im);
int                 im_iocheck                          (IMAGE *in,
                                                         IMAGE *out);
int                 im_incheck                          (IMAGE *im);
int                 im_outcheck                         (IMAGE *im);
int                 im_piocheck                         (IMAGE *in,
                                                         IMAGE *out);
int                 im_pincheck                         (IMAGE *im);
int                 im_poutcheck                        (IMAGE *im);
int                 im_check_uncoded                    (const char *domain,
                                                         IMAGE *im);
int                 im_check_coding_known               (const char *domain,
                                                         IMAGE *im);
int                 im_check_coding_labq                (const char *domain,
                                                         IMAGE *im);
int                 im_check_coding_rad                 (const char *domain,
                                                         IMAGE *im);
int                 im_check_coding_noneorlabq          (const char *domain,
                                                         IMAGE *im);
int                 im_check_coding_same                (const char *domain,
                                                         IMAGE *im1,
                                                         IMAGE *im2);
int                 im_check_mono                       (const char *domain,
                                                         IMAGE *im);
int                 im_check_bands_1or3                 (const char *domain,
                                                         IMAGE *in);
int                 im_check_bands                      (const char *domain,
                                                         IMAGE *im,
                                                         int bands);
int                 im_check_bands_1orn                 (const char *domain,
                                                         IMAGE *im1,
                                                         IMAGE *im2);
int                 im_check_bands_1orn_unary           (const char *domain,
                                                         IMAGE *im,
                                                         int n);
int                 im_check_bands_same                 (const char *domain,
                                                         IMAGE *im1,
                                                         IMAGE *im2);
int                 im_check_bandno                     (const char *domain,
                                                         IMAGE *im,
                                                         int bandno);
int                 im_check_int                        (const char *domain,
                                                         IMAGE *im);
int                 im_check_uint                       (const char *domain,
                                                         IMAGE *im);
int                 im_check_uintorf                    (const char *domain,
                                                         IMAGE *im);
int                 im_check_noncomplex                 (const char *domain,
                                                         IMAGE *im);
int                 im_check_complex                    (const char *domain,
                                                         IMAGE *im);
int                 im_check_format                     (const char *domain,
                                                         IMAGE *im,
                                                         VipsBandFmt fmt);
int                 im_check_u8or16                     (const char *domain,
                                                         IMAGE *im);
int                 im_check_8or16                      (const char *domain,
                                                         IMAGE *im);
int                 im_check_u8or16orf                  (const char *domain,
                                                         IMAGE *im);
int                 im_check_format_same                (const char *domain,
                                                         IMAGE *im1,
                                                         IMAGE *im2);
int                 im_check_size_same                  (const char *domain,
                                                         IMAGE *im1,
                                                         IMAGE *im2);
int                 im_check_vector                     (const char *domain,
                                                         int n,
                                                         IMAGE *im);
int                 im_check_hist                       (const char *domain,
                                                         IMAGE *im);
int                 im_check_imask                      (const char *domain,
                                                         INTMASK *mask);
int                 im_check_dmask                      (const char *domain,
                                                         DOUBLEMASK *mask);
gboolean            vips_bandfmt_isint                  (VipsBandFmt fmt);
gboolean            vips_bandfmt_isuint                 (VipsBandFmt fmt);
gboolean            vips_bandfmt_isfloat                (VipsBandFmt fmt);
gboolean            vips_bandfmt_iscomplex              (VipsBandFmt fmt);
gboolean            im_isfile                           (IMAGE *im);
gboolean            im_ispartial                        (IMAGE *im);
gboolean            im_isMSBfirst                       (IMAGE *im);

Description

These functions perform simple checks on an IMAGE, or indicate that you intend to use an IMAGE in a certain way.

im_incheck(), im_pincheck() and friends indicate the image IO style you intend to use, transforming the underlying IMAGE structure if necessary.

im_check_mono() and friends and convenience functions that test an IMAGE for having various properties and signal an error if the condition is not met. They are useful for writing image processing operations which can only work on certain types of image.

Details

im_rwcheck ()

int                 im_rwcheck                          (IMAGE *im);

Gets an image ready for an in-place operation, such as im_insertplace(). Operations like this both read and write with IM_IMAGE_ADDR().

See also: im_insertplace(), im_incheck().

im :

image to make read-write

Returns :

0 on succeess, or -1 on error.

im_iocheck ()

int                 im_iocheck                          (IMAGE *in,
                                                         IMAGE *out);

A convenience function to check a pair of images for IO via IM_IMAGE_ADDR() and im_writeline().

See also: im_incheck(), im_outcheck().

in :

input image

out :

output image

Returns :

0 on succeess, or -1 on error.

im_incheck ()

int                 im_incheck                          (IMAGE *im);

Check that an image is readable via the IM_IMAGE_ADDR() macro. If it isn't, try to transform it so that IM_IMAGE_ADDR() can work.

See also: im_outcheck(), im_pincheck(), im_rwcheck(), IM_IMAGE_ADDR().

im :

image to check

Returns :

0 on succeess, or -1 on error.

im_outcheck ()

int                 im_outcheck                         (IMAGE *im);

Check that an image is writeable by im_writeline(). If it isn't, try to transform it so that im_writeline() can work.

Set the image properties (like size, type and so on), then call im_setupout(), then call im_writeline() for each scan line.

See also: im_incheck(), im_poutcheck().

im :

image to check

Returns :

0 on succeess, or -1 on error.

im_piocheck ()

int                 im_piocheck                         (IMAGE *in,
                                                         IMAGE *out);

A convenience function to check a pair of images for IO via im_prepare() and im_generate().

See also: im_pincheck(), im_poutcheck().

in :

input image

out :

output image

Returns :

0 on succeess, or -1 on error.

im_pincheck ()

int                 im_pincheck                         (IMAGE *im);

Check that an image is readable with im_prepare() and friends. If it isn't, try to transform the image so that im_prepare() can work.

See also: im_incheck(), im_poutcheck(), im_prepare().

im :

image to check

Returns :

0 on succeess, or -1 on error.

im_poutcheck ()

int                 im_poutcheck                        (IMAGE *im);

Check that an image is writeable with im_generate(). If it isn't, try to transform the image so that im_generate() can work.

See also: im_incheck(), im_poutcheck(), im_generate().

im :

image to check

Returns :

0 on succeess, or -1 on error.

im_check_uncoded ()

int                 im_check_uncoded                    (const char *domain,
                                                         IMAGE *im);

Check that the image is not coded. If not, set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

Returns :

0 on OK, or -1 on error.

im_check_coding_known ()

int                 im_check_coding_known               (const char *domain,
                                                         IMAGE *im);

Check that the image is uncoded, LABQ coded or RAD coded. If not, set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

Returns :

0 on OK, or -1 on error.

im_check_coding_labq ()

int                 im_check_coding_labq                (const char *domain,
                                                         IMAGE *im);

Check that the image is in LABQ coding. If not, set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

Returns :

0 on OK, or -1 on error.

im_check_coding_rad ()

int                 im_check_coding_rad                 (const char *domain,
                                                         IMAGE *im);

Check that the image is in Radiance coding. If not, set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

Returns :

0 on OK, or -1 on error.

im_check_coding_noneorlabq ()

int                 im_check_coding_noneorlabq          (const char *domain,
                                                         IMAGE *im);

Check that the image is uncoded or LABQ coded. If not, set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

Returns :

0 on OK, or -1 on error.

im_check_coding_same ()

int                 im_check_coding_same                (const char *domain,
                                                         IMAGE *im1,
                                                         IMAGE *im2);

Check that the images have the same coding. If not, set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im1 :

first image to check

im2 :

second image to check

Returns :

0 if OK, -1 otherwise.

im_check_mono ()

int                 im_check_mono                       (const char *domain,
                                                         IMAGE *im);

Check that the image has exactly one band. Otherwise set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

Returns :

0 if OK, -1 otherwise.

im_check_bands_1or3 ()

int                 im_check_bands_1or3                 (const char *domain,
                                                         IMAGE *in);

im_check_bands ()

int                 im_check_bands                      (const char *domain,
                                                         IMAGE *im,
                                                         int bands);

Check that the image has bands bands. Otherwise set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

bands :

must have this many bands

Returns :

0 if OK, -1 otherwise.

im_check_bands_1orn ()

int                 im_check_bands_1orn                 (const char *domain,
                                                         IMAGE *im1,
                                                         IMAGE *im2);

Check that the images have the same number of bands, or that one of the images has just 1 band. If not, set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im1 :

first image to check

im2 :

second image to check

Returns :

0 on OK, or -1 on error.

im_check_bands_1orn_unary ()

int                 im_check_bands_1orn_unary           (const char *domain,
                                                         IMAGE *im,
                                                         int n);

Check that an image has 1 or n bands. Handy for unary operations, cf. im_check_bands_1orn(). If not, set an error message and return non-zero.

See also: im_check_bands_1orn().

domain :

the originating domain for the error message

im :

image to check

n :

number of bands, or 1

Returns :

0 on OK, or -1 on error.

im_check_bands_same ()

int                 im_check_bands_same                 (const char *domain,
                                                         IMAGE *im1,
                                                         IMAGE *im2);

Check that the images have the same number of bands. If not, set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im1 :

first image to check

im2 :

second image to check

Returns :

0 if OK, -1 otherwise.

im_check_bandno ()

int                 im_check_bandno                     (const char *domain,
                                                         IMAGE *im,
                                                         int bandno);

bandno should be a valid band number (ie. 0 to im->Bands - 1), or can be -1, meaning all bands. If not, set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

bandno :

band number

Returns :

0 if OK, -1 otherwise.

im_check_int ()

int                 im_check_int                        (const char *domain,
                                                         IMAGE *im);

Check that the image is in one of the integer formats. Otherwise set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

Returns :

0 if OK, -1 otherwise.

im_check_uint ()

int                 im_check_uint                       (const char *domain,
                                                         IMAGE *im);

Check that the image is in one of the unsigned integer formats. Otherwise set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

Returns :

0 if OK, -1 otherwise.

im_check_uintorf ()

int                 im_check_uintorf                    (const char *domain,
                                                         IMAGE *im);

Check that the image is unsigned int or float. Otherwise set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

Returns :

0 if OK, -1 otherwise.

im_check_noncomplex ()

int                 im_check_noncomplex                 (const char *domain,
                                                         IMAGE *im);

Check that the image is not complex. Otherwise set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

Returns :

0 if OK, -1 otherwise.

im_check_complex ()

int                 im_check_complex                    (const char *domain,
                                                         IMAGE *im);

Check that the image is complex. Otherwise set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

Returns :

0 if OK, -1 otherwise.

im_check_format ()

int                 im_check_format                     (const char *domain,
                                                         IMAGE *im,
                                                         VipsBandFmt fmt);

Check that the image has the specified format. Otherwise set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

fmt :

format to test for

Returns :

0 if OK, -1 otherwise.

im_check_u8or16 ()

int                 im_check_u8or16                     (const char *domain,
                                                         IMAGE *im);

Check that the image is 8 or 16-bit unsigned integer. Otherwise set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

Returns :

0 if OK, -1 otherwise.

im_check_8or16 ()

int                 im_check_8or16                      (const char *domain,
                                                         IMAGE *im);

Check that the image is 8 or 16-bit integer, signed or unsigned. Otherwise set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

Returns :

0 if OK, -1 otherwise.

im_check_u8or16orf ()

int                 im_check_u8or16orf                  (const char *domain,
                                                         IMAGE *im);

Check that the image is 8 or 16-bit unsigned integer, or float. Otherwise set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

Returns :

0 if OK, -1 otherwise.

im_check_format_same ()

int                 im_check_format_same                (const char *domain,
                                                         IMAGE *im1,
                                                         IMAGE *im2);

Check that the images have the same format. If not, set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im1 :

first image to check

im2 :

second image to check

Returns :

0 if OK, -1 otherwise.

im_check_size_same ()

int                 im_check_size_same                  (const char *domain,
                                                         IMAGE *im1,
                                                         IMAGE *im2);

Check that the images have the same size. If not, set an error message and return non-zero.

See also: im_error().

domain :

the originating domain for the error message

im1 :

first image to check

im2 :

second image to check

Returns :

0 if OK, -1 otherwise.

im_check_vector ()

int                 im_check_vector                     (const char *domain,
                                                         int n,
                                                         IMAGE *im);

Operations with a vector constant need a 1-element vector, or a vector with the same number of elements as there are bands in the image.

See also: im_error().

domain :

the originating domain for the error message

n :

number of elements in vector

im :

image to check against

Returns :

0 if OK, -1 otherwise.

im_check_hist ()

int                 im_check_hist                       (const char *domain,
                                                         IMAGE *im);

Histogram images must have width or height 1, and must not have more than 65536 elements. Return 0 if the image will pass as a histogram, or -1 and set an error message otherwise.

See also: im_error().

domain :

the originating domain for the error message

im :

image to check

Returns :

0 if OK, -1 otherwise.

im_check_imask ()

int                 im_check_imask                      (const char *domain,
                                                         INTMASK *mask);

Sanity-check a mask parameter.

See also: im_error().

domain :

the originating domain for the error message

mask :

mask to check

Returns :

0 if OK, -1 otherwise.

im_check_dmask ()

int                 im_check_dmask                      (const char *domain,
                                                         DOUBLEMASK *mask);

Sanity-check a mask parameter.

See also: im_error().

domain :

the originating domain for the error message

mask :

mask to check

Returns :

0 if OK, -1 otherwise.

vips_bandfmt_isint ()

gboolean            vips_bandfmt_isint                  (VipsBandFmt fmt);

Return TRUE if fmt is one of the integer types.

fmt :

format to test

vips_bandfmt_isuint ()

gboolean            vips_bandfmt_isuint                 (VipsBandFmt fmt);

Return TRUE if fmt is one of the unsigned integer types.

fmt :

format to test

vips_bandfmt_isfloat ()

gboolean            vips_bandfmt_isfloat                (VipsBandFmt fmt);

Return TRUE if fmt is one of the float types.

fmt :

format to test

vips_bandfmt_iscomplex ()

gboolean            vips_bandfmt_iscomplex              (VipsBandFmt fmt);

Return TRUE if fmt is one of the complex types.

fmt :

format to test

im_isfile ()

gboolean            im_isfile                           (IMAGE *im);

Return TRUE if im represents a file on disc in some way.

im :

image to test

im_ispartial ()

gboolean            im_ispartial                        (IMAGE *im);

Return TRUE if im represents a partial image (a delayed calculation).

im :

image to test

im_isMSBfirst ()

gboolean            im_isMSBfirst                       (IMAGE *im);

Return TRUE if im is in most-significant- byte first form. This is the byte order used on the SPARC architecture and others.

im :

image to test

See Also

image