Woolz Image Processing  Version 1.7.5
WlzArithmetic

Files

file  WlzImageArithmetic.c
 Functions for performing arithmetic on a pair of domain objects with grey values.
 
file  WlzRGBAImageArithmetic.c
 Performs image arithmetic on RGBA data. Both input files must be RGBA value type.
 
file  WlzRGBAScalarBinaryOp.c
 Apply a scalar binary operation to an RGBA image.
 
file  WlzRGBChanRatio.c
 Computes log ratio of RGB channels in a RGBA object.
 
file  WlzScalarArithmeticOp.c
 Functions which apply scalar arithmetic operations to domain objects.
 
file  WlzScalarBinaryOp.c
 Applies scalar binary operators to objects.
 
file  WlzScalarFn.c
 Code to apply scalar functions to scalar image values in Woolz objects.
 

Enumerations

enum  _WlzBinaryOperatorType {
  WLZ_BO_ADD = 0,
  WLZ_BO_SUBTRACT,
  WLZ_BO_MULTIPLY,
  WLZ_BO_DIVIDE,
  WLZ_BO_MODULUS,
  WLZ_BO_EQ,
  WLZ_BO_NE,
  WLZ_BO_GT,
  WLZ_BO_GE,
  WLZ_BO_LT,
  WLZ_BO_LE,
  WLZ_BO_AND,
  WLZ_BO_OR,
  WLZ_BO_XOR,
  WLZ_BO_MAX,
  WLZ_BO_MIN,
  WLZ_BO_MAGNITUDE
}
 Binary operators. Typedef: WlzBinaryOperatorType. More...
 

Functions

WlzObjectWlzRGBAImageArithmetic (WlzObject *obj0, WlzObject *obj1, WlzBinaryOperatorType op, int overwrite, WlzErrorNum *dstErr)
 Performs image arithmetic on objects with RGBA values. See WlzImageArithmetic(). More...
 
WlzObjectWlzRGBChanRatio (WlzObject *rgbObj, WlzRGBAColorChannel num, WlzRGBAColorChannel den, WlzRGBAColorChannel mul, int useMul, int norm, WlzErrorNum *dstErr)
 Computes log ratio of RGB channels in a RGBA object for each pixel using ratio \(r\) with

\[ r = m \log(1 + \frac{n}{1 + d}). \]

where m is the multipler channel value or unity if not used. This results in either an object with float values or if the normalise parameter is non-zero an object with unsigned byte values normalised to the range 0-255. The numerator and denominator channels must be red, green blue, yellow, magenta, cyan, hue, staturation, brightness, or grey (modulus). More...

 
WlzErrorNum WlzGreyIncValuesInDomain (WlzObject *gObj, WlzObject *dObj)
 Increments all valus of the firstobjct which are within the domain of the second object. The domain of the first object must cover that of the second. More...
 
WlzErrorNum WlzGreyIncValues2D (WlzObject *obj)
 Increments all values within the given object. More...
 
WlzObjectWlzScalarBinaryOp2 (WlzObject *o1, WlzPixelV pval, WlzBinaryOperatorType op, WlzErrorNum *dstErr)
 Apply a binary operation (add subtract etc) to each pixel value in the given object. The operand value is in pval. More...
 
WlzObjectWlzScalarAdd (WlzObject *o1, WlzPixelV pval, WlzErrorNum *dstErr)
 Add a value to each pixel of an object. More...
 
WlzObjectWlzScalarSubtract (WlzObject *o1, WlzPixelV pval, WlzErrorNum *dstErr)
 Subtract a value from each pixel of an object. More...
 
WlzObjectWlzScalarMultiply (WlzObject *o1, WlzPixelV pval, WlzErrorNum *dstErr)
 Multiply each pixel of an object. More...
 
WlzObjectWlzScalarDivide (WlzObject *o1, WlzPixelV pval, WlzErrorNum *dstErr)
 Divide each pixel of an object. More...
 
WlzObjectWlzScalarMulAdd (WlzObject *iObj, WlzPixelV m, WlzPixelV a, WlzGreyType rGType, WlzErrorNum *dstErr)
 Scales the values of the given Woolz object so that \(v_{new} = m v_{given} + a.\). More...
 
