IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 820


Ignore:
Timestamp:
Jun 1, 2004, 10:00:08 AM (22 years ago)
Author:
desonia
Message:

added psImageClip* functions.

Location:
trunk/psLib/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/image/psImage.c

    r816 r820  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-05-29 01:42:12 $
     11 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-06-01 20:00:08 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1818/*  INCLUDE FILES                                                             */
    1919/******************************************************************************/
     20
    2021#include <string.h>
     22#include <math.h>
    2123
    2224#include "psMemory.h"
     
    384386}
    385387
     388int psImageClip(psImage* input,float min,float vmin,float max,float vmax)
     389{
     390    int numClipped = 0;
     391    psU32 numRows;
     392    psU32 numCols;
     393
     394    if (input == NULL) {
     395        return 0;
     396    }
     397    numRows = input->numRows;
     398    numCols = input->numCols;
     399
     400    switch (input->type.type) {
     401
     402        #define psImageClipCase(type) \
     403    case PS_TYPE_##type: { \
     404            ps##type minimum = (ps##type) min; \
     405            ps##type maximum = (ps##type) max; \
     406            for (psU32 row = 0;row<numRows;row++) { \
     407                ps##type* inputRow = input->data.type[row]; \
     408                for (psU32 col = 0; col < numCols; col++) { \
     409                    if (inputRow[col] < minimum) { \
     410                        inputRow[col] = (ps##type)vmin; \
     411                        numClipped++; \
     412                    } else if (inputRow[col] > maximum) { \
     413                        inputRow[col] = (ps##type)vmax; \
     414                        numClipped++; \
     415                    } \
     416                } \
     417            } \
     418        } \
     419        break;
     420
     421        psImageClipCase(S8)
     422        psImageClipCase(S16)
     423        psImageClipCase(S32)
     424        psImageClipCase(S64)
     425        psImageClipCase(U8)
     426        psImageClipCase(U16)
     427        psImageClipCase(U32)
     428        psImageClipCase(U64)
     429        psImageClipCase(F32)
     430        psImageClipCase(F64)
     431
     432    default:
     433        psError(__func__,"psImageClip does not support the given datatype (%d)",
     434                input->type.type);
     435    }
     436
     437    return numClipped;
     438}
     439
     440int psImageClipNaN(psImage* input,float value)
     441{
     442    int numClipped = 0;
     443    psU32 numRows;
     444    psU32 numCols;
     445
     446    if (input == NULL) {
     447        return 0;
     448    }
     449    numRows = input->numRows;
     450    numCols = input->numCols;
     451
     452    switch (input->type.type) {
     453
     454        #define psImageClipNaNCase(type) \
     455    case PS_TYPE_##type: { \
     456            for (psU32 row = 0;row<numRows;row++) { \
     457                ps##type* inputRow = input->data.type[row]; \
     458                for (psU32 col = 0; col < numCols; col++) { \
     459                    if (! isfinite(inputRow[col])) { \
     460                        inputRow[col] = (ps##type)value; \
     461                        numClipped++; \
     462                    } \
     463                } \
     464            } \
     465        } \
     466        break;
     467
     468        psImageClipNaNCase(F32)
     469        psImageClipNaNCase(F64)
     470        psImageClipNaNCase(C32)
     471        psImageClipNaNCase(C64)
     472
     473    default:
     474        psError(__func__,"psImageClip does not support the given datatype (%d)",
     475                input->type.type);
     476    }
     477
     478    return numClipped;
     479}
  • trunk/psLib/src/image/psImage.h

    r816 r820  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-05-29 01:42:12 $
     11 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-06-01 20:00:08 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8888/** Resize a given image to the given size/type.
    8989 *
    90  *  return psImage* Resized psImage.
     90 *  @return psImage* Resized psImage.
    9191 *
    9292 */
     
    127127/** Frees all children of a psImage.
    128128 *
    129  *  return int      Number of children freed.
     129 *  @return int      Number of children freed.
    130130 *
    131131 */
     
    137137/** Makes a copy of a psImage
    138138 *
    139  * return psImage*  Copy of the input psImage.  This may not be equal to the
     139 * @return psImage*  Copy of the input psImage.  This may not be equal to the
    140140 * output parameter
    141141 *
     
    152152);
    153153
     154/** Clip image values outside of tange to given values
     155 *
     156 *  All pixels with values less than min are set to the value vmin.  all pixels
     157 *  with values greater than max are set to the value vmax. This function is
     158 *  defined for psU8, psU16, psS8, psS16, psF32, psF64, psC32, and psC64.
     159 *
     160 *  @return int     The number of clipped pixels
     161 */
     162int psImageClip(
     163    psImage* input,                 ///< the image to clip
     164    psF32 min,                      ///< the minimum image value allowed
     165    psF32 vmin,                     ///< the value pixels < min are set to
     166    psF32 max,                      ///< the maximum image value allowed
     167    psF32 vmax                      ///< the value pixels > max are set to
     168);
     169
     170/** Clip NaN image pixels to given value.
     171 *
     172 *  Pixels with NaN, +Inf, or -Inf values are set to the specified value. This
     173 *  function is defined for psF32, psF64, psC32, and psC64.
     174 *
     175 *  @return int     The number of clipped pixels
     176 */
     177int psImageClipNaN(
     178    psImage* input,                 ///< the image to clip
     179    psF32 value                     ///< the value to set all NaN/Inf values to
     180);
     181
     182/** Overlay subregion of image with another image
     183 *
     184 *  Replace the pixels in the image which correspond to the pixels in OVERLAY
     185 *  with values derived from the IMAGE and OVERLAY based on the given operator
     186 *  OP.  Valid operators are "=" (set image value to OVERLAY value), "+" (add
     187 *  OVERLAY value to image value), "-" (subtract OVERLAY from image), "*"
     188 *  (multiply OVERLAY times image), "/" (divide image by OVERLAY).  This
     189 *  function is defined for psU8, psS8, psS16, psF32, psF64, psC32, and psC64.
     190 *
     191 *  @return int         0 if success, non-zero if failed.
     192 */
     193int psImageOverlaySection(
     194    psImage* image,                 ///< target image
     195    const psImage* overlay,         ///< the overlay image
     196    int col0,                       ///< the column to start overlay
     197    int row0,                       ///< the row to start overlay
     198    const char* op                  ///< the operation to perform for overlay
     199);
    154200
    155201#endif
  • trunk/psLib/src/mathtypes/psImage.c

    r816 r820  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-05-29 01:42:12 $
     11 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-06-01 20:00:08 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1818/*  INCLUDE FILES                                                             */
    1919/******************************************************************************/
     20
    2021#include <string.h>
     22#include <math.h>
    2123
    2224#include "psMemory.h"
     
    384386}
    385387
     388int psImageClip(psImage* input,float min,float vmin,float max,float vmax)
     389{
     390    int numClipped = 0;
     391    psU32 numRows;
     392    psU32 numCols;
     393
     394    if (input == NULL) {
     395        return 0;
     396    }
     397    numRows = input->numRows;
     398    numCols = input->numCols;
     399
     400    switch (input->type.type) {
     401
     402        #define psImageClipCase(type) \
     403    case PS_TYPE_##type: { \
     404            ps##type minimum = (ps##type) min; \
     405            ps##type maximum = (ps##type) max; \
     406            for (psU32 row = 0;row<numRows;row++) { \
     407                ps##type* inputRow = input->data.type[row]; \
     408                for (psU32 col = 0; col < numCols; col++) { \
     409                    if (inputRow[col] < minimum) { \
     410                        inputRow[col] = (ps##type)vmin; \
     411                        numClipped++; \
     412                    } else if (inputRow[col] > maximum) { \
     413                        inputRow[col] = (ps##type)vmax; \
     414                        numClipped++; \
     415                    } \
     416                } \
     417            } \
     418        } \
     419        break;
     420
     421        psImageClipCase(S8)
     422        psImageClipCase(S16)
     423        psImageClipCase(S32)
     424        psImageClipCase(S64)
     425        psImageClipCase(U8)
     426        psImageClipCase(U16)
     427        psImageClipCase(U32)
     428        psImageClipCase(U64)
     429        psImageClipCase(F32)
     430        psImageClipCase(F64)
     431
     432    default:
     433        psError(__func__,"psImageClip does not support the given datatype (%d)",
     434                input->type.type);
     435    }
     436
     437    return numClipped;
     438}
     439
     440int psImageClipNaN(psImage* input,float value)
     441{
     442    int numClipped = 0;
     443    psU32 numRows;
     444    psU32 numCols;
     445
     446    if (input == NULL) {
     447        return 0;
     448    }
     449    numRows = input->numRows;
     450    numCols = input->numCols;
     451
     452    switch (input->type.type) {
     453
     454        #define psImageClipNaNCase(type) \
     455    case PS_TYPE_##type: { \
     456            for (psU32 row = 0;row<numRows;row++) { \
     457                ps##type* inputRow = input->data.type[row]; \
     458                for (psU32 col = 0; col < numCols; col++) { \
     459                    if (! isfinite(inputRow[col])) { \
     460                        inputRow[col] = (ps##type)value; \
     461                        numClipped++; \
     462                    } \
     463                } \
     464            } \
     465        } \
     466        break;
     467
     468        psImageClipNaNCase(F32)
     469        psImageClipNaNCase(F64)
     470        psImageClipNaNCase(C32)
     471        psImageClipNaNCase(C64)
     472
     473    default:
     474        psError(__func__,"psImageClip does not support the given datatype (%d)",
     475                input->type.type);
     476    }
     477
     478    return numClipped;
     479}
  • trunk/psLib/src/mathtypes/psImage.h

    r816 r820  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-05-29 01:42:12 $
     11 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-06-01 20:00:08 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8888/** Resize a given image to the given size/type.
    8989 *
    90  *  return psImage* Resized psImage.
     90 *  @return psImage* Resized psImage.
    9191 *
    9292 */
     
    127127/** Frees all children of a psImage.
    128128 *
    129  *  return int      Number of children freed.
     129 *  @return int      Number of children freed.
    130130 *
    131131 */
     
    137137/** Makes a copy of a psImage
    138138 *
    139  * return psImage*  Copy of the input psImage.  This may not be equal to the
     139 * @return psImage*  Copy of the input psImage.  This may not be equal to the
    140140 * output parameter
    141141 *
     
    152152);
    153153
     154/** Clip image values outside of tange to given values
     155 *
     156 *  All pixels with values less than min are set to the value vmin.  all pixels
     157 *  with values greater than max are set to the value vmax. This function is
     158 *  defined for psU8, psU16, psS8, psS16, psF32, psF64, psC32, and psC64.
     159 *
     160 *  @return int     The number of clipped pixels
     161 */
     162int psImageClip(
     163    psImage* input,                 ///< the image to clip
     164    psF32 min,                      ///< the minimum image value allowed
     165    psF32 vmin,                     ///< the value pixels < min are set to
     166    psF32 max,                      ///< the maximum image value allowed
     167    psF32 vmax                      ///< the value pixels > max are set to
     168);
     169
     170/** Clip NaN image pixels to given value.
     171 *
     172 *  Pixels with NaN, +Inf, or -Inf values are set to the specified value. This
     173 *  function is defined for psF32, psF64, psC32, and psC64.
     174 *
     175 *  @return int     The number of clipped pixels
     176 */
     177int psImageClipNaN(
     178    psImage* input,                 ///< the image to clip
     179    psF32 value                     ///< the value to set all NaN/Inf values to
     180);
     181
     182/** Overlay subregion of image with another image
     183 *
     184 *  Replace the pixels in the image which correspond to the pixels in OVERLAY
     185 *  with values derived from the IMAGE and OVERLAY based on the given operator
     186 *  OP.  Valid operators are "=" (set image value to OVERLAY value), "+" (add
     187 *  OVERLAY value to image value), "-" (subtract OVERLAY from image), "*"
     188 *  (multiply OVERLAY times image), "/" (divide image by OVERLAY).  This
     189 *  function is defined for psU8, psS8, psS16, psF32, psF64, psC32, and psC64.
     190 *
     191 *  @return int         0 if success, non-zero if failed.
     192 */
     193int psImageOverlaySection(
     194    psImage* image,                 ///< target image
     195    const psImage* overlay,         ///< the overlay image
     196    int col0,                       ///< the column to start overlay
     197    int row0,                       ///< the row to start overlay
     198    const char* op                  ///< the operation to perform for overlay
     199);
    154200
    155201#endif
Note: See TracChangeset for help on using the changeset viewer.