/** @file  psImagePixelManip.h
 *
 *  @brief Contains basic image pixel manipulation operations, as
 *         specified in the PSLIB SDRS sections "Image Pixel Manipulations"
 *
 *  @ingroup Image
 *
 *  @author Robert DeSonia, MHPCC
 *
 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
 *  @date $Date: 2005-06-08 23:40:45 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
 */
#ifndef PS_IMAGE_PIXEL_MANIP_H
#define PS_IMAGE_PIXEL_MANIP_H

#include "psImage.h"
#include "psCoord.h"
#include "psStats.h"
#include "psPixels.h"

/// @addtogroup Image
/// @{

/** Clip image values outside of range to given values
 *
 *  All pixels with values less than min are set to the value vmin.  all pixels
 *  with values greater than max are set to the value vmax. This function is
 *  defined for psU8, psU16, psS8, psS16, psF32, psF64, psC32, and psC64.
 *
 *  @return psS32     The number of clipped pixels
 */
psS32 psImageClip(
    psImage* input,                    ///< the image to clip
    psF64 min,                         ///< the minimum image value allowed
    psF64 vmin,                        ///< the value pixels < min are set to
    psF64 max,                         ///< the maximum image value allowed
    psF64 vmax                         ///< the value pixels > max are set to
);

/** Clip image values outside of a specified complex region
 *
 *  All pixels outside of the rectangular region in complex space formed by
 *  the min and max input parameters are set to the value vmax (if either
 *  the real or imaginary portion exceeds the respective max values), or vmin.
 *  This function is defined for psC32, and psC64 imagery only.
 *
 *  @return psS32     The number of clipped pixels
 */
psS32 psImageClipComplexRegion(
    psImage* input,                    ///< the image to clip
    psC64 min,                         ///< the minimum image value allowed
    psC64 vmin,                        ///< the value pixels < min are set to
    psC64 max,                         ///< the maximum image value allowed
    psC64 vmax                         ///< the value pixels > max are set to
);

/** Clip NaN image pixels to given value.
 *
 *  Pixels with NaN, +Inf, or -Inf values are set to the specified value. This
 *  function is defined for psF32, psF64, psC32, and psC64.
 *
 *  @return psS32     The number of clipped pixels
 */
psS32 psImageClipNaN(
    psImage* input,                    ///< the image to clip
    psF64 value                        ///< the value to set all NaN/Inf values to
);

/** Overlay subregion of image with another image
 *
 *  Replace the pixels in the image which correspond to the pixels in OVERLAY
 *  with values derived from the IMAGE and OVERLAY based on the given operator
 *  OP.  Valid operators are "=" (set image value to OVERLAY value), "+" (add
 *  OVERLAY value to image value), "-" (subtract OVERLAY from image), "*"
 *  (multiply OVERLAY times image), "/" (divide image by OVERLAY).  This
 *  function is defined for psU8, psS8, psS16, psF32, psF64, psC32, and psC64.
 *
 *  @return psS32         0 if success, non-zero if failed.
 */
psS32 psImageOverlaySection(
    psImage* image,                    ///< target image
    const psImage* overlay,            ///< the overlay image
    psS32 col0,                        ///< the column to start overlay
    psS32 row0,                        ///< the row to start overlay
    const char *op                     ///< the operation to perform for overlay
);

#endif // #ifndef PS_IMAGE_PIXEL_MANIP_H