WlzErrorNum WlzScalarBinaryOp (WlzObject *o1, WlzPixelV pval, WlzObject *o3, WlzBinaryOperatorType op)
 Perform the given binary operation for each grey value in image o1 with val putting the result in o3. The value table of o3 can be identical to that of o1 to allow overwriting. This function assumes that the domains of each object are the same. Unless overwriting is required then the functions WlzImageAdd, WlzImageSubtract etc. should be used. These return an object which is the intersection of the input objects. More...
 
WlzObjectWlzScalarFn (WlzObject *sObj, WlzFnType fn, WlzErrorNum *dstErr)
 Computes a new object which shares the domain of the given object, but which has grey values that are the result of applying the given function to the grey values of the given object. More...
 

Detailed Description

Enumeration Type Documentation

Binary operators. Typedef: WlzBinaryOperatorType.

Enumerator
WLZ_BO_ADD 
WLZ_BO_SUBTRACT 
WLZ_BO_MULTIPLY 
WLZ_BO_DIVIDE 
WLZ_BO_MODULUS 
WLZ_BO_EQ 
WLZ_BO_NE 
WLZ_BO_GT 
WLZ_BO_GE 
WLZ_BO_LT 
WLZ_BO_LE 
WLZ_BO_AND 
WLZ_BO_OR 
WLZ_BO_XOR 
WLZ_BO_MAX 
WLZ_BO_MIN 
WLZ_BO_MAGNITUDE 

Function Documentation

WlzObject* WlzRGBAImageArithmetic ( WlzObject obj0,
WlzObject obj1,
WlzBinaryOperatorType  op,
int  overwrite,
WlzErrorNum dstErr 
)

Performs image arithmetic on objects with RGBA values. See WlzImageArithmetic().

Returns
New object.
Parameters
obj0First object.
obj1Second object.
opBinary operator.
overwriteAllow the destination object to share values with one of the given objects if non zero.
dstErrDestination error pointer, may be NULL.

References _WlzCompoundArray::o, _WlzObject::type, WLZ_COMPOUND_ARR_1, WLZ_ERR_NONE, WLZ_ERR_OBJECT_NULL, WLZ_ERR_OBJECT_TYPE, WLZ_ERR_PARAM_DATA, WLZ_GREY_RGBA, WLZ_RGBA_SPACE_RGB, WlzCompoundToRGBA(), WlzFreeObj(), WlzGreyTypeFromObj(), WlzImageArithmetic(), WlzMakeCompoundArray(), and WlzRGBAToCompound().

Referenced by WlzShadeCorrectBFDF().

WlzObject* WlzRGBChanRatio ( WlzObject rgbObj,
WlzRGBAColorChannel  num,
WlzRGBAColorChannel  den,
WlzRGBAColorChannel  mul,
int  useMul,
int  norm,
WlzErrorNum dstErr 
)

Computes log ratio of RGB channels in a RGBA object for each pixel using ratio \(r\) with

\[ r = m \log(1 + \frac{n}{1 + d}). \]

where m is the multipler channel value or unity if not used. This results in either an object with float values or if the normalise parameter is non-zero an object with unsigned byte values normalised to the range 0-255. The numerator and denominator channels must be red, green blue, yellow, magenta, cyan, hue, staturation, brightness, or grey (modulus).

Returns
Ratio object or NULL on error.
Parameters
rgbObjThe input RGBA object.
numChannel for numerator in ratio.
denChannel for denominator in ratio.
mulChannel for multiplier value.
useMulMultiplier used if non zero.
normNormalise the object values and return a ubyte object.
dstErrDestination error pointer, may be NULL.

