IM_MULTIPLY

Section: C Library Functions (3)
Updated: 24 April 1991
Index Return to Main Contents
 

NAME

im_cmulnorm, im_multiply - multiply two images  

SYNOPSIS

#include <vips/vips.h>

int im_cmulnorm(in1, in2, out)
IMAGE *in1, *in2, *out;

int im_multiply(in1, in2, out)
IMAGE *in1, *in2, *out;

 

DESCRIPTION

These functions operate on two images held by image descriptors in1 and in2 and write the result to the image descriptor out. Input images in1 and in2 should have the same channels and the same sizes; however they can be of different types. Only the history of the image descriptor pointed by in1 is copied to out.

im_multiply(3) applied to two integer images multiplies the two images and writes the output as:


 in1    | uchar   char   ushort  short  uint  int 
 -------+-----------------------------------------
 in2    |
 uchar  | ushort  short  ushort  short  uint  int
 char   | short   short  short   short  int   int
 ushort | ushort  short  ushort  short  uint  int
 short  | short   short  short   short  int   int
 uint   | uint    int    uint    int    uint  int
 int    | int     int    int     int    int   int

If one or more of the images is a floating point type, the output is FMTFLOAT, unless one or more of the inputs is FMTDOUBLE, in which case the output is also FMTDOUBLE.

If one or more of the images is a complex type, the output is FMTCOMPLEX, unless one or more of the inputs is FMTDPCOMPLEX, in which case the output is also FMTDPCOMPLEX.

For complex input pels (x1,y1) and (x2,y2), im_multiply() writes (x1*x2 - y1*y2, x1*y2 + x2*y1).

im_cmulnorm(3) multiplies two complex images. The complex output is normalised to 1 by dividing both the real and the imaginary part of each pel with the norm; for instance if the complex multiplication produces (a,b) then the output written by this function is (a/norm, b/norm), where norm=a*a+b*b. Result is checked for norm=0. The function is useful for phase correlation. Both inputs should be complex.

Result is float complex if both inputs are float complex. In any other case the result is double complex.

 

BUGS

None of the functions checks the result for over/underflow.  

RETURN VALUE

All functions return 0 on success and -1 on error.  

SEE ALSO

im_subtract(3), im_lintra(3), im_add(3).  

AUTHOR

N. Dessipris - 22/04/1991
J. Cupitt (im_multiply) - 22/04/1991