References ALG_MAX3, ALG_MIN3, _WlzVoxelValues::bckgrnd, _WlzValues::core, _WlzDomain::core, _WlzObject::domain, _WlzPlaneDomain::domains, _WlzGreyP::flp, _WlzGreyV::flv, _WlzVoxelValues::lastpl, _WlzIntervalWSpace::lftpos, _WlzDomain::p, _WlzGreyWSpace::pixeltype, _WlzPlaneDomain::plane1, _WlzVoxelValues::plane1, _WlzGreyP::rgbp, _WlzIntervalWSpace::rgtpos, _WlzPixelV::type, _WlzObject::type, _WlzCoreValues::type, _WlzVoxelValues::type, _WlzGreyWSpace::u_grintptr, _WlzGreyV::ubv, _WlzPixelV::v, _WlzValues::v, _WlzObject::values, _WlzVoxelValues::values, _WlzValues::vox, WLZ_2D_DOMAINOBJ, WLZ_3D_DOMAINOBJ, WLZ_ERR_DOMAIN_NULL, WLZ_ERR_EOO, WLZ_ERR_GREY_TYPE, WLZ_ERR_NONE, WLZ_ERR_OBJECT_NULL, WLZ_ERR_OBJECT_TYPE, WLZ_ERR_PARAM_DATA, WLZ_ERR_VALUES_NULL, WLZ_ERR_VALUES_TYPE, WLZ_GREY_FLOAT, WLZ_GREY_RGBA, WLZ_GREY_TAB_RAGR, WLZ_GREY_UBYTE, WLZ_NINT, WLZ_RGBA_BLUE_GET, WLZ_RGBA_CHANNEL_BLUE, WLZ_RGBA_CHANNEL_BRIGHTNESS, WLZ_RGBA_CHANNEL_CYAN, WLZ_RGBA_CHANNEL_GREEN, WLZ_RGBA_CHANNEL_GREY, WLZ_RGBA_CHANNEL_HUE, WLZ_RGBA_CHANNEL_MAGENTA, WLZ_RGBA_CHANNEL_RED, WLZ_RGBA_CHANNEL_SATURATION, WLZ_RGBA_CHANNEL_YELLOW, WLZ_RGBA_GREEN_GET, WLZ_RGBA_MODULUS, WLZ_RGBA_RED_GET, WlzAssignObject(), WlzAssignValues(), WlzConvertPix(), WlzFreeObj(), WlzFreeValues(), WlzGreyNormalise(), WlzGreyTableIsTiled(), WlzGreyValueTableType(), WlzInitGreyScan(), WlzMakeMain(), WlzMakeVoxelValueTb(), WlzNewValueTb(), WlzNextGreyInterval(), and WlzSetBackground().

WlzErrorNum WlzGreyIncValuesInDomain ( WlzObject gObj,
WlzObject dObj 
)
WlzObject* WlzScalarAdd ( WlzObject o1,
WlzPixelV  pval,
WlzErrorNum dstErr 
)

Add a value to each pixel of an object.

Returns
Object with value added to each pixel.
Parameters
o1Input object
pvalValue to be added.
dstErrError return.

References WLZ_BO_ADD, and WlzScalarBinaryOp2().

WlzObject* WlzScalarSubtract ( WlzObject o1,
WlzPixelV  pval,
WlzErrorNum dstErr 
)

Subtract a value from each pixel of an object.

Returns
Object with value subtacted from each pixel.
Parameters
o1Input object
pvalValue to be subtracted.
dstErrError return.

References WLZ_BO_SUBTRACT, and WlzScalarBinaryOp2().

WlzObject* WlzScalarMultiply ( WlzObject o1,
WlzPixelV  pval,
WlzErrorNum dstErr 
)

Multiply each pixel of an object.

Returns
Object with multiplied pixel values.
Parameters
o1Input object
pvalMultiplication factor.
dstErrError return.
Source:
WlzScalarArithmeticOp.c

References WLZ_BO_MULTIPLY, and WlzScalarBinaryOp2().

Referenced by WlzNObjGreyStats().

WlzObject* WlzScalarDivide ( WlzObject o1,
WlzPixelV  pval,
WlzErrorNum dstErr 
)

Divide each pixel of an object.

Returns
Object with each pixel divided.
Parameters
o1Input object
pvalDivision value.
dstErrError return.
Source:
WlzScalarArithmeticOp.c

References WLZ_BO_DIVIDE, and WlzScalarBinaryOp2().

WlzObject* WlzScalarMulAdd ( WlzObject iObj,
WlzPixelV  m,
WlzPixelV  a,
WlzGreyType  rGType,
WlzErrorNum dstErr 
)

Scales the values of the given Woolz object so that \(v_{new} = m v_{given} + a.\).

Returns
New woolz object or NULL on error.
Parameters
iObjGiven object.
mValue to multiply object values by.
aValue to add to product.
rGTypeRequired grey type for returned object.
dstErrDestination error pointer, may be NULL.

References AlcFree(), AlcMalloc(), _WlzObject::assoc, _WlzIntervalWSpace::colrmn, _WlzValues::core, _WlzDomain::core, _WlzGreyP::dbp, _WlzGreyV::dbv, _WlzObject::domain, _WlzPlaneDomain::domains, _WlzGreyP::flp, _WlzDomain::i, _WlzGreyP::inp, _WlzIntervalDomain::kol1, _WlzIntervalDomain::lastkl, _WlzPlaneDomain::lastpl, _WlzCompoundArray::n, _WlzCompoundArray::o, _WlzDomain::p, _WlzGreyWSpace::pixeltype, _WlzPlaneDomain::plane1, _WlzObject::plist, _WlzGreyP::rgbp, _WlzGreyP::shp, _WlzObject::type, _WlzRagRValues::type, _WlzGreyWSpace::u_grintptr, _WlzGreyP::ubp, _WlzPixelV::v, _WlzValues::v, _WlzObject::values, _WlzVoxelValues::values, _WlzValues::vox, WLZ_2D_DOMAINOBJ, WLZ_3D_DOMAINOBJ, WLZ_CLAMP, WLZ_COMPOUND_ARR_1, WLZ_ERR_DOMAIN_DATA, WLZ_ERR_DOMAIN_NULL, WLZ_ERR_EOO, WLZ_ERR_GREY_TYPE, WLZ_ERR_MEM_ALLOC, WLZ_ERR_NONE, WLZ_ERR_OBJECT_NULL, WLZ_ERR_OBJECT_TYPE, WLZ_ERR_VALUES_NULL, WLZ_GREY_DOUBLE, WLZ_GREY_FLOAT, WLZ_GREY_INT, WLZ_GREY_RGBA, WLZ_GREY_SHORT, WLZ_GREY_TAB_RAGR, WLZ_GREY_UBYTE, WLZ_NINT, WLZ_NULL, WLZ_RGBA_RGBA_SET, WlzAssignValues(), WlzEndGreyScan(), WlzFreeObj(), WlzFreeValueTb(), WlzFreeVoxelValueTb(), WlzGetBackground(), WlzGreyTableTypeToTableType(), WlzGreyValueTableType(), WlzInitGreyScan(), WlzMakeCompoundArray(), WlzMakeMain(), WlzNewValuesVox(), WlzNewValueTb(), WlzNextGreyInterval(), WlzValueConvertPixel(), WlzValueCopyDoubleToDouble(), WlzValueCopyFloatToDouble(), WlzValueCopyIntToDouble(), WlzValueCopyRGBAToDouble(), WlzValueCopyShortToDouble(), and WlzValueCopyUByteToDouble().

Referenced by WlzEffReadObjNifti().

WlzErrorNum WlzScalarBinaryOp ( WlzObject o1,
WlzPixelV  pval,
WlzObject o3,
WlzBinaryOperatorType  op 
)

Perform the given binary operation for each grey value in image o1 with val putting the result in o3. The value table of o3 can be identical to that of o1 to allow overwriting. This function assumes that the domains of each object are the same. Unless overwriting is required then the functions WlzImageAdd, WlzImageSubtract etc. should be used. These return an object which is the intersection of the input objects.

Returns
Woolz error.
Parameters
o1Input object.
pvalOperand value.
o3Oject for the return values. Setting equal to o1 means values will be overwritten.
opOpertor to be applied.
Source:
WlzScalarBinaryOp.c

References AlcFree(), AlcMalloc(), _WlzIntervalWSpace::colrmn, _WlzValues::core, _WlzDomain::core, _WlzGreyP::dbp, _WlzGreyV::dbv, _WlzObject::domain, _WlzPlaneDomain::domains, _WlzGreyP::flp, _WlzGreyV::flv, _WlzGreyP::inp, _WlzIntervalWSpace::intdmn, _WlzGreyV::inv, _WlzIntervalDomain::kol1, _WlzIntervalDomain::lastkl, _WlzPlaneDomain::lastpl, _WlzValues::obj, _WlzPixelP::p, _WlzDomain::p, _WlzGreyWSpace::pixeltype, _WlzPlaneDomain::plane1, _WlzGreyP::shp, _WlzGreyV::shv, _WlzPixelV::type, _WlzPixelP::type, _WlzObject::type, _WlzPlaneDomain::type, _WlzCoreValues::type, _WlzVoxelValues::type, _WlzGreyWSpace::u_grintptr, _WlzGreyP::ubp, _WlzGreyV::ubv, _WlzGreyP::v, _WlzPixelV::v, _WlzObject::values, _WlzVoxelValues::values, _WlzValues::vox, WLZ_2D_DOMAINOBJ, WLZ_3D_DOMAINOBJ, WLZ_EMPTY_OBJ, WLZ_ERR_DOMAIN_NULL, WLZ_ERR_DOMAIN_TYPE, WLZ_ERR_EOO, WLZ_ERR_NONE, WLZ_ERR_OBJECT_NULL, WLZ_ERR_OBJECT_TYPE, WLZ_ERR_PLANEDOMAIN_TYPE, WLZ_ERR_VALUES_NULL, WLZ_ERR_VALUES_TYPE, WLZ_ERR_VOXELVALUES_TYPE, WLZ_GREY_DOUBLE, WLZ_GREY_ERROR, WLZ_GREY_FLOAT, WLZ_GREY_INT, WLZ_GREY_SHORT, WLZ_GREY_UBYTE, WLZ_PLANEDOMAIN_DOMAIN, WLZ_TRANS_OBJ, WLZ_VOXELVALUETABLE_GREY, WlzFreeObj(), WlzGreyTableIsTiled(), WlzInitGreyScan(), WlzMakeMain(), and WlzNextGreyInterval().

Referenced by WlzRGBAScalarBinaryOp(), and WlzScalarBinaryOp2().

WlzObject* WlzScalarFn ( WlzObject sObj,
WlzFnType  fn,
WlzErrorNum dstErr 
)

Computes a new object which shares the domain of the given object, but which has grey values that are the result of applying the given function to the grey values of the given object.

Returns
New domain object.
Parameters
sObjGiven source domainn object with values.
fnScalar function to be applied.
dstErrDestination error pointer, may be NULL.

References _WlzValues::core, _WlzDomain::core, _WlzGreyP::dbp, _WlzGreyV::dbv, _WlzObject::domain, _WlzPlaneDomain::domains, _WlzGreyP::flp, _WlzGreyV::flv, _WlzGreyP::inp, _WlzGreyV::inv, _WlzPlaneDomain::lastpl, _WlzIntervalWSpace::lftpos, _WlzGreyP::lnp, _WlzGreyV::lnv, _WlzDomain::p, _WlzPlaneDomain::plane1, _WlzGreyP::rgbp, _WlzGreyV::rgbv, _WlzIntervalWSpace::rgtpos, _WlzGreyP::shp, _WlzGreyV::shv, _WlzPixelV::type, _WlzObject::type, _WlzGreyWSpace::u_grintptr, _WlzGreyP::ubp, _WlzGreyV::ubv, _WlzPixelV::v, _WlzValues::v, _WlzObject::values, _WlzVoxelValues::values, _WlzValues::vox, WLZ_2D_DOMAINOBJ, WLZ_3D_DOMAINOBJ, WLZ_ERR_DOMAIN_NULL, WLZ_ERR_EOO, WLZ_ERR_GREY_TYPE, WLZ_ERR_NONE, WLZ_ERR_OBJECT_NULL, WLZ_ERR_OBJECT_TYPE, WLZ_ERR_PARAM_DATA, WLZ_ERR_VALUES_NULL, WLZ_FN_SCALAR_EXP, WLZ_FN_SCALAR_INVSQRT, WLZ_FN_SCALAR_LOG, WLZ_FN_SCALAR_MOD, WLZ_FN_SCALAR_SQR, WLZ_FN_SCALAR_SQRT, WLZ_GREY_DOUBLE, WLZ_GREY_ERROR, WLZ_GREY_FLOAT, WLZ_GREY_INT, WLZ_GREY_LONG, WLZ_GREY_RGBA, WLZ_GREY_SHORT, WLZ_GREY_TAB_RAGR, WLZ_GREY_UBYTE, WLZ_VOXELVALUETABLE_GREY, WlzAssignValues(), WlzFreeObj(), WlzGetBackground(), WlzGreyTypeFromObj(), WlzGreyValueTableType(), WlzInitGreyScan(), WlzMakeMain(), WlzMakeVoxelValueTb(), WlzNewValueTb(), WlzNextGreyInterval(), WlzValueConvertPixel(), and WlzValueCopyGreyToGrey().

Referenced by WlzNObjGreyStats(), and WlzSepFilter().