Changeset 21183 for trunk/psLib
- Timestamp:
- Jan 26, 2009, 8:40:07 PM (17 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 1 added
- 48 edited
-
fft/psImageFFT.c (modified) (4 diffs)
-
fft/psImageFFT.h (modified) (2 diffs)
-
fits/psFitsImage.c (modified) (9 diffs)
-
fits/psFitsImage.h (modified) (6 diffs)
-
fits/psFitsScale.c (modified) (3 diffs)
-
fits/psFitsScale.h (modified) (1 diff)
-
imageops/psImageBackground.c (modified) (2 diffs)
-
imageops/psImageBackground.h (modified) (2 diffs)
-
imageops/psImageConvolve.c (modified) (45 diffs)
-
imageops/psImageConvolve.h (modified) (7 diffs)
-
imageops/psImageGeomManip.c (modified) (13 diffs)
-
imageops/psImageGeomManip.h (modified) (4 diffs)
-
imageops/psImageInterpolate.c (modified) (14 diffs)
-
imageops/psImageInterpolate.h (modified) (4 diffs)
-
imageops/psImageMap.c (modified) (6 diffs)
-
imageops/psImageMapFit.c (modified) (11 diffs)
-
imageops/psImageMapFit.h (modified) (4 diffs)
-
imageops/psImageMaskOps.c (modified) (14 diffs)
-
imageops/psImageMaskOps.h (modified) (6 diffs)
-
imageops/psImagePixelExtract.c (modified) (17 diffs)
-
imageops/psImagePixelExtract.h (modified) (4 diffs)
-
imageops/psImagePixelInterpolate.c (modified) (11 diffs)
-
imageops/psImagePixelInterpolate.h (modified) (2 diffs)
-
imageops/psImageStats.c (modified) (7 diffs)
-
imageops/psImageStats.h (modified) (4 diffs)
-
mask.notes.txt (added)
-
math/psClip.c (modified) (6 diffs)
-
math/psClip.h (modified) (3 diffs)
-
math/psConstants.h (modified) (2 diffs)
-
math/psHistogram.c (modified) (4 diffs)
-
math/psHistogram.h (modified) (2 diffs)
-
math/psMinimizeLMM.c (modified) (10 diffs)
-
math/psMinimizeLMM_ND.c (modified) (10 diffs)
-
math/psMinimizePolyFit.c (modified) (48 diffs)
-
math/psMinimizePolyFit.h (modified) (9 diffs)
-
math/psMinimizePowell.c (modified) (11 diffs)
-
math/psPolynomialMD.c (modified) (17 diffs)
-
math/psPolynomialMD.h (modified) (2 diffs)
-
math/psPolynomialUtils.c (modified) (5 diffs)
-
math/psPolynomialUtils.h (modified) (2 diffs)
-
math/psStats.c (modified) (40 diffs)
-
math/psStats.h (modified) (2 diffs)
-
mathtypes/psVector.c (modified) (3 diffs)
-
mathtypes/psVector.h (modified) (2 diffs)
-
sys/psType.h (modified) (2 diffs)
-
types/psMetadata.c (modified) (4 diffs)
-
types/psMetadata.h (modified) (3 diffs)
-
types/psPixels.c (modified) (6 diffs)
-
types/psPixels.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/fft/psImageFFT.c
r20566 r21183 6 6 /// @author Robert DeSonia, MHPCC 7 7 /// 8 /// @version $Revision: 1.2 8$ $Name: not supported by cvs2svn $9 /// @date $Date: 200 8-11-06 23:36:20$8 /// @version $Revision: 1.29 $ $Name: not supported by cvs2svn $ 9 /// @date $Date: 2009-01-27 06:39:37 $ 10 10 /// 11 11 /// Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 318 318 319 319 320 psImage *psImageConvolveFFT(psImage *out, const psImage *in, const psImage *mask, ps MaskType maskVal,320 psImage *psImageConvolveFFT(psImage *out, const psImage *in, const psImage *mask, psImageMaskType maskVal, 321 321 const psKernel *kernel) 322 322 { … … 326 326 if (mask) { 327 327 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 328 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, NULL);328 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 329 329 PS_ASSERT_IMAGES_SIZE_EQUAL(mask, in, NULL); 330 330 } … … 464 464 for (int y = 0; y < numRows; y++) { 465 465 for (int x = 0; x < numCols; x++) { 466 if (mask->data.PS_TYPE_ MASK_DATA[y][x] & maskVal) {466 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) { 467 467 data[x + paddedCols * y] = 0; 468 468 } -
trunk/psLib/src/fft/psImageFFT.h
r17320 r21183 5 5 /// @author Robert DeSonia, MHPCC 6 6 /// 7 /// @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $8 /// @date $Date: 200 8-04-04 22:44:56$7 /// @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 8 /// @date $Date: 2009-01-27 06:39:37 $ 9 9 /// Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 10 10 /// … … 70 70 const psImage *in, ///< Image to convolve 71 71 const psImage *mask, ///< Corresponding mask 72 ps MaskType maskVal,///< Value to mask72 psImageMaskType maskVal, ///< Value to mask 73 73 const psKernel *kernel ///< kernel to colvolve with 74 74 ); -
trunk/psLib/src/fits/psFitsImage.c
r19384 r21183 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.4 0$ $Name: not supported by cvs2svn $10 * @date $Date: 200 8-09-05 08:08:33$9 * @version $Revision: 1.41 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:37 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 251 251 const psImage *image, // Image to convert 252 252 const psImage *mask, // Mask image, or NULL 253 ps MaskType maskVal, // Value to mask253 psImageMaskType maskVal, // Value to mask 254 254 psRandom *rng, // Random number generator 255 255 bool newScaleZero // Determine a new BSCALE and BZERO? … … 506 506 507 507 bool psFitsWriteImageWithMask(psFits *fits, psMetadata *header, const psImage *input, 508 const psImage *mask, ps MaskType maskVal, int numZPlanes,508 const psImage *mask, psImageMaskType maskVal, int numZPlanes, 509 509 const char *extname) 510 510 { … … 525 525 526 526 bool psFitsInsertImageWithMask(psFits *fits, psMetadata *header, const psImage *image, 527 const psImage *mask, ps MaskType maskVal, int numZPlanes,527 const psImage *mask, psImageMaskType maskVal, int numZPlanes, 528 528 const char *extname, bool after) 529 529 { … … 532 532 PS_ASSERT_IMAGE_NON_NULL(image, false); 533 533 if (mask) { 534 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, false);534 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false); 535 535 PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, false); 536 536 } … … 706 706 } 707 707 708 bool psFitsUpdateImageWithMask(psFits *fits, const psImage *input, const psImage *mask, ps MaskType maskVal,708 bool psFitsUpdateImageWithMask(psFits *fits, const psImage *input, const psImage *mask, psImageMaskType maskVal, 709 709 int x0, int y0, int z) 710 710 { … … 713 713 PS_ASSERT_IMAGE_NON_NULL(input, false); 714 714 if (mask) { 715 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, false);715 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false); 716 716 PS_ASSERT_IMAGES_SIZE_EQUAL(mask, input, false); 717 717 } … … 896 896 897 897 bool psFitsWriteImageCubeWithMask(psFits *fits, psMetadata *header, const psArray *input, 898 const psArray *masks, ps MaskType maskVal, const char *extname)898 const psArray *masks, psImageMaskType maskVal, const char *extname) 899 899 { 900 900 PS_ASSERT_FITS_NON_NULL(fits, false); … … 976 976 977 977 bool psFitsUpdateImageCubeWithMask(psFits *fits, const psArray *input, 978 const psArray *masks, ps MaskType maskVal, int x0, int y0)978 const psArray *masks, psImageMaskType maskVal, int x0, int y0) 979 979 { 980 980 PS_ASSERT_FITS_NON_NULL(fits, false); -
trunk/psLib/src/fits/psFitsImage.h
r19384 r21183 4 4 * @author Robert DeSonia, MHPCC 5 5 * 6 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $7 * @date $Date: 200 8-09-05 08:08:33$6 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-01-27 06:39:37 $ 8 8 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 9 9 */ … … 74 74 const psImage *input, ///< the image to output 75 75 const psImage *mask, ///< the mask image 76 ps MaskType maskVal,///< value to mask76 psImageMaskType maskVal, ///< value to mask 77 77 int depth, ///< the number of z-planes of the FITS image data cube 78 78 const char *extname ///< FITS extension name … … 101 101 const psImage *input, ///< the image to output 102 102 const psImage *mask, ///< the mask image 103 ps MaskType maskVal,///< value to mask103 psImageMaskType maskVal, ///< value to mask 104 104 int depth, ///< the number of z-planes of the FITS image data cube 105 105 const char *extname, ///< FITS extension name … … 128 128 const psImage *input, ///< the image to output 129 129 const psImage *mask, ///< the mask image 130 ps MaskType maskVal,///< value to mask130 psImageMaskType maskVal, ///< value to mask 131 131 int x0, ///< psImage's x-axis origin in FITS image coordinates 132 132 int y0, ///< psImage's y-axis origin in FITS image coordinates … … 157 157 const psArray *input, ///< Array of images 158 158 const psArray *masks, ///< Array of masks 159 ps MaskType maskVal,///< Value to mask159 psImageMaskType maskVal, ///< Value to mask 160 160 const char *extname ///< Name of extension 161 161 ); … … 175 175 const psArray *input, ///< Array of images 176 176 const psArray *masks, ///< Array of masks 177 ps MaskType maskVal,///< Value to mask177 psImageMaskType maskVal, ///< Value to mask 178 178 int x0, ///< x origin of images in FITS image coordinates 179 179 int y0 ///< y origin of images in FITS image coordinates -
trunk/psLib/src/fits/psFitsScale.c
r19383 r21183 100 100 const psImage *image, // Image to scale 101 101 const psImage *mask, // Mask image 102 ps MaskType maskVal, // Value to mask102 psImageMaskType maskVal, // Value to mask 103 103 const psFitsOptions *options // FITS options 104 104 ) … … 167 167 168 168 bool psFitsScaleDetermine(double *bscale, double *bzero, long *blank, const psImage *image, 169 const psImage *mask, ps MaskType maskVal, const psFits *fits)169 const psImage *mask, psImageMaskType maskVal, const psFits *fits) 170 170 { 171 171 PS_ASSERT_PTR_NON_NULL(bscale, false); … … 174 174 PS_ASSERT_IMAGE_NON_NULL(image, false); 175 175 if (mask) { 176 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, false);176 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false); 177 177 PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, false); 178 178 } -
trunk/psLib/src/fits/psFitsScale.h
r19383 r21183 13 13 const psImage *image, ///< Image to scale 14 14 const psImage *mask, ///< Mask image 15 ps MaskType maskVal, ///< Value to mask15 psImageMaskType maskVal, ///< Value to mask 16 16 const psFits *fits ///< FITS options 17 17 ); -
trunk/psLib/src/imageops/psImageBackground.c
r20216 r21183 18 18 // XXX allow the user to choose the stats method? 19 19 // (SAMPLE_MEAN, CLIPPED_MEAN, ROBUST_MEDIAN, FITTED_MEAN) 20 bool psImageBackground(psStats *stats, psVector **sample, const psImage *image, const psImage *mask, ps MaskType maskValue, psRandom *rng)20 bool psImageBackground(psStats *stats, psVector **sample, const psImage *image, const psImage *mask, psImageMaskType maskValue, psRandom *rng) 21 21 { 22 22 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 23 23 if (mask) { 24 24 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 25 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ U8, NULL);25 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 26 26 PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, NULL); 27 27 } … … 63 63 int iy = pixel / nx; 64 64 65 if (!isfinite(image->data.F32[iy][ix]) || (mask && mask->data. U8[iy][ix] & maskValue)) {65 if (!isfinite(image->data.F32[iy][ix]) || (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskValue)) { 66 66 continue; 67 67 } -
trunk/psLib/src/imageops/psImageBackground.h
r16115 r21183 5 5 * @author EAM, IfA 6 6 * 7 * $Revision: 1. 6$ $Name: not supported by cvs2svn $8 * $Date: 200 8-01-17 22:07:33$7 * $Revision: 1.7 $ $Name: not supported by cvs2svn $ 8 * $Date: 2009-01-27 06:39:37 $ 9 9 * Copyright 2004-2005 IfA, University of Hawaii 10 10 */ … … 27 27 const psImage *image, // Image for which to get the background 28 28 const psImage *mask, // Mask image 29 ps MaskType maskValue, // Mask pixels which this mask value29 psImageMaskType maskValue, // Mask pixels which this mask value 30 30 psRandom *rng // Random number generator (for pixel selection) 31 31 ); -
trunk/psLib/src/imageops/psImageConvolve.c
r20830 r21183 7 7 /// @author Eugene Magnier, IfA 8 8 /// 9 /// @version $Revision: 1.8 1$ $Name: not supported by cvs2svn $10 /// @date $Date: 200 8-11-26 00:43:12$9 /// @version $Revision: 1.82 $ $Name: not supported by cvs2svn $ 10 /// @date $Date: 2009-01-27 06:39:37 $ 11 11 /// 12 12 /// Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 319 319 } 320 320 321 psImage *psImageConvolveMaskDirect(psImage *out, const psImage *mask, ps MaskType maskVal,322 ps MaskType setVal, int xMin, int xMax, int yMin, int yMax)321 psImage *psImageConvolveMaskDirect(psImage *out, const psImage *mask, psImageMaskType maskVal, 322 psImageMaskType setVal, int xMin, int xMax, int yMin, int yMax) 323 323 { 324 324 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 325 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, NULL);325 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 326 326 if (out == mask && ((maskVal & setVal) || !setVal)) { 327 327 psError(PS_ERR_BAD_PARAMETER_VALUE, true, … … 352 352 if (!out) { 353 353 // Propagate the non-masked values 354 out = (psImage*)psBinaryOp(NULL, (const psPtr)mask, "&", psScalarAlloc(~maskVal, PS_TYPE_ MASK));354 out = (psImage*)psBinaryOp(NULL, (const psPtr)mask, "&", psScalarAlloc(~maskVal, PS_TYPE_IMAGE_MASK)); 355 355 } 356 356 357 357 // Dereference mask images 358 ps MaskType **maskData = mask->data.PS_TYPE_MASK_DATA;359 ps MaskType **outData = out->data.PS_TYPE_MASK_DATA;358 psImageMaskType **maskData = mask->data.PS_TYPE_IMAGE_MASK_DATA; 359 psImageMaskType **outData = out->data.PS_TYPE_IMAGE_MASK_DATA; 360 360 361 361 if (setVal) { … … 376 376 for (int row = 0; row < numRows; row++) { 377 377 for (int col = 0; col < numCols; col++) { 378 ps MaskType pixel = outData[row][col]; // Pixel value to set378 psImageMaskType pixel = outData[row][col]; // Pixel value to set 379 379 if (pixel & maskVal) { 380 380 // Already done this one … … 395 395 396 396 397 psImage *psImageConvolveMaskFFT(psImage *out, const psImage *mask, ps MaskType maskVal,398 ps MaskType setVal, int xMin, int xMax, int yMin, int yMax, float thresh)397 psImage *psImageConvolveMaskFFT(psImage *out, const psImage *mask, psImageMaskType maskVal, 398 psImageMaskType setVal, int xMin, int xMax, int yMin, int yMax, float thresh) 399 399 { 400 400 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 401 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, NULL);401 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 402 402 PS_ASSERT_FLOAT_LARGER_THAN(thresh, 0.0, NULL); 403 403 PS_ASSERT_FLOAT_LESS_THAN(thresh, 1.0, NULL); … … 431 431 for (int y = 0; y < numRows; y++) { 432 432 for (int x = 0; x < numCols; x++) { 433 if (mask->data.PS_TYPE_ MASK_DATA[y][x] & maskVal) {433 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) { 434 434 onoff->data.F32[y][x] = 1.0; 435 435 } … … 452 452 453 453 if (!out) { 454 out = psImageAlloc(numCols, numRows, PS_TYPE_ MASK);454 out = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 455 455 } 456 456 for (int y = 0; y < numRows; y++) { 457 457 for (int x = 0; x < numCols; x++) { 458 out->data.PS_TYPE_ MASK_DATA[y][x] = (convolved->data.F32[y][x] >= thresh) ?459 (mask->data.PS_TYPE_ MASK_DATA[y][x] | setVal) : mask->data.PS_TYPE_MASK_DATA[y][x];458 out->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = (convolved->data.F32[y][x] >= thresh) ? 459 (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] | setVal) : mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x]; 460 460 } 461 461 } … … 651 651 case PS_TYPE_##TYPE: { \ 652 652 psImage *calculation = psImageAlloc(numRows, numCols, PS_TYPE_##TYPE); /* Calculation image; BW */ \ 653 psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_ MASK); /* Mask for calculation image; BW */ \653 psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_IMAGE_MASK); /* Mask for calculation image; BW */ \ 654 654 \ 655 655 /** Smooth in X direction **/ \ … … 658 658 int xMin = PS_MAX(i - size, 0); \ 659 659 int xMax = PS_MIN(i + size, xLast); \ 660 const ps MaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[j][xMin]; \660 const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[j][xMin]; \ 661 661 const ps##TYPE *imageData = &image->data.TYPE[j][xMin]; \ 662 662 int uMin = - PS_MIN(i, size); /* Minimum kernel index */ \ … … 673 673 /* BW */ \ 674 674 calculation->data.TYPE[i][j] = sumIG / sumG; \ 675 calcMask->data.PS_TYPE_ MASK_DATA[i][j] = 0; \675 calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0; \ 676 676 } else { \ 677 677 /* BW */ \ 678 calcMask->data.PS_TYPE_ MASK_DATA[i][j] = 0xFF; \678 calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0xFF; \ 679 679 } \ 680 680 } \ … … 688 688 int yMin = PS_MAX(j - size, 0); \ 689 689 int yMax = PS_MIN(j + size, yLast); \ 690 const ps MaskType *maskData = &calcMask->data.PS_TYPE_MASK_DATA[i][yMin]; /* BW */ \690 const psImageMaskType *maskData = &calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][yMin]; /* BW */ \ 691 691 const ps##TYPE *imageData = &calculation->data.TYPE[i][yMin]; /* BW */ \ 692 692 int vMin = - PS_MIN(j, size); /* Minimum kernel index */ \ … … 714 714 const psImage *image, 715 715 const psImage *mask, 716 ps MaskType maskVal,716 psImageMaskType maskVal, 717 717 float sigma, 718 718 float numSigma, … … 721 721 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 722 722 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 723 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, NULL);723 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 724 724 PS_ASSERT_IMAGES_SIZE_EQUAL(image, mask, NULL); 725 725 … … 751 751 case PS_TYPE_F32: { 752 752 psImage *calculation = psImageAlloc(numRows, numCols, PS_TYPE_F32); /* Calculation image; BW */ 753 psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_ MASK); /* Mask for calculation image; BW */753 psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_IMAGE_MASK); /* Mask for calculation image; BW */ 754 754 755 755 /** Smooth in X direction **/ … … 758 758 int xMin = PS_MAX(i - size, 0); 759 759 int xMax = PS_MIN(i + size, xLast); 760 const ps MaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[j][xMin];760 const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[j][xMin]; 761 761 const psF32 *imageData = &image->data.F32[j][xMin]; 762 762 int uMin = - PS_MIN(i, size); /* Minimum kernel index */ … … 776 776 /* BW */ 777 777 calculation->data.F32[i][j] = sumIG / sumG; 778 calcMask->data.PS_TYPE_ MASK_DATA[i][j] = 0;778 calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0; 779 779 } else { 780 780 /* BW */ 781 calcMask->data.PS_TYPE_ MASK_DATA[i][j] = 0xFF;781 calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0xFF; 782 782 } 783 783 } … … 791 791 int yMin = PS_MAX(j - size, 0); 792 792 int yMax = PS_MIN(j + size, yLast); 793 const ps MaskType *maskData = &calcMask->data.PS_TYPE_MASK_DATA[i][yMin]; /* BW */793 const psImageMaskType *maskData = &calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][yMin]; /* BW */ 794 794 const psF32 *imageData = &calculation->data.F32[i][yMin]; /* BW */ 795 795 int vMin = - PS_MIN(j, size); /* Minimum kernel index */ … … 832 832 const psImage *image, 833 833 const psImage *mask, 834 ps MaskType maskVal,834 psImageMaskType maskVal, 835 835 psVector *gaussNorm, 836 836 float minGauss, … … 848 848 int xMin = PS_MAX(i - size, 0); 849 849 int xMax = PS_MIN(i + size, xLast); 850 const ps MaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[j][xMin];850 const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[j][xMin]; 851 851 const psF32 *imageData = &image->data.F32[j][xMin]; 852 852 int uMin = - PS_MIN(i, size); /* Minimum kernel index */ … … 863 863 /* BW */ 864 864 calculation->data.F32[i][j] = sumIG / sumG; 865 calcMask->data.PS_TYPE_ MASK_DATA[i][j] = 0;865 calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0; 866 866 } else { 867 867 /* BW */ 868 calcMask->data.PS_TYPE_ MASK_DATA[i][j] = 0xFF;868 calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0xFF; 869 869 } 870 870 } … … 876 876 psImage *calculation, 877 877 psImage *calcMask, 878 ps MaskType maskVal,878 psImageMaskType maskVal, 879 879 psVector *gaussNorm, 880 880 float minGauss, … … 892 892 int yMin = PS_MAX(j - size, 0); 893 893 int yMax = PS_MIN(j + size, yLast); 894 const ps MaskType *maskData = &calcMask->data.PS_TYPE_MASK_DATA[i][yMin]; /* BW */894 const psImageMaskType *maskData = &calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][yMin]; /* BW */ 895 895 const psF32 *imageData = &calculation->data.F32[i][yMin]; /* BW */ 896 896 int vMin = - PS_MIN(j, size); /* Minimum kernel index */ … … 921 921 const psImage *mask = job->args->data[3]; // input mask 922 922 923 ps MaskType maskVal = PS_SCALAR_VALUE(job->args->data[4],U8);923 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA); 924 924 psVector *gaussNorm = job->args->data[5]; // gauss kernel 925 925 float minGauss = PS_SCALAR_VALUE(job->args->data[6],F32); … … 941 941 psImage *calculation = job->args->data[1]; // calculation image 942 942 psImage *calcMask = job->args->data[2]; // calculation mask 943 ps MaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],U8);943 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA); 944 944 945 945 psVector *gaussNorm = job->args->data[4]; // gauss kernel … … 956 956 const psImage *image, 957 957 const psImage *mask, 958 ps MaskType maskVal,958 psImageMaskType maskVal, 959 959 float sigma, 960 960 float numSigma, … … 963 963 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 964 964 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 965 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, NULL);965 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 966 966 PS_ASSERT_IMAGES_SIZE_EQUAL(image, mask, NULL); 967 967 … … 999 999 case PS_TYPE_F32: { 1000 1000 psImage *calculation = psImageAlloc(numRows, numCols, PS_TYPE_F32); /* Calculation image; BW */ 1001 psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_ MASK); /* Mask for calculation image; BW */1001 psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_IMAGE_MASK); /* Mask for calculation image; BW */ 1002 1002 1003 1003 /** Smooth in X direction **/ … … 1011 1011 psArrayAdd(job->args, 1, (psImage *) image); // cast away const 1012 1012 psArrayAdd(job->args, 1, (psImage *) mask); // cast away const 1013 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_ U8);1013 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 1014 1014 psArrayAdd(job->args, 1, gaussNorm); 1015 1015 PS_ARRAY_ADD_SCALAR(job->args, minGauss, PS_TYPE_F32); … … 1046 1046 psArrayAdd(job->args, 1, calculation); 1047 1047 psArrayAdd(job->args, 1, calcMask); 1048 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_ U8);1048 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 1049 1049 psArrayAdd(job->args, 1, gaussNorm); 1050 1050 PS_ARRAY_ADD_SCALAR(job->args, minGauss, PS_TYPE_F32); … … 1091 1091 bool psImageSmoothMaskF32 (psImage *image, 1092 1092 psImage *mask, 1093 ps MaskType maskVal,1093 psImageMaskType maskVal, 1094 1094 double sigma, 1095 1095 double Nsigma) … … 1122 1122 psVector *calculation = psVectorAlloc(Nx, PS_TYPE_F32); 1123 1123 for (int j = 0; j < Ny; j++) { 1124 ps U8 *vm = mask->data.U8[j];1124 psImageMaskType *vm = mask->data.PS_TYPE_IMAGE_MASK_DATA[j]; 1125 1125 psF32 *vi = image->data.F32[j]; 1126 1126 psF32 *vo = calculation->data.F32; … … 1128 1128 for (int i = 0; i < Nx; i++, vi++, vo++, vm++) { 1129 1129 int offset = PS_MIN (i, Nrange); 1130 ps U8*sm = vm - offset;1130 psImageMaskType *sm = vm - offset; 1131 1131 psF32 *si = vi - offset; 1132 1132 psF32 *sg = gauss - offset; … … 1171 1171 int yMax = PS_MIN (j + Nrange + 1, Ny); 1172 1172 for (int n = yMin; n < yMax; n++) { 1173 ps U8 *vm = mask->data.U8[n];1173 psImageMaskType *vm = mask->data.PS_TYPE_IMAGE_MASK_DATA[n]; 1174 1174 psF32 *vi = image->data.F32[n]; 1175 1175 psF32 *vo = output->data.F32; … … 1214 1214 const psImage *input, // Input image 1215 1215 int start, int stop, // Range of rows 1216 ps MaskType maskVal, // Value to mask; NOTE subtle difference!1216 psImageMaskType maskVal, // Value to mask; NOTE subtle difference! 1217 1217 int xMin, int xMax // Range in x for kernel 1218 1218 ) 1219 1219 { 1220 1220 // Dereference mask images 1221 ps MaskType **inputData = input->data.PS_TYPE_MASK_DATA;1222 ps MaskType **targetData = target->data.PS_TYPE_MASK_DATA;1221 psImageMaskType **inputData = input->data.PS_TYPE_IMAGE_MASK_DATA; 1222 psImageMaskType **targetData = target->data.PS_TYPE_IMAGE_MASK_DATA; 1223 1223 1224 1224 int numCols = input->numCols; // Number of columns … … 1241 1241 min = PS_MAX(0, min); 1242 1242 max = PS_MIN(numCols - 1, max); 1243 memset(&targetData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_ MASK));1243 memset(&targetData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK)); 1244 1244 } 1245 1245 } … … 1247 1247 // Mask from the minimum to the end of the row 1248 1248 min = PS_MAX(0, min); 1249 memset(&targetData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_ MASK));1249 memset(&targetData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK)); 1250 1250 } 1251 1251 } … … 1256 1256 const psImage *input, // Input image 1257 1257 int start, int stop, // Range of rows 1258 ps MaskType setVal, // Value to set; NOTE subtle difference!1258 psImageMaskType setVal, // Value to set; NOTE subtle difference! 1259 1259 int yMin, int yMax // Range in y for kernel 1260 1260 ) 1261 1261 { 1262 1262 // Dereference mask images 1263 ps MaskType **inputData = input->data.PS_TYPE_MASK_DATA;1264 ps MaskType **targetData = target->data.PS_TYPE_MASK_DATA;1263 psImageMaskType **inputData = input->data.PS_TYPE_IMAGE_MASK_DATA; 1264 psImageMaskType **targetData = target->data.PS_TYPE_IMAGE_MASK_DATA; 1265 1265 1266 1266 int numRows = input->numRows; // Number of rows … … 1308 1308 int start = PS_SCALAR_VALUE(args->data[2], S32); // Row/col to start at 1309 1309 int stop = PS_SCALAR_VALUE(args->data[3], S32); // Row/col to stop at 1310 ps MaskType maskVal = PS_SCALAR_VALUE(args->data[4], U8); // Value to mask/set1310 psImageMaskType maskVal = PS_SCALAR_VALUE(args->data[4], PS_TYPE_IMAGE_MASK_DATA); // Value to mask/set 1311 1311 int kernelMin = PS_SCALAR_VALUE(args->data[5], S32); // Minimum range for kernel 1312 1312 int kernelMax = PS_SCALAR_VALUE(args->data[6], S32); // Maximum range for kernel … … 1317 1317 } 1318 1318 1319 psImage *psImageConvolveMask(psImage *out, const psImage *mask, ps MaskType maskVal,1320 ps MaskType setVal, int xMin, int xMax, int yMin, int yMax)1319 psImage *psImageConvolveMask(psImage *out, const psImage *mask, psImageMaskType maskVal, 1320 psImageMaskType setVal, int xMin, int xMax, int yMin, int yMax) 1321 1321 { 1322 1322 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 1323 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, NULL);1323 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 1324 1324 if (out) { 1325 1325 PS_ASSERT_IMAGE_NON_NULL(out, NULL); 1326 PS_ASSERT_IMAGE_TYPE(out, PS_TYPE_ MASK, NULL);1326 PS_ASSERT_IMAGE_TYPE(out, PS_TYPE_IMAGE_MASK, NULL); 1327 1327 PS_ASSERT_IMAGES_SIZE_EQUAL(out, mask, NULL); 1328 1328 if (out == mask && ((maskVal & setVal) || !setVal)) { … … 1354 1354 1355 1355 // Propagate the non-masked values 1356 out = (psImage*)psBinaryOp(out, (const psPtr)mask, "&", psScalarAlloc(~setVal, PS_TYPE_ MASK));1356 out = (psImage*)psBinaryOp(out, (const psPtr)mask, "&", psScalarAlloc(~setVal, PS_TYPE_IMAGE_MASK)); 1357 1357 1358 1358 if (!setVal) { … … 1360 1360 } 1361 1361 1362 psImage *conv = psImageAlloc(numCols, numRows, PS_TYPE_ MASK); // Temporary convolved image1362 psImage *conv = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); // Temporary convolved image 1363 1363 psImageInit(conv, 0); 1364 1364 … … 1377 1377 PS_ARRAY_ADD_SCALAR(job->args, start, PS_TYPE_S32); 1378 1378 PS_ARRAY_ADD_SCALAR(job->args, stop, PS_TYPE_S32); 1379 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_ MASK);1379 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 1380 1380 PS_ARRAY_ADD_SCALAR(job->args, xMin, PS_TYPE_S32); 1381 1381 PS_ARRAY_ADD_SCALAR(job->args, xMax, PS_TYPE_S32); … … 1415 1415 PS_ARRAY_ADD_SCALAR(job->args, start, PS_TYPE_S32); 1416 1416 PS_ARRAY_ADD_SCALAR(job->args, stop, PS_TYPE_S32); 1417 PS_ARRAY_ADD_SCALAR(job->args, setVal, PS_TYPE_ MASK);1417 PS_ARRAY_ADD_SCALAR(job->args, setVal, PS_TYPE_IMAGE_MASK); 1418 1418 PS_ARRAY_ADD_SCALAR(job->args, yMin, PS_TYPE_S32); 1419 1419 PS_ARRAY_ADD_SCALAR(job->args, yMax, PS_TYPE_S32); … … 1460 1460 min = PS_MAX(0, min); 1461 1461 max = PS_MIN(numCols - 1, max); 1462 memset(&convData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_ MASK));1462 memset(&convData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK)); 1463 1463 } 1464 1464 } … … 1466 1466 // Mask from the minimum to the end of the row 1467 1467 min = PS_MAX(0, min); 1468 memset(&convData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_ MASK));1468 memset(&convData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK)); 1469 1469 } 1470 1470 } -
trunk/psLib/src/imageops/psImageConvolve.h
r20830 r21183 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1.3 8$ $Name: not supported by cvs2svn $8 * @date $Date: 200 8-11-26 00:43:12$7 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:37 $ 9 9 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 10 10 */ … … 148 148 psImage *psImageConvolveMask(psImage *out, ///< Output image, or NULL 149 149 const psImage *mask, ///< Mask to convolve 150 ps MaskType maskVal, ///< Mask value to convolve151 ps MaskType setVal, ///< Mask value to set; 0 to propagate maskVal150 psImageMaskType maskVal, ///< Mask value to convolve 151 psImageMaskType setVal, ///< Mask value to set; 0 to propagate maskVal 152 152 int xMin, int xMax, int yMin, int yMax ///< Convolution bounds 153 153 ); … … 160 160 psImage *psImageConvolveMaskDirect(psImage *out, ///< Output image, or NULL 161 161 const psImage *mask, ///< Mask to convolve 162 ps MaskType maskVal, ///< Mask value to convolve163 ps MaskType setVal, ///< Mask value to set; 0 to propagate maskVal162 psImageMaskType maskVal, ///< Mask value to convolve 163 psImageMaskType setVal, ///< Mask value to set; 0 to propagate maskVal 164 164 int xMin, int xMax, int yMin, int yMax ///< Convolution bounds 165 165 ); … … 174 174 psImage *psImageConvolveMaskFFT(psImage *out, ///< Output image, or NULL 175 175 const psImage *mask, ///< Mask to convolve 176 ps MaskType maskVal, ///< Mask value to convolve177 ps MaskType setVal, ///< Mask value to set; 0 to use maskVal176 psImageMaskType maskVal, ///< Mask value to convolve 177 psImageMaskType setVal, ///< Mask value to set; 0 to use maskVal 178 178 int xMin, int xMax, int yMin, int yMax, ///< Convolution bounds 179 179 float thresh ///< Threshold (0..1) for convolved floating-point image … … 201 201 const psImage *image, ///< Input image (F32 or F64) 202 202 const psImage *mask, ///< Mask image 203 ps MaskType maskVal,///< Mask value203 psImageMaskType maskVal, ///< Mask value 204 204 float sigma, ///< Width of the smoothing kernel (pixels) 205 205 float numSigma, ///< Size of the smoothing box (sigma) … … 211 211 const psImage *image, 212 212 const psImage *mask, 213 ps MaskType maskVal,213 psImageMaskType maskVal, 214 214 float sigma, 215 215 float numSigma, … … 219 219 psImage *image, ///< the image to be smoothed 220 220 psImage *mask, ///< optional mask 221 ps MaskType maskVal,221 psImageMaskType maskVal, ///< masked bits 222 222 double sigma, ///< the width of the smoothing kernel in pixels 223 223 double Nsigma ///< the size of the smoothing box in sigmas -
trunk/psLib/src/imageops/psImageGeomManip.c
r20299 r21183 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.4 4$ $Name: not supported by cvs2svn $13 * @date $Date: 200 8-10-21 22:10:53$12 * @version $Revision: 1.45 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2009-01-27 06:39:37 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 39 39 const psImage* in, 40 40 const psImage* mask, 41 ps MaskType maskVal,41 psImageMaskType maskVal, 42 42 int scale, 43 43 const psStats* stats) … … 47 47 psS32 outRows; 48 48 psS32 outCols; 49 psVector *vec; // vector to hold the values of a single bin.50 psVector *maskVec = NULL; // vector to hold the mask of a single bin.51 ps MaskType*maskData = NULL;52 psStats *myStats;49 psVector *vec; // vector to hold the values of a single bin. 50 psVector *maskVec = NULL; // vector to hold the mask of a single bin. 51 psVectorMaskType *maskData = NULL; 52 psStats *myStats; 53 53 54 54 if (in == NULL) { … … 86 86 87 87 if (mask != NULL) { 88 if (mask->type.type != PS_TYPE_ MASK) {88 if (mask->type.type != PS_TYPE_IMAGE_MASK) { 89 89 char* typeStr; 90 90 PS_TYPE_NAME(typeStr,mask->type.type); 91 91 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 92 92 _("Input psImage mask type, %s, is not the supported mask datatype of %s."), 93 typeStr, PS_TYPE_ MASK_NAME);93 typeStr, PS_TYPE_IMAGE_MASK_NAME); 94 94 psFree(out); 95 95 psFree(vec); 96 96 return NULL; 97 97 } 98 maskVec = psVectorAllocEmpty(scale * scale, PS_TYPE_ MASK);99 maskData = maskVec->data.PS_TYPE_ MASK_DATA;98 maskVec = psVectorAllocEmpty(scale * scale, PS_TYPE_VECTOR_MASK); 99 maskData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA; 100 100 } 101 101 … … 114 114 ps##TYPE *outRowData; \ 115 115 ps##TYPE *vecData = vec->data.TYPE; \ 116 ps MaskType *inRowMask = NULL; \116 psImageMaskType *inRowMask = NULL; \ 117 117 for (psS32 row = 0; row < outRows; row++) { \ 118 118 outRowData = out->data.TYPE[row]; \ … … 126 126 ps##TYPE* inRowData = in->data.TYPE[inRow]; \ 127 127 if (mask != NULL) { \ 128 inRowMask = mask->data.PS_TYPE_ MASK_DATA[inRow]; \128 inRowMask = mask->data.PS_TYPE_IMAGE_MASK_DATA[inRow]; \ 129 129 } \ 130 130 for (psS32 inCol = inCurrentCol; inCol < inNextCol && inCol < inCols; inCol++) { \ 131 131 if (maskData != NULL) { \ 132 maskData[n] = inRowMask[inCol]; \132 maskData[n] = (inRowMask[inCol] & maskVal); \ 133 133 } \ 134 134 vecData[n++] = inRowData[inCol]; \ … … 139 139 maskVec->n = n; \ 140 140 } \ 141 psVectorStats(myStats, vec, NULL, maskVec, maskVal);\141 psVectorStats(myStats, vec, NULL, maskVec, 0xff); /* the mask vector has only 0 or 1 */ \ 142 142 outRowData[col] = (ps##TYPE)psStatsGetValue(myStats, statistic); \ 143 143 } \ … … 659 659 660 660 bool psImageShiftMask(psImage **out, psImage **outMask, const psImage* in, const psImage *inMask, 661 ps MaskType maskVal, float dx, float dy, double exposed, psMaskType blank,661 psImageMaskType maskVal, float dx, float dy, double exposed, psImageMaskType blank, 662 662 psImageInterpolateMode mode) 663 663 { … … 667 667 PS_ASSERT_IMAGE_NON_NULL(inMask, false); 668 668 PS_ASSERT_IMAGES_SIZE_EQUAL(in, inMask, false); 669 PS_ASSERT_IMAGE_TYPE(inMask, PS_TYPE_ MASK, false);669 PS_ASSERT_IMAGE_TYPE(inMask, PS_TYPE_IMAGE_MASK, false); 670 670 } 671 671 … … 675 675 *out = psImageRecycle(*out, numCols, numRows, type); 676 676 if (outMask) { 677 *outMask = psImageRecycle(*outMask, numCols, numRows, PS_TYPE_ MASK);677 *outMask = psImageRecycle(*outMask, numCols, numRows, PS_TYPE_IMAGE_MASK); 678 678 } 679 679 … … 702 702 for (int row = 0; row < numRows; row++) { \ 703 703 ps##TYPE* outRow = (*out)->data.TYPE[row]; \ 704 ps MaskType *outMaskRow = (outMask ? (*outMask)->data.PS_TYPE_MASK_DATA[row] : NULL); \704 psImageMaskType *outMaskRow = (outMask ? (*outMask)->data.PS_TYPE_IMAGE_MASK_DATA[row] : NULL); \ 705 705 float y = row + 0.5 - dy; \ 706 706 for (int col = 0; col < numCols; col++) { \ 707 707 float x = col + 0.5 - dx; \ 708 708 double value; \ 709 ps MaskType valueMask = 0; \709 psImageMaskType valueMask = 0; \ 710 710 if (!psImageInterpolate(&value, NULL, &valueMask, x, y, interp)) { \ 711 711 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); \ … … 750 750 const psImage *input, 751 751 const psImage *inputMask, 752 ps MaskType inputMaskVal,752 psImageMaskType inputMaskVal, 753 753 const psPlaneTransform *outToIn, 754 754 psRegion region, … … 778 778 return NULL; 779 779 } 780 if (inputMask->type.type != PS_TYPE_ MASK) {780 if (inputMask->type.type != PS_TYPE_IMAGE_MASK) { 781 781 char* typeStr; 782 782 PS_TYPE_NAME(typeStr,inputMask->type.type); 783 783 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 784 784 _("Input psImage mask type, %s, is not the supported mask datatype of %s."), 785 typeStr, PS_TYPE_ MASK_NAME);785 typeStr, PS_TYPE_IMAGE_MASK_NAME); 786 786 psFree(output); 787 787 return NULL; -
trunk/psLib/src/imageops/psImageGeomManip.h
r16910 r21183 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 2$ $Name: not supported by cvs2svn $9 * @date $Date: 200 8-03-11 00:41:30$8 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-01-27 06:39:37 $ 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 11 11 */ … … 36 36 const psImage* in, ///< input image 37 37 const psImage* mask, ///< mask for input image. If NULL, no masking is done. 38 ps MaskType maskVal,///< the bits to check in mask.38 psImageMaskType maskVal, ///< the bits to check in mask. 39 39 int scale, ///< the scale to rebin for each dimension 40 40 const psStats* stats … … 106 106 const psImage* in, ///< Input image 107 107 const psImage *inMask, ///< Input mask, or NULL 108 ps MaskType maskVal,///< Value to mask108 psImageMaskType maskVal, ///< Value to mask 109 109 float dx, float dy, ///< Shift to apply 110 110 double exposed, ///< Value to give exposed pixels 111 ps MaskType blank,///< Mask value for exposed pixels111 psImageMaskType blank, ///< Mask value for exposed pixels 112 112 psImageInterpolateMode mode ///< Interpolation mode 113 113 ); … … 159 159 const psImage *input, ///< psImage to apply transform to 160 160 const psImage *inputMask, ///< if not NULL, mask of input psImage 161 ps MaskType inputMaskVal,///< masking value for inputMask161 psImageMaskType inputMaskVal, ///< masking value for inputMask 162 162 const psPlaneTransform *outToIn, ///< the transform to apply 163 163 psRegion region, ///< the size of the transformed image -
trunk/psLib/src/imageops/psImageInterpolate.c
r20758 r21183 7 7 * @author Paul Price, IfA 8 8 * 9 * @version $Revision: 1.3 0$ $Name: not supported by cvs2svn $10 * @date $Date: 200 8-11-15 03:09:34$9 * @version $Revision: 1.31 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:37 $ 11 11 * 12 12 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 205 205 psImageInterpolation *psImageInterpolationAlloc(psImageInterpolateMode mode, 206 206 const psImage *image, const psImage *variance, 207 const psImage *mask, ps MaskType maskVal,207 const psImage *mask, psImageMaskType maskVal, 208 208 double badImage, double badVariance, 209 ps MaskType badMask, psMaskType poorMask,209 psImageMaskType badMask, psImageMaskType poorMask, 210 210 float poorFrac, int numKernels) 211 211 { … … 274 274 // Interpolation engine for flat mode (nearest pixel) 275 275 static inline psImageInterpolateStatus interpolateFlat(double *imageValue, double *varianceValue, 276 ps MaskType *maskValue, float x, float y,276 psImageMaskType *maskValue, float x, float y, 277 277 const psImageInterpolation *interp) 278 278 { … … 331 331 if (maskValue) { 332 332 if (interp->mask) { 333 *maskValue = interp->mask->data.PS_TYPE_ MASK_DATA[yInt][xInt];333 *maskValue = interp->mask->data.PS_TYPE_IMAGE_MASK_DATA[yInt][xInt]; 334 334 } else { 335 335 *maskValue = 0; … … 456 456 // Interpolation engine for separable interpolation kernels 457 457 static psImageInterpolateStatus interpolateSeparable(double *imageValue, double *varianceValue, 458 ps MaskType *maskValue, float x, float y,458 psImageMaskType *maskValue, float x, float y, 459 459 const psImageInterpolation *interp) 460 460 { … … 465 465 const psImage *mask = interp->mask; // Image mask 466 466 const psImage *variance = interp->variance; // Image variance 467 ps MaskType maskVal = interp->maskVal; // Value to mask467 psImageMaskType maskVal = interp->maskVal; // Value to mask 468 468 bool wantVariance = variance && varianceValue; // Does the user want the variance value? 469 469 bool haveMask = mask && maskVal; // Does the user want the variance value? … … 582 582 const ps##TYPE *imageData = &image->data.TYPE[yPix][xMin]; \ 583 583 const ps##TYPE *varianceData = &variance->data.TYPE[yPix][xMin]; \ 584 const ps MaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[yPix][xMin]; \584 const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xMin]; \ 585 585 const psF32 *xKernelData = xKernel; \ 586 586 const psF32 *xKernel2Data = xKernel2; \ … … 642 642 /* Dereferenced versions of inputs */ \ 643 643 const ps##TYPE *imageData = &image->data.TYPE[yPix][xMin]; \ 644 const ps MaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[yPix][xMin]; \644 const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xMin]; \ 645 645 const psF32 *xKernelData = xKernel; \ 646 646 const psF32 *xKernel2Data = xKernel2; \ … … 713 713 // Interpolation engine for (separable) interpolation kernels 714 714 static psImageInterpolateStatus interpolateKernel(double *imageValue, double *varianceValue, 715 ps MaskType *maskValue, float x, float y,715 psImageMaskType *maskValue, float x, float y, 716 716 const psImageInterpolation *interp) 717 717 { … … 722 722 const psImage *mask = interp->mask; // Image mask 723 723 const psImage *variance = interp->variance; // Image variance 724 ps MaskType maskVal = interp->maskVal; // Value to mask724 psImageMaskType maskVal = interp->maskVal; // Value to mask 725 725 bool wantVariance = variance && varianceValue; // Does the user want the variance value? 726 726 bool haveMask = mask && maskVal; // Does the user want the variance value? … … 790 790 float kernelValue = kernel[j][i]; /* Value of kernel */ \ 791 791 float kernelValue2 = PS_SQR(kernelValue); /* Square of kernel */ \ 792 if (mask->data.PS_TYPE_ MASK_DATA[yPix][xPix] & maskVal) { \792 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xPix] & maskVal) { \ 793 793 sumBad += kernelValue2; \ 794 794 } else { \ … … 820 820 float kernelValue = kernel[j][i]; /* Value of kernel */ \ 821 821 float kernelValue2 = PS_SQR(kernelValue); /* Square of kernel */ \ 822 if (mask->data.PS_TYPE_ MASK_DATA[yPix][xPix] & maskVal) { \822 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xPix] & maskVal) { \ 823 823 sumBad += kernelValue2; \ 824 824 } else { \ … … 866 866 867 867 868 psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue, ps MaskType *maskValue,868 psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue, psImageMaskType *maskValue, 869 869 float x, float y, const psImageInterpolation *interp) 870 870 { … … 885 885 if (maskValue && mask) { 886 886 PS_ASSERT_IMAGE_NON_NULL(mask, PS_INTERPOLATE_STATUS_ERROR); 887 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, PS_INTERPOLATE_STATUS_ERROR);887 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, PS_INTERPOLATE_STATUS_ERROR); 888 888 psAssert(image->numCols == mask->numCols && image->numRows == mask->numRows, "Image and mask sizes"); 889 889 } -
trunk/psLib/src/imageops/psImageInterpolate.h
r20327 r21183 7 7 * @author Paul Price, Institute for Astronomy 8 8 * 9 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $10 * @date $Date: 200 8-10-22 19:21:06$9 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:37 $ 11 11 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii 12 12 */ … … 50 50 const psImage *variance; ///< Variance image for interpolation 51 51 const psImage *mask; ///< Mask image for interpolation 52 ps MaskType maskVal;///< Value to mask52 psImageMaskType maskVal; ///< Value to mask 53 53 double badImage; ///< Image value if x,y location is not good 54 54 double badVariance; ///< Variance value if x,y location is not good 55 ps MaskType badMask;///< Mask value to give bad pixels56 ps MaskType poorMask;///< Mask value to give poor pixels55 psImageMaskType badMask; ///< Mask value to give bad pixels 56 psImageMaskType poorMask; ///< Mask value to give poor pixels 57 57 float poorFrac; ///< Fraction of flux in bad pixels before output is marked bad 58 58 bool shifting; ///< Shifting images? Don't interpolate if the shift is exact. … … 69 69 const psImage *variance, // Variance image 70 70 const psImage *mask, // Mask image 71 ps MaskType maskVal, // Value to mask71 psImageMaskType maskVal, // Value to mask 72 72 double badImage, // Value for image if bad 73 73 double badVariance, // Value for variance if bad 74 ps MaskType badMask, // Mask value for bad pixels75 ps MaskType poorMask, // Mask value for poor pixels74 psImageMaskType badMask, // Mask value for bad pixels 75 psImageMaskType poorMask, // Mask value for poor pixels 76 76 float poorFrac, // Fraction of flux for question 77 77 int numKernels // Number of interpolation kernels to pre-calculate … … 83 83 double *imageValue, ///< Return value for image 84 84 double *varianceValue, ///< Return value for variance 85 ps MaskType *maskValue, ///< Return value for mask85 psImageMaskType *maskValue, ///< Return value for mask 86 86 float x, float y, ///< Location to which to interpolate 87 87 const psImageInterpolation *options ///< Options -
trunk/psLib/src/imageops/psImageMap.c
r21172 r21183 7 7 * @author Eugene Magnier, IfA 8 8 * 9 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2009-01-27 0 0:00:21$9 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:37 $ 11 11 * 12 12 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 145 145 } 146 146 147 psImage *mask = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_ MASK);147 psImage *mask = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_IMAGE_MASK); 148 148 psImage *xCoord = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_F32); 149 149 psImage *yCoord = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_F32); … … 212 212 // this will not in general be properly weighted... 213 213 if (psVectorStats (map->stats, fCell, dfCell, NULL, 0)) { 214 mask->data. U8[iy][ix] = 0;214 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] = 0; 215 215 // XXX ensure only one option is selected, or save both position and width 216 216 map->map->data.F32[iy][ix] = psStatsGetValue (map->stats, map->stats->options); … … 224 224 yCoord->data.F32[iy][ix] = psStatsGetValue (meanStat, meanStat->options); 225 225 } else { 226 mask->data. U8[iy][ix] = 1;226 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] = 1; 227 227 } 228 228 … … 353 353 } 354 354 355 psVector *psImageMapEvalVector(const psImageMap *map, const psVector *mask, ps MaskType maskValue, const psVector *x, const psVector *y)355 psVector *psImageMapEvalVector(const psImageMap *map, const psVector *mask, psVectorMaskType maskValue, const psVector *x, const psVector *y) 356 356 { 357 357 PS_ASSERT_IMAGE_MAP_NON_NULL(map, NULL); … … 365 365 366 366 for (int i = 0; i < x->n; i++) { 367 if (mask && (mask->data. U8[i] & maskValue)) {367 if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) { 368 368 result->data.F32[i] = 0.0; 369 369 } else { -
trunk/psLib/src/imageops/psImageMapFit.c
r21172 r21183 7 7 * @author Eugene Magnier, IfA 8 8 * 9 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2009-01-27 0 0:00:21$9 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:37 $ 11 11 * 12 12 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 47 47 48 48 // map defines the output image dimensions and scaling. 49 bool psImageMapFit(psImageMap *map, const psVector *mask, ps MaskType maskValue,49 bool psImageMapFit(psImageMap *map, const psVector *mask, psVectorMaskType maskValue, 50 50 const psVector *x, const psVector *y, const psVector *f, const psVector *df) 51 51 { … … 145 145 for (int i = 0; i < x->n; i++) { 146 146 147 if (mask && (mask->data. U8[i] & maskValue)) continue;147 if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) continue; 148 148 149 149 // base coordinate offset for this point (x,y) relative to this map element (n,m) … … 338 338 339 339 // measure residuals on each pass and clip outliers based on stats 340 bool psImageMapClipFit(psImageMap *map, psStats *stats, psVector *inMask, ps MaskType maskValue,340 bool psImageMapClipFit(psImageMap *map, psStats *stats, psVector *inMask, psVectorMaskType maskValue, 341 341 const psVector *x, const psVector *y, const psVector *f, const psVector *df) 342 342 { … … 377 377 psVector *mask = inMask; 378 378 if (!inMask) { 379 mask = psVectorAlloc (x->n, PS_TYPE_ U8);379 mask = psVectorAlloc (x->n, PS_TYPE_VECTOR_MASK); 380 380 psVectorInit (mask, 0); 381 381 } … … 429 429 for (psS32 i = 0; i < resid->n; i++) { 430 430 // XXX this prevents recovery of previously masked values 431 if (mask->data. U8[i] & maskValue) {431 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue) { 432 432 continue; 433 433 } … … 435 435 if ((resid->data.F32[i] - meanValue > maxClipValue) || (resid->data.F32[i] - meanValue < minClipValue)) { 436 436 psTrace("psLib.imageops", 6, "Masking element %d : %f vs %f : resid is %f\n", i, f->data.F32[i], fit->data.F32[i], resid->data.F32[i]); 437 mask->data. U8[i] |= 0x01;437 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01; 438 438 continue; 439 439 } … … 455 455 456 456 // map defines the output image dimensions and scaling. 457 bool psImageMapFit1DinY(psImageMap *map, const psVector *mask, ps MaskType maskValue,457 bool psImageMapFit1DinY(psImageMap *map, const psVector *mask, psVectorMaskType maskValue, 458 458 const psVector *x, const psVector *y, const psVector *f, const psVector *df) 459 459 { … … 490 490 for (int i = 0; i < y->n; i++) { 491 491 492 if (mask && (mask->data. U8[i] & maskValue)) continue;492 if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) continue; 493 493 494 494 float dy = psImageBinningGetRuffY (map->binning, y->data.F32[i]) - (m + 0.5); … … 603 603 604 604 // map defines the output image dimensions and scaling. 605 bool psImageMapFit1DinX(psImageMap *map, const psVector *mask, ps MaskType maskValue,605 bool psImageMapFit1DinX(psImageMap *map, const psVector *mask, psVectorMaskType maskValue, 606 606 const psVector *x, const psVector *y, const psVector *f, const psVector *df) 607 607 { … … 638 638 for (int i = 0; i < x->n; i++) { 639 639 640 if (mask && (mask->data. U8[i] & maskValue)) continue;640 if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) continue; 641 641 642 642 float dx = psImageBinningGetRuffX (map->binning, x->data.F32[i]) - (m + 0.5); -
trunk/psLib/src/imageops/psImageMapFit.h
r15841 r21183 10 10 bool psImageMapFit(psImageMap *map, 11 11 const psVector *mask, 12 ps MaskType maskValue,12 psVectorMaskType maskValue, // 13 13 const psVector *x, 14 14 const psVector *y, … … 21 21 psStats *stats, 22 22 psVector *mask, // WARNING: Mask is modified! 23 ps MaskType maskValue,23 psVectorMaskType maskValue, 24 24 const psVector *x, 25 25 const psVector *y, … … 30 30 bool psImageMapFit1DinY(psImageMap *map, 31 31 const psVector *mask, 32 ps MaskType maskValue,32 psVectorMaskType maskValue, 33 33 const psVector *x, 34 34 const psVector *y, … … 39 39 bool psImageMapFit1DinX(psImageMap *map, 40 40 const psVector *mask, 41 ps MaskType maskValue,41 psVectorMaskType maskValue, 42 42 const psVector *x, 43 43 const psVector *y, -
trunk/psLib/src/imageops/psImageMaskOps.c
r18494 r21183 8 8 * @author David Robbins, MHPCC 9 9 * 10 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $11 * @date $Date: 200 8-07-12 21:08:33$10 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-01-27 06:39:37 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 37 37 psRegion region, 38 38 const char *op, 39 ps MaskType maskValue)39 psImageMaskType maskValue) 40 40 { 41 41 if (image == NULL) { … … 53 53 if ((i + image->col0) < region.x0) continue; \ 54 54 if ((i + image->col0) > region.x1) continue; /* is this correct (not >= ?) */ \ 55 image->data.PS_TYPE_ MASK_DATA[j][i] OP maskValue; \55 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] OP maskValue; \ 56 56 } \ 57 57 } … … 84 84 psRegion region, 85 85 const char *op, 86 ps MaskType maskValue)86 psImageMaskType maskValue) 87 87 { 88 88 if (image == NULL) { … … 100 100 (i + image->col0) < region.x0 || \ 101 101 (i + image->col0) > region.x1 ) { \ 102 image->data.PS_TYPE_ MASK_DATA[j][i] OP maskValue; \102 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] OP maskValue; \ 103 103 } } } 104 104 … … 131 131 double radius, 132 132 const char *op, 133 ps MaskType maskValue)133 psImageMaskType maskValue) 134 134 { 135 135 if (image == NULL) { … … 150 150 r2 = PS_SQR(dx) + PS_SQR(dy); \ 151 151 if (r2 <= R2) { \ 152 image->data.PS_TYPE_ MASK_DATA[iy][ix] OP maskValue; \152 image->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] OP maskValue; \ 153 153 } } } 154 154 … … 182 182 double radius, 183 183 const char *op, 184 ps MaskType maskValue)184 psImageMaskType maskValue) 185 185 { 186 186 … … 201 201 r2 = PS_SQR(dx) + PS_SQR(dy); \ 202 202 if (r2 > R2) { \ 203 image->data.PS_TYPE_ MASK_DATA[iy][ix] OP maskValue; \203 image->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] OP maskValue; \ 204 204 } } } 205 205 … … 228 228 psImage *psImageGrowMask(psImage *out, 229 229 const psImage *in, 230 ps MaskType maskVal,230 psImageMaskType maskVal, 231 231 unsigned int growSize, 232 ps MaskType growVal)232 psImageMaskType growVal) 233 233 { 234 234 if (in == NULL) { … … 237 237 return NULL; 238 238 } 239 if (in->type.type != PS_TYPE_ MASK) {239 if (in->type.type != PS_TYPE_IMAGE_MASK) { 240 240 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 241 "Invalid input image. Input image type must match ps MaskType.\n");241 "Invalid input image. Input image type must match psImageMaskType.\n"); 242 242 return NULL; 243 243 } … … 261 261 for (k = 0; k < in->numRows; k++) { 262 262 for (l = 0; l < in->numCols; l++) { 263 out->data.PS_TYPE_ MASK_DATA[k][l] = in->data.PS_TYPE_MASK_DATA[k][l];264 changed->data.PS_TYPE_ MASK_DATA[k][l] = 0;263 out->data.PS_TYPE_IMAGE_MASK_DATA[k][l] = in->data.PS_TYPE_IMAGE_MASK_DATA[k][l]; 264 changed->data.PS_TYPE_IMAGE_MASK_DATA[k][l] = 0; 265 265 } 266 266 } … … 268 268 for (int i = 0; i < in->numRows; i++) { 269 269 for (int j = 0; j < in->numCols; j++) { 270 if ( (in->data.PS_TYPE_ MASK_DATA[i][j] & maskVal) != 0 &&271 changed->data.PS_TYPE_ MASK_DATA[i][j] == 0) {270 if ( (in->data.PS_TYPE_IMAGE_MASK_DATA[i][j] & maskVal) != 0 && 271 changed->data.PS_TYPE_IMAGE_MASK_DATA[i][j] == 0) { 272 272 m = i - growSize; 273 273 if (m < 0) { … … 281 281 for (l = n; l <= (j + growSize) && l < in->numCols; l++) { 282 282 if (((k-i)*(k-i) + (l-j)*(l-j)) <= (growSize*growSize)) { 283 out->data.PS_TYPE_ MASK_DATA[k][l] |= growVal;284 if ( (in->data.PS_TYPE_ MASK_DATA[i][j] & maskVal) == 0 ) {285 changed->data.PS_TYPE_ MASK_DATA[k][l] = 1;283 out->data.PS_TYPE_IMAGE_MASK_DATA[k][l] |= growVal; 284 if ( (in->data.PS_TYPE_IMAGE_MASK_DATA[i][j] & maskVal) == 0 ) { 285 changed->data.PS_TYPE_IMAGE_MASK_DATA[k][l] = 1; 286 286 } 287 287 } -
trunk/psLib/src/imageops/psImageMaskOps.h
r11248 r21183 6 6 * @author David Robbins, MHPCC 7 7 * 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 200 7-01-23 22:47:23$8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-01-27 06:39:37 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 32 32 psRegion region, ///< the specified region 33 33 const char *op, ///< the logical operation 34 ps MaskType maskValue///< the specified bits34 psImageMaskType maskValue ///< the specified bits 35 35 ); 36 36 … … 44 44 psRegion region, ///< the specified region 45 45 const char *op, ///< the logical operation 46 ps MaskType maskValue///< the specified bits46 psImageMaskType maskValue ///< the specified bits 47 47 ); 48 48 … … 58 58 double radius, ///< the radius of the specified circle 59 59 const char *op, ///< the logical operation 60 ps MaskType maskValue///< the specified bits60 psImageMaskType maskValue ///< the specified bits 61 61 ); 62 62 … … 72 72 double radius, ///< the radius of the specified circle 73 73 const char *op, ///< the logical operation 74 ps MaskType maskValue///< the specified bits74 psImageMaskType maskValue ///< the specified bits 75 75 ); 76 76 … … 89 89 psImage *out, ///< the image to set and return 90 90 const psImage *in, ///< the input to image 91 ps MaskType maskVal,///< the specified mask value91 psImageMaskType maskVal, ///< the specified mask value 92 92 unsigned int growSize, ///< the range of values from maskVal 93 ps MaskType growVal///< the output value to set93 psImageMaskType growVal ///< the output value to set 94 94 ); 95 95 -
trunk/psLib/src/imageops/psImagePixelExtract.c
r20306 r21183 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.3 3$ $Name: not supported by cvs2svn $11 * @date $Date: 200 8-10-22 02:10:37 $10 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-01-27 06:39:37 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 206 206 const psImage* input, 207 207 const psImage* mask, 208 ps MaskType maskVal,208 psImageMaskType maskVal, 209 209 psRegion region, 210 210 psImageCutDirection direction, … … 357 357 return NULL; 358 358 } 359 if (mask->type.type != PS_TYPE_ MASK) {359 if (mask->type.type != PS_TYPE_IMAGE_MASK) { 360 360 char* typeStr; 361 361 PS_TYPE_NAME(typeStr,mask->type.type); 362 362 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 363 363 _("Input psImage mask type, %s, is not the supported mask datatype of %s."), 364 typeStr, PS_TYPE_ MASK_NAME);364 typeStr, PS_TYPE_IMAGE_MASK_NAME); 365 365 psFree(out); 366 366 return NULL; … … 394 394 psVector* imgVec = psVectorAlloc(numRows, type); 395 395 psVector* maskVec = NULL; 396 ps MaskType* maskData = NULL;396 psImageMaskType* maskData = NULL; 397 397 psPixelCoord* outPosition = NULL; 398 398 … … 416 416 417 417 if (mask != NULL) { 418 maskVec = psVectorAlloc(numRows, mask->type.type); 419 } 420 #define PSIMAGE_CUT_VERTICAL(TYPE) \ 418 maskVec = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK); 419 } 420 421 #define PSIMAGE_CUT_VERTICAL(TYPE) \ 421 422 case PS_TYPE_##TYPE: { \ 422 ps MaskType* maskVecData = NULL; \423 for (psS32 c =col0;c<col1;c++) { \423 psVectorMaskType* maskVecData = NULL; \ 424 for (psS32 c = col0; c < col1; c++) { \ 424 425 ps##TYPE *imgData = input->data.TYPE[row0] + c; \ 425 426 ps##TYPE *imgVecData = imgVec->data.TYPE; \ 426 427 if (maskVec != NULL) { \ 427 maskVecData = maskVec->data.U8; \ 428 maskData = (psMaskType* )(mask->data.U8[row0]) + c; \ 428 maskVecData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA; \ 429 maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[row0][c]; /* XXX double check this... */ \ 430 /** old entry: maskData = (psMaskType* )(mask->data.PS_TYPE_IMAGE_MASK_DATA[row0]) + c; */ \ 429 431 } \ 430 for (psS32 r=row0;r<row1;r++) { \ 431 *(imgVecData++) = *imgData; \ 432 for (psS32 r = row0; r < row1; r++) { \ 433 *imgVecData = *imgData; \ 434 imgVecData ++; \ 432 435 imgData += inCols; \ 433 436 if (maskVecData != NULL) { \ 434 *(maskVecData++) = *maskData; \ 437 *maskVecData = (*maskData & maskVal); \ 438 maskVecData ++; \ 435 439 maskData += inCols; \ 436 440 } \ 437 441 } \ 438 psVectorStats(myStats, imgVec,NULL,maskVec,maskVal); \442 psVectorStats(myStats, imgVec, NULL, maskVec, 0xff); \ 439 443 *outData = psStatsGetValue(myStats, statistic); \ 440 444 if (outPosition != NULL) { \ … … 471 475 psFree(imgVec); 472 476 psFree(maskVec); 477 473 478 } else if (direction == PS_CUT_Y_POS || direction == PS_CUT_Y_NEG) { 474 479 // Cut in Y direction 480 // XXX use this if we drop the hackish stuff below: psVector* imgVec = psVectorAlloc(numCols, type); 475 481 psVector* imgVec = NULL; 476 482 psVector* maskVec = NULL; … … 479 485 480 486 // fill in psVector to fake out the statistics functions. 487 // XXX EAM : this seems rather hackish: just use the needed psVectorAlloc (like above)? 481 488 imgVec = psAlloc(sizeof(psVector)); 482 489 imgVec->type = input->type; 483 490 P_PSVECTOR_SET_NALLOC(imgVec,numCols); 484 if (mask != NULL) { 485 maskVec = psAlloc(sizeof(psVector)); 486 maskVec->type = mask->type; 487 P_PSVECTOR_SET_NALLOC(maskVec,numCols); 488 } 491 imgVec->n = imgVec->nalloc; 492 489 493 // recycle output to make a proper sized/type output structure 490 494 // n.b. type is double as that is the type given for all stats in … … 492 496 out = psVectorRecycle(out, numRows, PS_TYPE_F64); 493 497 out->n = numRows; 494 imgVec->n = imgVec->nalloc;495 maskVec->n = maskVec->nalloc;496 498 if (coords != NULL) { 497 499 coords = psPixelsRealloc(coords, numRows); … … 507 509 } 508 510 511 if (mask != NULL) { 512 maskVec = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK); 513 // XXX the old code (below) faked out the mask vector 514 // maskVec = psAlloc(sizeof(psVector)); 515 // maskVec->type = mask->type; 516 // P_PSVECTOR_SET_NALLOC(maskVec,numCols); 517 // maskVec->n = maskVec->nalloc; 518 } 519 509 520 for (psS32 r = row0; r < row1; r++) { 510 521 // point the vector struct to the 511 522 // data to calculate the stats 512 523 imgVec->data.U8 = (psPtr )(input->data.U8[r] + col0 * elementSize); 524 525 // set the vector mask pixels based on the image pixels 513 526 if (maskVec != NULL) { 514 maskVec->data.U8 = (psPtr )(mask->data.U8[r] + col0 * sizeof(psMaskType)); 515 } 516 psVectorStats(myStats, imgVec, NULL, maskVec, maskVal); 527 psVectorMaskType *maskVecData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA; 528 psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[r][col0]; 529 for (psS32 c = col0; c < col1; c++) { 530 *maskVecData = (*maskData & maskVal); 531 maskVecData ++; 532 maskData ++; 533 } 534 } 535 536 psVectorStats(myStats, imgVec, NULL, maskVec, 0xff); 517 537 *outData = psStatsGetValue(myStats, statistic); 518 538 if (outPosition != NULL) { … … 544 564 const psImage* input, 545 565 const psImage* mask, 546 ps MaskType maskVal,566 psImageMaskType maskVal, 547 567 psRegion region, 548 568 unsigned int nSamples, … … 651 671 return NULL; 652 672 } 653 if (mask->type.type != PS_TYPE_ MASK) {673 if (mask->type.type != PS_TYPE_IMAGE_MASK) { 654 674 char* typeStr; 655 675 PS_TYPE_NAME(typeStr,mask->type.type); 656 676 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 657 677 _("Input psImage mask type, %s, is not the supported mask datatype of %s."), 658 typeStr, PS_TYPE_ MASK_NAME);678 typeStr, PS_TYPE_IMAGE_MASK_NAME); 659 679 psFree(out); 660 680 return NULL; … … 739 759 const psImage* input, 740 760 const psImage* mask, 741 ps MaskType maskVal,761 psImageMaskType maskVal, 742 762 float x, 743 763 float y, … … 765 785 return NULL; 766 786 } 767 if (mask->type.type != PS_TYPE_ MASK) {787 if (mask->type.type != PS_TYPE_IMAGE_MASK) { 768 788 char* typeStr; 769 789 PS_TYPE_NAME(typeStr,mask->type.type); 770 790 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 771 791 _("Input psImage mask type, %s, is not the supported mask datatype of %s."), 772 typeStr, PS_TYPE_ MASK_NAME);792 typeStr, PS_TYPE_IMAGE_MASK_NAME); 773 793 psFree(out); 774 794 return NULL; … … 868 888 if (mask != NULL) { 869 889 bufferMask[lcv] = psVectorAllocEmpty(1+4*(rSq[lcv+1]-rSq[lcv]), 870 PS_TYPE_ MASK);890 PS_TYPE_VECTOR_MASK); 871 891 } 872 892 } … … 877 897 for (psS32 row=startRow; row <= endRow; row++) { 878 898 psF32* inRow = input->data.F32[row]; 879 ps MaskType* maskRow = NULL;899 psImageMaskType* maskRow = NULL; 880 900 if (mask != NULL) { 881 maskRow = mask->data.PS_TYPE_ MASK_DATA[row];901 maskRow = mask->data.PS_TYPE_IMAGE_MASK_DATA[row]; 882 902 } 883 903 for (psS32 col=startCol; col <= endCol; col++) { … … 899 919 900 920 if (maskRow != NULL) { 901 bufferMask[r]->data.PS_TYPE_ MASK_DATA[n] = maskRow[col];921 bufferMask[r]->data.PS_TYPE_VECTOR_MASK_DATA[n] = (maskRow[col] & maskVal); 902 922 bufferMask[r]->n = n+1; 903 923 } … … 913 933 914 934 for (psS32 r = 0; r < numOut; r++) { 915 psVectorStats(myStats, buffer[r], NULL, bufferMask[r],maskVal);935 psVectorStats(myStats, buffer[r], NULL, bufferMask[r], 0xff); 916 936 outData[r] = psStatsGetValue(myStats, statistic); 917 937 } -
trunk/psLib/src/imageops/psImagePixelExtract.h
r11248 r21183 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $8 * @date $Date: 200 7-01-23 22:47:23$7 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:37 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 84 84 const psImage* input, ///< the input image in which to perform the slice 85 85 const psImage* mask, ///< the mask for the input image. 86 ps MaskType maskVal,///< the mask value to apply to the mask86 psImageMaskType maskVal, ///< the mask value to apply to the mask 87 87 psRegion region, ///< the slice region 88 88 psImageCutDirection direction, ///< the slice dimension and direction … … 112 112 const psImage* input, ///< the input image in which to perform the cut 113 113 const psImage* mask, ///< the mask for the input image. 114 ps MaskType maskVal,///< the mask value to apply to the mask114 psImageMaskType maskVal, ///< the mask value to apply to the mask 115 115 psRegion region, ///< the start and end points to cut along 116 116 unsigned int nSamples, ///< the number of samples along the cut … … 135 135 const psImage* input, ///< the input image in which to perform the cut 136 136 const psImage* mask, ///< the mask for the input image. 137 ps MaskType maskVal,///< the mask value to apply to the mask137 psImageMaskType maskVal, ///< the mask value to apply to the mask 138 138 float x, ///< the column of the center of the cut circle 139 139 float y, ///< the row of the center of the cut circle -
trunk/psLib/src/imageops/psImagePixelInterpolate.c
r15254 r21183 11 11 * @author Eugene Magnier, IfA 12 12 * 13 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $14 * @date $Date: 200 7-10-09 19:25:44$13 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2009-01-27 06:39:37 $ 15 15 * 16 16 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 54 54 /* do not test self */ \ 55 55 if (!jx && !jy) { continue; } \ 56 if (mask->data.PS_TYPE_ MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } \56 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } \ 57 57 nGood ++; \ 58 58 } \ … … 67 67 // just the mask, the output image contains enum values which define the type of interpolation which 68 68 // can be performed 69 psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, ps MaskType maskVal) {69 psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psImageMaskType maskVal) { 70 70 71 71 psImage *result = psImageAlloc (mask->numCols, mask->numRows, PS_TYPE_S32); … … 79 79 80 80 // state of the good pixels (unmasked) 81 if (!(mask->data.PS_TYPE_ MASK_DATA[iy][ix] & maskVal)) {81 if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal)) { 82 82 // count good neighbor pixels (+ self) 83 83 int nGood = 0; … … 94 94 if (jx + ix < 0) { continue; } 95 95 if (jx + ix >= mask->numCols) { continue; } 96 if (mask->data.PS_TYPE_ MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }96 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } 97 97 nGood ++; 98 98 minX = PS_MIN (minX, jx); … … 137 137 138 138 // interpolate the poor pixels using the available options 139 bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, ps MaskType maskVal) {139 bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psImageMaskType maskVal) { 140 140 141 141 assert (image->numCols == state->numCols); … … 185 185 if (!jx && !jy) { continue; } 186 186 // skip masked pixels 187 if (mask->data.PS_TYPE_ MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }187 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } 188 188 x->data.F32[n] = jx; 189 189 y->data.F32[n] = jy; … … 241 241 242 242 // interpolate the good pixels to their true centers 243 bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, ps MaskType maskVal) {243 bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, psImageMaskType maskVal) { 244 244 245 245 assert (value->numCols == state->numCols); … … 299 299 if (jx + ix >= value->numCols) { continue; } 300 300 // skip masked pixels 301 if (mask->data.PS_TYPE_ MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }301 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } 302 302 x->data.F32[n] = xCoord->data.F32[iy+jy][ix+jx]; 303 303 y->data.F32[n] = yCoord->data.F32[iy+jy][ix+jx]; … … 331 331 if (jx + ix >= value->numCols) { continue; } 332 332 // skip masked pixels 333 if (mask->data.PS_TYPE_ MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }333 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } 334 334 x->data.F32[n] = xCoord->data.F32[iy+jy][ix+jx]; 335 335 y->data.F32[n] = yCoord->data.F32[iy+jy][ix+jx]; … … 363 363 for (int iy = 0; iy < value->numRows; iy++) { 364 364 for (int ix = 0; ix < value->numCols; ix++) { 365 if (mask->data.PS_TYPE_ MASK_DATA[iy][ix] & maskVal) { continue; }365 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal) { continue; } 366 366 value->data.F32[iy][ix] = output->data.F32[iy][ix]; 367 367 } -
trunk/psLib/src/imageops/psImagePixelInterpolate.h
r14924 r21183 7 7 * @author Eugene Magnier, IfA 8 8 * 9 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $10 * @date $Date: 200 7-09-20 23:54:25$9 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:37 $ 11 11 * 12 12 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 34 34 } psImagePixelInterpolateType; 35 35 36 psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, ps MaskType maskVal);37 bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, ps MaskType maskVal);38 bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, ps MaskType maskVal);36 psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psImageMaskType maskVal); 37 bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psImageMaskType maskVal); 38 bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, psImageMaskType maskVal); 39 39 40 40 /// @} -
trunk/psLib/src/imageops/psImageStats.c
r12431 r21183 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.10 6$ $Name: not supported by cvs2svn $12 * @date $Date: 200 7-03-14 00:39:50$11 * @version $Revision: 1.107 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2009-01-27 06:39:37 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 53 53 const psImage* in, 54 54 const psImage* mask, 55 ps MaskType maskVal)55 psImageMaskType maskVal) 56 56 { 57 57 psVector *junkData = NULL; … … 62 62 PS_ASSERT_IMAGE_NON_NULL(in, false) 63 63 if (mask != NULL) { 64 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ U8, false);64 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false); 65 65 PS_ASSERT_IMAGES_SIZE_EQUAL(in, mask, false); 66 66 } 67 68 if (in->parent == NULL) { 69 // stuff the image data into a psVector struct. 70 // XXX this is a bit hackish: does it save much time? (avoids a Nx*Ny alloc) 71 junkData = (psVector *) psAlloc(sizeof(psVector)); 72 junkData->type = in->type; 73 P_PSVECTOR_SET_NALLOC(junkData,in->numRows * in->numCols); 74 junkData->n = junkData->nalloc; 75 junkData->data.U8 = in->data.V[0]; // since psImage data is contiguous... 76 } else { 77 // image not necessarily contiguous 78 int numRows = in->numRows; 79 int numCols = in->numCols; 80 int rowSize = numCols * (PSELEMTYPE_SIZEOF(in->type.type)); 81 82 junkData = psVectorAlloc(numRows*numCols, in->type.type); 83 84 psU8* data = junkData->data.U8; 85 for (int row = 0; row < numRows; row++) { 86 memcpy(data, in->data.V[row], rowSize); 87 data += rowSize; 88 } 89 } 90 91 if (mask != NULL) { 92 // image not necessarily contiguous, generate a temp vector to hold the full image 93 int numRows = mask->numRows; 94 int numCols = mask->numCols; 95 96 junkMask = psVectorAlloc(numRows*numCols, PS_TYPE_VECTOR_MASK); 97 98 psVectorMaskType *data = junkMask->data.PS_TYPE_VECTOR_MASK_DATA; 99 for (int row = 0, nVect = 0; row < numRows; row++) { 100 for (int col = 0; col < numCols; col++, nVect++) { 101 data[nVect] = (mask->data.PS_TYPE_IMAGE_MASK_DATA[row][col] & maskVal); 102 } 103 } 104 } 105 106 psVectorStats(stats, junkData, NULL, junkMask, 0xff); 107 108 psFree(junkMask); 109 psFree(junkData); 110 return true; 111 } 112 113 /***************************************************************************** 114 NOTE: We assume that the psHistogram structure out has already been allocated 115 and initialized. 116 *****************************************************************************/ 117 bool psImageHistogram(psHistogram* out, 118 const psImage* in, 119 const psImage* mask, 120 psImageMaskType maskVal) 121 { 122 PS_ASSERT_PTR_NON_NULL(out, false); 123 PS_ASSERT_PTR_NON_NULL(in, false); 124 if (mask != NULL) { 125 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false); 126 PS_ASSERT_IMAGES_SIZE_EQUAL(in, mask, false); 127 } 128 psVector* junkData = NULL; 129 psVector* junkMask = NULL; 67 130 68 131 if (in->parent == NULL) { … … 89 152 90 153 if (mask != NULL) { 91 if (mask->parent == NULL) { 92 // stuff the mask data into a psVector struct. 93 junkMask = psAlloc(sizeof(psVector)); 94 junkMask->type = mask->type; 95 P_PSVECTOR_SET_NALLOC(junkMask,mask->numRows * mask->numCols); 96 junkMask->n = junkMask->nalloc; 97 junkMask->data.U8 = mask->data.V[0]; 98 } else { 99 // image not necessarily contiguous 100 int numRows = mask->numRows; 101 int numCols = mask->numCols; 102 int rowSize = numCols * (PSELEMTYPE_SIZEOF(mask->type.type)); 103 104 junkMask = psVectorAlloc(numRows*numCols, mask->type.type); 105 106 psU8* data = junkMask->data.U8; 107 for (int row = 0; row < numRows; row++) { 108 memcpy(data, mask->data.V[row], rowSize); 109 data += rowSize; 110 } 111 } 112 } 113 114 psVectorStats(stats, junkData, NULL, junkMask, maskVal); 115 116 psFree(junkMask); 117 psFree(junkData); 118 return true; 119 } 120 121 /***************************************************************************** 122 NOTE: We assume that the psHistogram structure out has already been allocated 123 and initialized. 124 *****************************************************************************/ 125 bool psImageHistogram(psHistogram* out, 126 const psImage* in, 127 const psImage* mask, 128 psMaskType maskVal) 129 { 130 PS_ASSERT_PTR_NON_NULL(out, false); 131 PS_ASSERT_PTR_NON_NULL(in, false); 132 if (mask != NULL) { 133 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_U8, false); 134 PS_ASSERT_IMAGES_SIZE_EQUAL(in, mask, false); 135 } 136 psVector* junkData = NULL; 137 psVector* junkMask = NULL; 138 139 if (in->parent == NULL) { 140 // stuff the image data into a psVector struct. 141 junkData = (psVector *) psAlloc(sizeof(psVector)); 142 junkData->type = in->type; 143 P_PSVECTOR_SET_NALLOC(junkData,in->numRows * in->numCols); 144 junkData->n = junkData->nalloc; 145 junkData->data.U8 = in->data.V[0]; // since psImage data is contiguous... 146 } else { 147 // image not necessarily contiguous 148 int numRows = in->numRows; 149 int numCols = in->numCols; 150 int rowSize = numCols * (PSELEMTYPE_SIZEOF(in->type.type)); 151 152 junkData = psVectorAlloc(numRows*numCols, in->type.type); 153 154 psU8* data = junkData->data.U8; 155 for (int row = 0; row < numRows; row++) { 156 memcpy(data, in->data.V[row], rowSize); 157 data += rowSize; 158 } 159 } 160 161 if (mask != NULL) { 162 if (mask->parent == NULL) { 163 // stuff the mask data into a psVector struct. 164 junkMask = psAlloc(sizeof(psVector)); 165 junkMask->type = mask->type; 166 P_PSVECTOR_SET_NALLOC(junkMask,mask->numRows * mask->numCols); 167 junkMask->n = junkMask->nalloc; 168 junkMask->data.U8 = mask->data.V[0]; 169 } else { 170 // image not necessarily contiguous 171 int numRows = mask->numRows; 172 int numCols = mask->numCols; 173 int rowSize = numCols * (PSELEMTYPE_SIZEOF(mask->type.type)); 174 175 junkMask = psVectorAlloc(numRows*numCols, mask->type.type); 176 177 psU8* data = junkMask->data.U8; 178 for (int row = 0; row < numRows; row++) { 179 memcpy(data, mask->data.V[row], rowSize); 180 data += rowSize; 181 } 182 } 154 // image not necessarily contiguous; vector & image mask types do not match 155 int numRows = mask->numRows; 156 int numCols = mask->numCols; 157 158 junkMask = psVectorAlloc(numRows*numCols, PS_TYPE_VECTOR_MASK); 159 160 psVectorMaskType *data = junkMask->data.PS_TYPE_VECTOR_MASK_DATA; 161 for (int row = 0, nVect = 0; row < numRows; row++) { 162 for (int col = 0; col < numCols; col++, nVect++) { 163 data[nVect] = (mask->data.PS_TYPE_IMAGE_MASK_DATA[row][col] & maskVal); 164 } 165 } 183 166 } 184 167 … … 472 455 long psImageCountPixelMask (psImage *mask, 473 456 psRegion region, 474 ps MaskType value)457 psImageMaskType value) 475 458 { 476 459 long Npixels = 0; … … 479 462 int x1 = 0; 480 463 int y1 = 0; 481 psElemType type;482 464 483 465 // this is not a valid error: a psRegion with ranges outside the valid pixels … … 608 590 y1 = row1; 609 591 610 type = mask->type.type; 611 if (type != PS_TYPE_MASK) { 612 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 613 "psImage type does not match the specified psMaskType!\n"); 614 return -1; 615 } 616 592 # define PS_IMAGE_COUNT_PIXEL_MASK(NAME,TYPE) \ 593 case PS_TYPE_##NAME: \ 594 for (long j = y0; j < y1; j++) { \ 595 for (long i = x0; i < x1; i++) { \ 596 if (mask->data.TYPE[j][i] & value) { \ 597 Npixels ++; \ 598 } \ 599 } \ 600 } \ 601 break; 602 603 psElemType type = mask->type.type; 617 604 switch (type) { 618 case PS_TYPE_U8: 619 case PS_TYPE_U16: 620 for (long j = y0; j < y1; j++) { 621 for (long i = x0; i < x1; i++) { 622 if (mask->data.PS_TYPE_MASK_DATA[j][i] & value) { 623 Npixels ++; 624 } 625 } 626 } 627 break; 628 case PS_TYPE_S8: 629 case PS_TYPE_S16: 630 case PS_TYPE_S32: 631 case PS_TYPE_S64: 632 case PS_TYPE_U32: 633 case PS_TYPE_U64: 634 case PS_TYPE_F32: 635 case PS_TYPE_F64: 605 PS_IMAGE_COUNT_PIXEL_MASK(U8, U8); 606 PS_IMAGE_COUNT_PIXEL_MASK(U16,U16); 607 PS_IMAGE_COUNT_PIXEL_MASK(U32,U32); 608 PS_IMAGE_COUNT_PIXEL_MASK(U64,U64); 609 PS_IMAGE_COUNT_PIXEL_MASK(S8, S8); 610 PS_IMAGE_COUNT_PIXEL_MASK(S16,S16); 611 PS_IMAGE_COUNT_PIXEL_MASK(S32,S32); 612 PS_IMAGE_COUNT_PIXEL_MASK(S64,S64); 613 636 614 default: 637 615 // XXX this should include the mask type (as a string) 638 616 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 639 _("Input psImage mask type is not a supported maskdatatype"));617 _("Input psImage is an unsupported datatype")); 640 618 641 619 return -1; -
trunk/psLib/src/imageops/psImageStats.h
r11759 r21183 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.3 1$ $Name: not supported by cvs2svn $12 * @date $Date: 200 7-02-13 03:01:23$11 * @version $Revision: 1.32 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2009-01-27 06:39:37 $ 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 14 14 */ … … 42 42 const psImage* in, ///< image (or subimage) to calculate stats 43 43 const psImage* mask, ///< mask data for image (NULL ok) 44 ps MaskType maskVal///< mask value for mask44 psImageMaskType maskVal ///< mask value for mask 45 45 ); 46 46 … … 57 57 const psImage* in, ///< Image data to be histogramed. 58 58 const psImage* mask, ///< mask data for image (NULL ok) 59 ps MaskType maskVal///< mask Mask for mask59 psImageMaskType maskVal ///< mask Mask for mask 60 60 ); 61 61 … … 97 97 psImage *mask, ///< input image to count 98 98 psRegion region, ///< input region of image 99 ps MaskType value///< the mask value to satisfy99 psImageMaskType value ///< the mask value to satisfy 100 100 ); 101 101 -
trunk/psLib/src/math/psClip.c
r11756 r21183 22 22 23 23 psClipParams *psClipParamsAlloc(psStatsOptions meanStat, psStatsOptions stdevStat, 24 ps MaskType masked, psMaskType clipped)24 psVectorMaskType masked, psVectorMaskType clipped) 25 25 { 26 26 psClipParams *params = psAlloc(sizeof(psClipParams)); // Clip parameters … … 48 48 PS_ASSERT_VECTOR_NON_NULL(values, -1); 49 49 PS_ASSERT_VECTOR_NON_NULL(mask, -1); 50 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ MASK, -1);50 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, -1); 51 51 PS_ASSERT_PTR(params, -1); 52 52 PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, -1); … … 62 62 } 63 63 64 ps MaskType masked = params->masked; // Indicates masked values65 ps MaskType clipped = params->clipped; // Indicates clipped values64 psVectorMaskType masked = params->masked; // Indicates masked values 65 psVectorMaskType clipped = params->clipped; // Indicates clipped values 66 66 masked |= clipped; // Make sure we're also masking clipped values 67 ps MaskType *maskData = mask->data.PS_TYPE_MASK_DATA; // Dereference mask67 psVectorMaskType *maskData = mask->data.PS_TYPE_VECTOR_MASK_DATA; // Dereference mask 68 68 long totalMasked = 0; // Total number of pixels masked 69 69 … … 120 120 PS_ASSERT_VECTOR_NON_NULL(values, -1); 121 121 PS_ASSERT_VECTOR_NON_NULL(mask, -1); 122 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ MASK, -1);122 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, -1); 123 123 PS_ASSERT_PTR(params, -1); 124 124 PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, -1); … … 141 141 } 142 142 143 ps MaskType masked = params->masked; // Indicates masked values144 ps MaskType clipped = params->clipped; // Indicates clipped values143 psVectorMaskType masked = params->masked; // Indicates masked values 144 psVectorMaskType clipped = params->clipped; // Indicates clipped values 145 145 masked |= clipped; // Make sure we're also masking clipped values 146 146 … … 158 158 case PS_TYPE_##TYPE: { \ 159 159 ps##TYPE *valuesData = values->data.TYPE; /* Dereference for speed */ \ 160 ps MaskType *maskData = mask->data.PS_TYPE_MASK_DATA; /* Dereference mask for speed */ \160 psVectorMaskType *maskData = mask->data.PS_TYPE_VECTOR_MASK_DATA; /* Dereference mask for speed */ \ 161 161 if (errors) { \ 162 162 ps##TYPE *errorsData = errors->data.TYPE; \ -
trunk/psLib/src/math/psClip.h
r14452 r21183 4 4 * @author Paul Price, IfA. 5 5 * 6 * $Revision: 1. 5$ $Name: not supported by cvs2svn $7 * $Date: 200 7-08-09 01:40:07$6 * $Revision: 1.6 $ $Name: not supported by cvs2svn $ 7 * $Date: 2009-01-27 06:39:38 $ 8 8 * Copyright 2007 Institute for Astronomy, University of Hawaii 9 9 */ … … 25 25 int iter; ///< Number of rejection iterations; unused by psClip functions 26 26 float rej; ///< Rejection limit (standard deviations) 27 ps MaskType masked; ///< Mask value for entries already masked28 ps MaskType clipped; ///< Mask value to give to clipped entries27 psVectorMaskType masked; ///< Mask value for entries already masked 28 psVectorMaskType clipped; ///< Mask value to give to clipped entries 29 29 double mean; ///< Resultant mean 30 30 double stdev; ///< Resultant stdev … … 35 35 psClipParams *psClipParamsAlloc(psStatsOptions meanStat, ///< Stats option to use for mean 36 36 psStatsOptions stdevStat, ///< Stats option to use for standard deviation 37 ps MaskType masked, ///< Mask value for entries already masked38 ps MaskType clipped ///< Mask value to give to clipped entries37 psVectorMaskType masked, ///< Mask value for entries already masked 38 psVectorMaskType clipped ///< Mask value to give to clipped entries 39 39 ) PS_ATTR_MALLOC; 40 40 -
trunk/psLib/src/math/psConstants.h
r17035 r21183 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1.9 6$ $Name: not supported by cvs2svn $8 * @date $Date: 200 8-03-18 18:25:00$7 * @version $Revision: 1.97 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:38 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 67 67 68 68 // These defines for bitwise opertaions are necessary to yield results of the proper size (use instead of ~) 69 #define PS_NOT_U8(A)(UCHAR_MAX-(A)) // Perform bitwise NOT on A which is of type U8 70 #define PS_NOT_U16(A)(USHORT_MAX-(A)) // Perform bitwaise NOT on A which is of type U16 69 #define PS_NOT_U8(A)(UINT8_MAX-(A)) // Perform bitwise NOT on A which is of type U8 70 #define PS_NOT_U16(A)(UINT16_MAX-(A)) // Perform bitwaise NOT on A which is of type U16 71 #define PS_NOT_U32(A)(UINT32_MAX-(A)) // Perform bitwise NOT on A which is of type U8 72 #define PS_NOT_U64(A)(UINT64_MAX-(A)) // Perform bitwaise NOT on A which is of type U16 71 73 72 74 /// @} -
trunk/psLib/src/math/psHistogram.c
r17565 r21183 5 5 * @author GLG (MHPCC), EAM (IfA) 6 6 * 7 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $8 * @date $Date: 200 8-05-07 23:11:30$7 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:38 $ 9 9 * 10 10 * Copyright 2006 IfA, University of Hawaii … … 231 231 const psVector* errors, 232 232 const psVector* mask, 233 ps MaskType maskVal)233 psVectorMaskType maskVal) 234 234 { 235 235 psTrace("psLib.math", 3, "---- %s() begin ----\n", __func__); … … 244 244 if (mask) { 245 245 PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, false); 246 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);246 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 247 247 } 248 248 if (errors) { … … 274 274 for (long i = 0; i < inF32->n; i++) { 275 275 // Check if this pixel is masked, and if so, skip it. 276 if (!mask || (mask && (!(mask->data. U8[i] & maskVal)))) {276 if (!mask || (mask && (!(mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal)))) { 277 277 if (inF32->data.F32[i] < out->bounds->data.F32[0]) { 278 278 // If this pixel is below minimum value, count it, then skip. -
trunk/psLib/src/math/psHistogram.h
r14452 r21183 7 7 * @author GLG, MHPCC 8 8 * 9 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $10 * @date $Date: 200 7-08-09 01:40:07$9 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:38 $ 11 11 * 12 12 * Copyright 2004-2005 IfA, University of Hawaii … … 88 88 const psVector* errors, ///< Errors 89 89 const psVector* mask, ///< Mask dat for input vector 90 ps MaskType maskVal///< Mask value91 );90 psVectorMaskType maskVal ///< Mask value 91 ); 92 92 93 93 /// @} -
trunk/psLib/src/math/psMinimizeLMM.c
r19845 r21183 10 10 * @author EAM, IfA 11 11 * 12 * @version $Revision: 1.3 5$ $Name: not supported by cvs2svn $13 * @date $Date: 200 8-10-02 20:49:22$12 * @version $Revision: 1.36 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2009-01-27 06:39:38 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 74 74 PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false); 75 75 if (paramMask) { 76 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_ MASK, false);76 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false); 77 77 } 78 78 … … 113 113 // set tmpBeta values which are not masked 114 114 for (int j = 0, n = 0; j < params->n; j++) { 115 if (paramMask && (paramMask->data. U8[j])) continue;115 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue; 116 116 tmpBeta->data.F32[j] = Beta->data.F32[n]; 117 117 n++; … … 120 120 // apply Beta to get new Params values 121 121 for (int j = 0; j < params->n; j++) { 122 if (paramMask && (paramMask->data. U8[j])) {122 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) { 123 123 Params->data.F32[j] = params->data.F32[j]; 124 124 continue; … … 140 140 // apply tmpBeta after limits have been checked 141 141 for (int j = 0, n = 0; j < params->n; j++) { 142 if (paramMask && (paramMask->data. U8[j])) continue;142 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue; 143 143 Beta->data.F32[n] = tmpBeta->data.F32[j]; 144 144 n++; … … 269 269 PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false); 270 270 if (paramMask) { 271 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_ MASK, false);271 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false); 272 272 } 273 273 … … 297 297 // we track alpha,beta and params,deriv separately 298 298 for (int j = 0, J = 0; j < params->n; j++) { 299 if (paramMask && (paramMask->data. U8[j])) continue;299 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue; 300 300 301 301 weight = deriv->data.F32[j] * dy->data.F32[i]; 302 302 303 303 for (int k = 0, K = 0; k <= j; k++) { 304 if (paramMask && (paramMask->data. U8[k])) continue;304 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue; 305 305 alpha->data.F32[J][K] += weight * deriv->data.F32[k]; 306 306 K++; … … 351 351 paramMask = constraint->paramMask; 352 352 if (paramMask != NULL) { 353 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_ U8, false);353 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false); 354 354 PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false); 355 355 } … … 493 493 psImageInit (covar, 0.0); 494 494 for (int j = 0, J = 0; j < params->n; j++) { 495 if (paramMask && (paramMask->data. U8[j])) {495 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) { 496 496 covar->data.F32[j][j] = 1.0; 497 497 continue; 498 498 } 499 499 for (int k = 0, K = 0; k < params->n; k++) { 500 if (paramMask && (paramMask->data. U8[k])) continue;500 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue; 501 501 covar->data.F32[j][k] = Alpha->data.F32[J][K]; 502 502 K++; … … 535 535 nParams = 0; 536 536 for (int i = 0; i < paramMask->n; i++) { 537 if (paramMask->data. U8[i]) continue;537 if (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 538 538 nParams ++; 539 539 } -
trunk/psLib/src/math/psMinimizeLMM_ND.c
r17442 r21183 8 8 * @author EAM, IfA 9 9 * 10 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $11 * @date $Date: 200 8-04-11 08:01:29$10 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-01-27 06:39:38 $ 12 12 * 13 13 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 55 55 paramMask = constraint->paramMask; 56 56 if (paramMask != NULL) { 57 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_ U8, false);57 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false); 58 58 PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false); 59 59 } … … 201 201 psImageInit (covar, 0.0); 202 202 for (int j = 0, J = 0; j < params->n; j++) { 203 if (paramMask && (paramMask->data. U8[j])) {203 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) { 204 204 covar->data.F32[j][j] = 1.0; 205 205 continue; 206 206 } 207 207 for (int k = 0, K = 0; k < params->n; k++) { 208 if (paramMask && (paramMask->data. U8[k])) continue;208 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue; 209 209 covar->data.F32[j][k] = Alpha->data.F32[J][K]; 210 210 K++; … … 251 251 PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false); 252 252 if (paramMask) { 253 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_ MASK, false);253 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false); 254 254 } 255 255 … … 282 282 // set tmpBeta values which are not masked 283 283 for (int j = 0, n = 0; j < params->n; j++) { 284 if (paramMask && (paramMask->data. U8[j])) continue;284 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue; 285 285 tmpBeta->data.F32[j] = Beta->data.F32[n]; 286 286 n++; … … 289 289 // apply Beta to get new Params values 290 290 for (int j = 0; j < params->n; j++) { 291 if (paramMask && (paramMask->data. U8[j])) {291 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) { 292 292 Params->data.F32[j] = params->data.F32[j]; 293 293 continue; … … 309 309 // apply tmpBeta after limits have been checked 310 310 for (int j = 0, n = 0; j < params->n; j++) { 311 if (paramMask && (paramMask->data. U8[j])) continue;311 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue; 312 312 Beta->data.F32[n] = tmpBeta->data.F32[j]; 313 313 n++; … … 438 438 PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false); 439 439 if (paramMask) { 440 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_ MASK, false);440 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false); 441 441 } 442 442 … … 474 474 // we track alpha,beta and params,deriv separately 475 475 for (int j = 0, J = 0; j < params->n; j++) { 476 if (paramMask && (paramMask->data. U8[j])) continue;476 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue; 477 477 478 478 weight = deriv->data.F32[j] * dy->data.F32[i]; 479 479 480 480 for (int k = 0, K = 0; k <= j; k++) { 481 if (paramMask && (paramMask->data. U8[k])) continue;481 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue; 482 482 alpha->data.F32[J][K] += weight * deriv->data.F32[k]; 483 483 K++; … … 512 512 nParams = 0; 513 513 for (int i = 0; i < paramMask->n; i++) { 514 if (paramMask->data. U8[i]) continue;514 if (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 515 515 nParams ++; 516 516 } -
trunk/psLib/src/math/psMinimizePolyFit.c
r19304 r21183 10 10 * @author EAM, IfA 11 11 * 12 * @version $Revision: 1.3 3$ $Name: not supported by cvs2svn $13 * @date $Date: 200 8-09-02 19:03:38 $12 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2009-01-27 06:39:38 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 307 307 psPolynomial1D* myPoly, 308 308 const psVector *mask, 309 ps MaskType maskValue,309 psVectorMaskType maskValue, 310 310 const psVector* y, 311 311 const psVector* yErr, … … 326 326 if (mask != NULL) { 327 327 PS_ASSERT_VECTORS_SIZE_EQUAL(y, mask, NULL); 328 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, NULL);328 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, NULL); 329 329 } 330 330 … … 354 354 psF64 **matrix = A->data.F64; // Least-squares matrix 355 355 psF64 *vector = B->data.F64; // Least-squares vector 356 ps U8*dataMask = NULL; // Mask for data356 psVectorMaskType *dataMask = NULL; // Mask for data 357 357 if (mask) { 358 dataMask = mask->data. U8;359 } 360 ps U8*coeffMask = myPoly->coeffMask; // Mask for polynomial terms358 dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA; 359 } 360 psMaskType *coeffMask = myPoly->coeffMask; // Mask for polynomial terms 361 361 psF64 *yData = y->data.F64; // Coordinate data 362 362 psF64 *yErrData = NULL; // Errors in the coordinate … … 473 473 psPolynomial1D* myPoly, 474 474 const psVector *mask, 475 ps MaskType maskValue,475 psVectorMaskType maskValue, 476 476 const psVector *f, 477 477 const psVector *fErr, … … 484 484 if (mask) { 485 485 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 486 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);486 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 487 487 } 488 488 if (x) { … … 529 529 530 530 // Dereference some pointers for speed in the loop 531 ps U8*dataMask = NULL; // Dereferenced version of mask for data points531 psVectorMaskType *dataMask = NULL; // Dereferenced version of mask for data points 532 532 if (mask) { 533 dataMask = mask->data. U8;534 } 535 ps U8*coeffMask = myPoly->coeffMask; // Dereferenced version of mask for polynomial terms533 dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA; 534 } 535 psMaskType *coeffMask = myPoly->coeffMask; // Dereferenced version of mask for polynomial terms 536 536 psF64 *ordinates = NULL; // Dereferenced version of ordinate data 537 537 if (x) { … … 698 698 psPolynomial1D *poly, 699 699 const psVector *mask, 700 ps MaskType maskValue,700 psVectorMaskType maskValue, 701 701 const psVector *f, 702 702 const psVector *fErr, … … 711 711 if (mask != NULL) { 712 712 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 713 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);713 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 714 714 } 715 715 if (fErr != NULL) { … … 782 782 psStats *stats, 783 783 const psVector *mask, 784 ps MaskType maskValue,784 psVectorMaskType maskValue, 785 785 const psVector *f, 786 786 const psVector *fErr, … … 794 794 PS_ASSERT_VECTOR_NON_NULL(mask, false); 795 795 PS_ASSERT_VECTORS_SIZE_EQUAL(mask, f, false); 796 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);796 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 797 797 798 798 if (fErr != NULL) { … … 862 862 if (mask != NULL) { 863 863 for (psS32 i = 0 ; i < mask->n ; i++) { 864 psTrace("psLib.math", 6, "mask[%d] is %d\n", i, mask->data. U8[i]);864 psTrace("psLib.math", 6, "mask[%d] is %d\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]); 865 865 } 866 866 } … … 895 895 if (mask != NULL) { 896 896 for (psS32 i = 0 ; i < mask->n ; i++) { 897 if (!((mask != NULL) && (mask->data. U8[i] & maskValue))) {897 if (!((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue))) { 898 898 psTrace("psLib.math", 6, "(f, fit)[%d] is (%f, %f). resid is (%f)\n", 899 899 i, f->data.F32[i], fit->data.F32[i], resid->data.F64[i]); … … 922 922 // recovery is not allowed with this scheme 923 923 for (psS32 i = 0; i < resid->n; i++) { 924 if ((mask != NULL) && (mask->data. U8[i] & maskValue)) {924 if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) { 925 925 continue; 926 926 } … … 936 936 937 937 if (mask != NULL) { 938 mask->data. U8[i] |= 0x01;938 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01; 939 939 } 940 940 continue; … … 979 979 psPolynomial2D* myPoly, 980 980 const psVector* mask, 981 ps MaskType maskValue,981 psVectorMaskType maskValue, 982 982 const psVector *f, 983 983 const psVector *fErr, … … 1003 1003 if (mask != NULL) { 1004 1004 PS_ASSERT_VECTORS_SIZE_EQUAL(y, mask, false); 1005 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);1005 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 1006 1006 } 1007 1007 … … 1026 1026 psF64 **matrix = A->data.F64; // Dereference the least-squares matrix 1027 1027 psF64 *vector = B->data.F64; // Dereference the least-squares vector 1028 ps U8**coeffMask = myPoly->coeffMask; // Dereference mask for polynomial terms1029 ps U8*dataMask = NULL; // Dereference mask for data1028 psMaskType **coeffMask = myPoly->coeffMask; // Dereference mask for polynomial terms 1029 psVectorMaskType *dataMask = NULL; // Dereference mask for data 1030 1030 if (mask) { 1031 dataMask = mask->data. U8;1031 dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA; 1032 1032 } 1033 1033 psF64 *xData = x->data.F64; // Dereference x … … 1162 1162 psPolynomial2D *poly, 1163 1163 const psVector *mask, 1164 ps MaskType maskValue,1164 psVectorMaskType maskValue, 1165 1165 const psVector *f, 1166 1166 const psVector *fErr, … … 1179 1179 if (mask != NULL) { 1180 1180 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 1181 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);1181 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 1182 1182 } 1183 1183 if (fErr != NULL) { … … 1231 1231 psStats *stats, 1232 1232 const psVector *mask, 1233 ps MaskType maskValue,1233 psVectorMaskType maskValue, 1234 1234 const psVector *f, 1235 1235 const psVector *fErr, … … 1254 1254 1255 1255 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 1256 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);1256 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 1257 1257 1258 1258 if (fErr != NULL) { … … 1300 1300 if (mask != NULL) { 1301 1301 for (psS32 i = 0 ; i < mask->n ; i++) { 1302 psTrace("psLib.math", 7, "mask[%d] is %d\n", i, mask->data. U8[i]);1302 psTrace("psLib.math", 7, "mask[%d] is %d\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]); 1303 1303 } 1304 1304 } … … 1329 1329 if (mask != NULL) { 1330 1330 for (psS32 i = 0 ; i < mask->n ; i++) { 1331 if (!((mask != NULL) && (mask->data. U8[i] & maskValue))) {1331 if (!((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue))) { 1332 1332 psTrace("psLib.math", 7, "point %d at %f %f : value, fit : %f %f resid: %f\n", 1333 1333 i, x->data.F32[i], y->data.F32[i], f->data.F32[i], fit->data.F32[i], resid->data.F64[i]); … … 1356 1356 // recovery is not allowed with this scheme 1357 1357 for (psS32 i = 0; i < resid->n; i++) { 1358 if ((mask != NULL) && (mask->data. U8[i] & maskValue)) {1358 if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) { 1359 1359 continue; 1360 1360 } … … 1370 1370 1371 1371 if (mask != NULL) { 1372 mask->data. U8[i] |= 0x01;1372 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01; 1373 1373 } 1374 1374 continue; … … 1403 1403 psPolynomial3D* myPoly, 1404 1404 const psVector* mask, 1405 ps MaskType maskValue,1405 psVectorMaskType maskValue, 1406 1406 const psVector *f, 1407 1407 const psVector *fErr, … … 1433 1433 if (mask != NULL) { 1434 1434 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 1435 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);1435 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 1436 1436 } 1437 1437 … … 1464 1464 fErrData = fErr->data.F64; 1465 1465 } 1466 ps U8*dataMask = NULL; // Mask for data1466 psVectorMaskType *dataMask = NULL; // Mask for data 1467 1467 if (mask) { 1468 dataMask = mask->data. U8;1469 } 1470 ps U8***coeffMask = myPoly->coeffMask; // Mask for polynomial terms1468 dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA; 1469 } 1470 psMaskType ***coeffMask = myPoly->coeffMask; // Mask for polynomial terms 1471 1471 int nYZterm = nYterm * nZterm; // Multiplication of the numbers, to calculate the index 1472 1472 … … 1603 1603 psPolynomial3D *poly, 1604 1604 const psVector *mask, 1605 ps MaskType maskValue,1605 psVectorMaskType maskValue, 1606 1606 const psVector *f, 1607 1607 const psVector *fErr, … … 1623 1623 if (mask != NULL) { 1624 1624 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 1625 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);1625 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 1626 1626 } 1627 1627 if (fErr != NULL) { … … 1677 1677 psStats *stats, 1678 1678 const psVector *mask, 1679 ps MaskType maskValue,1679 psVectorMaskType maskValue, 1680 1680 const psVector *f, 1681 1681 const psVector *fErr, … … 1705 1705 1706 1706 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 1707 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);1707 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 1708 1708 1709 1709 if (fErr != NULL) { … … 1751 1751 if (mask != NULL) { 1752 1752 for (psS32 i = 0 ; i < mask->n ; i++) { 1753 psTrace("psLib.math", 6, "mask[%d] is %d\n", i, mask->data. U8[i]);1753 psTrace("psLib.math", 6, "mask[%d] is %d\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]); 1754 1754 } 1755 1755 } … … 1778 1778 if (mask != NULL) { 1779 1779 for (psS32 i = 0 ; i < mask->n ; i++) { 1780 if (!((mask != NULL) && (mask->data. U8[i] & maskValue))) {1780 if (!((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue))) { 1781 1781 psTrace("psLib.math", 6, "(f, fit)[%d] is (%f, %f). resid is (%f)\n", 1782 1782 i, f->data.F32[i], fit->data.F32[i], resid->data.F64[i]); … … 1805 1805 // recovery is not allowed with this scheme 1806 1806 for (psS32 i = 0; i < resid->n; i++) { 1807 if ((mask != NULL) && (mask->data. U8[i] & maskValue)) {1807 if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) { 1808 1808 continue; 1809 1809 } … … 1819 1819 1820 1820 if (mask != NULL) { 1821 mask->data. U8[i] |= 0x01;1821 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01; 1822 1822 } 1823 1823 continue; … … 1850 1850 psPolynomial4D* myPoly, 1851 1851 const psVector* mask, 1852 ps MaskType maskValue,1852 psVectorMaskType maskValue, 1853 1853 const psVector *f, 1854 1854 const psVector *fErr, … … 1884 1884 if (mask) { 1885 1885 PS_ASSERT_VECTORS_SIZE_EQUAL(y, mask, false); 1886 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);1886 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 1887 1887 } 1888 1888 … … 1918 1918 fErrData = fErr->data.F64; 1919 1919 } 1920 ps U8*dataMask = NULL; // Mask for data1920 psVectorMaskType *dataMask = NULL; // Mask for data 1921 1921 if (mask) { 1922 dataMask = mask->data. U8;1923 } 1924 ps U8****coeffMask = myPoly->coeffMask; // Mask for polynomial terms1922 dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA; 1923 } 1924 psMaskType ****coeffMask = myPoly->coeffMask; // Mask for polynomial terms 1925 1925 int nYZTterm = nYterm * nZterm * nTterm; // Multiplication of the numbers, for calculating the index 1926 1926 int nZTterm = nZterm * nTterm; // Multiplication of the numbers, for calculating the index … … 2068 2068 psPolynomial4D *poly, 2069 2069 const psVector *mask, 2070 ps MaskType maskValue,2070 psVectorMaskType maskValue, 2071 2071 const psVector *f, 2072 2072 const psVector *fErr, … … 2091 2091 if (mask) { 2092 2092 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 2093 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);2093 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 2094 2094 } 2095 2095 if (fErr != NULL) { … … 2148 2148 psStats *stats, 2149 2149 const psVector *mask, 2150 ps MaskType maskValue,2150 psVectorMaskType maskValue, 2151 2151 const psVector *f, 2152 2152 const psVector *fErr, … … 2181 2181 2182 2182 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 2183 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);2183 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 2184 2184 2185 2185 if (fErr != NULL) { … … 2227 2227 if (mask != NULL) { 2228 2228 for (psS32 i = 0 ; i < mask->n ; i++) { 2229 psTrace("psLib.math", 6, "mask[%d] is %d\n", i, mask->data. U8[i]);2229 psTrace("psLib.math", 6, "mask[%d] is %d\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]); 2230 2230 } 2231 2231 } … … 2255 2255 if (mask != NULL) { 2256 2256 for (psS32 i = 0 ; i < mask->n ; i++) { 2257 if (!((mask != NULL) && (mask->data. U8[i] & maskValue))) {2257 if (!((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue))) { 2258 2258 psTrace("psLib.math", 6, "(f, fit)[%d] is (%f, %f). resid is (%f)\n", 2259 2259 i, f->data.F32[i], fit->data.F32[i], resid->data.F64[i]); … … 2282 2282 // recovery is not allowed with this scheme 2283 2283 for (psS32 i = 0; i < resid->n; i++) { 2284 if ((mask != NULL) && (mask->data. U8[i] & maskValue)) {2284 if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) { 2285 2285 continue; 2286 2286 } … … 2296 2296 2297 2297 if (mask != NULL) { 2298 mask->data. U8[i] |= 0x01;2298 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01; 2299 2299 } 2300 2300 continue; -
trunk/psLib/src/math/psMinimizePolyFit.h
r11248 r21183 7 7 * @author GLG, MHPCC 8 8 * 9 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $10 * @date $Date: 200 7-01-23 22:47:23$9 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:38 $ 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 12 12 * … … 48 48 psPolynomial1D *poly, 49 49 const psVector *mask, 50 ps MaskType maskValue,50 psVectorMaskType maskValue, 51 51 const psVector *f, 52 52 const psVector *fErr, … … 57 57 psPolynomial2D *poly, 58 58 const psVector *mask, 59 ps MaskType maskValue,59 psVectorMaskType maskValue, 60 60 const psVector *f, 61 61 const psVector *fErr, … … 67 67 psPolynomial3D *poly, 68 68 const psVector *mask, 69 ps MaskType maskValue,69 psVectorMaskType maskValue, 70 70 const psVector *f, 71 71 const psVector *fErr, … … 78 78 psPolynomial4D *poly, 79 79 const psVector *mask, 80 ps MaskType maskValue,80 psVectorMaskType maskValue, 81 81 const psVector *f, 82 82 const psVector *fErr, … … 92 92 psStats *stats, 93 93 const psVector *mask, 94 ps MaskType maskValue,94 psVectorMaskType maskValue, 95 95 const psVector *f, 96 96 const psVector *fErr, … … 102 102 psStats *stats, 103 103 const psVector *mask, 104 ps MaskType maskValue,104 psVectorMaskType maskValue, 105 105 const psVector *f, 106 106 const psVector *fErr, … … 113 113 psStats *stats, 114 114 const psVector *mask, 115 ps MaskType maskValue,115 psVectorMaskType maskValue, 116 116 const psVector *f, 117 117 const psVector *fErr, … … 125 125 psStats *stats, 126 126 const psVector *mask, 127 ps MaskType maskValue,127 psVectorMaskType maskValue, 128 128 const psVector *f, 129 129 const psVector *fErr, -
trunk/psLib/src/math/psMinimizePowell.c
r11668 r21183 11 11 * NOTE: XXX: The SDR is silent about data types. F32 is implemented here. 12 12 * 13 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $14 * @date $Date: 200 7-02-06 21:36:09$13 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2009-01-27 06:39:38 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 43 43 #define PS_VECTOR_ADD_MULTIPLE(BASE, BASEMASK, LINE, OUT, MUL) \ 44 44 for (psS32 i=0;i<BASE->n;i++) { \ 45 if (BASEMASK->data. U8[i] == 0) { \45 if (BASEMASK->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { \ 46 46 OUT->data.F32[i] = BASE->data.F32[i] + (MUL * LINE->data.F32[i]); \ 47 47 } else { \ … … 62 62 BOOL_VAR = true; \ 63 63 for (psS32 i=0;i<IN->n;i++) { \ 64 if ((INMASK->data. U8[i] == 0) && (fabs(IN->data.F32[i]) >= FLT_EPSILON)) { \64 if ((INMASK->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) && (fabs(IN->data.F32[i]) >= FLT_EPSILON)) { \ 65 65 BOOL_VAR = false; \ 66 66 break; \ … … 359 359 PS_ASSERT_VECTOR_NON_NULL(paramMask, NAN); 360 360 PS_ASSERT_VECTOR_NON_EMPTY(paramMask, NAN); 361 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_ U8, NAN);361 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, NAN); 362 362 PS_ASSERT_PTR_NON_NULL(coords, NAN); 363 363 PS_ASSERT_PTR_NON_NULL(func, NAN); … … 388 388 for (i=0;i<params->n;i++) { 389 389 psTrace("psLib.math", 6, "(params, paramMask, line)[%d] is (%f %d %f)\n", i, 390 params->data.F32[i], paramMask->data. U8[i], line->data.F32[i]);390 params->data.F32[i], paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i], line->data.F32[i]); 391 391 } 392 392 } … … 527 527 528 528 if (paramMask == NULL) { 529 myParamMask = psVectorAlloc(params->n, PS_TYPE_ U8);529 myParamMask = psVectorAlloc(params->n, PS_TYPE_VECTOR_MASK); 530 530 psVectorInit(myParamMask, 0); 531 531 } else { … … 572 572 biggestIter = 0; 573 573 for (i=0;i<numDims;i++) { 574 if (myParamMask->data. U8[i] == 0) {574 if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { 575 575 P_PSMINIMIZATION_SET_MAXITER((&dummyMin),PS_MINIMIZE_POWELL_LINEMIN_MAX_ITERATIONS); 576 576 *(float*)&dummyMin.tol = PS_MINIMIZE_POWELL_LINEMIN_ERROR_TOLERANCE; … … 603 603 // 4: Set the vector u = Q - P 604 604 for (i=0;i<numDims;i++) { 605 if (myParamMask->data. U8[i] == 0) {605 if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { 606 606 u->data.F32[i] = Q->data.F32[i] - params->data.F32[i]; 607 607 u->n++; … … 649 649 650 650 for (i=0;i<numDims;i++) { 651 if (myParamMask->data. U8[i] == 0) {651 if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { 652 652 pQP->data.F32[i] = (2 * Q->data.F32[i]) - params->data.F32[i]; 653 653 } else { … … 663 663 if (term1 < term2) { 664 664 for (i=0;i<numDims;i++) { 665 if (myParamMask->data. U8[i] == 0) {665 if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { 666 666 ((psVector *) v->data[biggestIter])->data.F32[i] = u->data.F32[i]; 667 667 } … … 671 671 // 7: Set P to Q 672 672 for (i=0;i<numDims;i++) { 673 if (myParamMask->data. U8[i] == 0) {673 if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { 674 674 params->data.F32[i] = Q->data.F32[i]; 675 675 } -
trunk/psLib/src/math/psPolynomialMD.c
r19085 r21183 132 132 const psVector *values, // Measured values 133 133 const psVector *mask, // Mask for values 134 ps MaskType maskVal134 psVectorMaskType maskVal 135 135 ) 136 136 { … … 143 143 int numGood = numValues; // Number of good values 144 144 for (int i = 0; i < numValues; i++) { 145 if (mask && (mask->data. U8[i] & maskVal)) {145 if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal)) { 146 146 numGood--; 147 147 continue; … … 253 253 254 254 bool psPolynomialMDFit(psPolynomialMD *poly, const psVector *values, const psVector *errors, 255 const psVector *mask, ps MaskType maskVal, const psArray *coordsArray)255 const psVector *mask, psVectorMaskType maskVal, const psArray *coordsArray) 256 256 { 257 257 PS_ASSERT_POLYNOMIALMD_NON_NULL(poly, false); … … 268 268 if (mask) { 269 269 PS_ASSERT_VECTOR_NON_NULL(mask, false); 270 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ MASK, false);270 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 271 271 PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, false); 272 272 } … … 294 294 PS_ASSERT_VECTOR_TYPE(coords, PS_TYPE_F32, false); 295 295 296 if (mask && (mask->data.PS_TYPE_ MASK_DATA[i] & maskVal)) {296 if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal)) { 297 297 continue; 298 298 } … … 321 321 } 322 322 323 // XXX this function should take a (ps MaskType markVal) argument323 // XXX this function should take a (psVectorMaskType markVal) argument 324 324 bool psPolynomialMDClipFit(psPolynomialMD *poly, const psVector *values, const psVector *errors, 325 const psVector *mask, ps MaskType maskVal, const psArray *coordsArray,325 const psVector *mask, psVectorMaskType maskVal, const psArray *coordsArray, 326 326 int numIter, float rej) 327 327 { … … 340 340 if (mask) { 341 341 PS_ASSERT_VECTOR_NON_NULL(mask, false); 342 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ MASK, false);342 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 343 343 PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, false); 344 344 } … … 355 355 356 356 // copy the input mask to a local temporary mask 357 poly->ownMask = psVectorRecycle(poly->ownMask, numValues, PS_TYPE_ U8); // Our own mask for input values357 poly->ownMask = psVectorRecycle(poly->ownMask, numValues, PS_TYPE_VECTOR_MASK); // Our own mask for input values 358 358 psVectorInit(poly->ownMask, 0); 359 359 for (int i = 0; mask && (i < numValues); i++) { 360 if (mask->data.PS_TYPE_ MASK_DATA[i] & maskVal) {361 poly->ownMask->data. U8[i] = 0xff;360 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal) { 361 poly->ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff; 362 362 numGood--; 363 363 } … … 392 392 i, values->data.F32[i], values->data.F32[i] - poly->deviations->data.F32[i], poly->deviations->data.F32[i], limit); 393 393 394 if (poly->ownMask->data. U8[i]) continue;394 if (poly->ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 395 395 396 396 if (fabs(poly->deviations->data.F32[i]) > limit) { … … 398 398 i, values->data.F32[i], values->data.F32[i] + poly->deviations->data.F32[i], 399 399 poly->deviations->data.F32[i], limit); 400 poly->ownMask->data. U8[i] = 0xff;400 poly->ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff; 401 401 numClipped++; 402 402 numGood--; … … 435 435 psVectorInit(vector, 0.0); 436 436 for (int i = 0; i < numValues; i++) { 437 if (mask->data. U8[i]) {437 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 438 438 continue; 439 439 } … … 462 462 463 463 bool psPolynomialMDClipFit(psPolynomialMD *poly, const psVector *values, const psVector *errors, 464 const psVector *mask, ps MaskType maskVal, const psArray *coordsArray,464 const psVector *mask, psVectorMaskType maskVal, const psArray *coordsArray, 465 465 int numIter, float rej) 466 466 { … … 478 478 if (mask) { 479 479 PS_ASSERT_VECTOR_NON_NULL(mask, false); 480 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ MASK, false);480 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 481 481 PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, false); 482 482 } … … 500 500 PS_ASSERT_VECTOR_TYPE(coords, PS_TYPE_F32, false); 501 501 502 if (mask && (mask->data.PS_TYPE_ MASK_DATA[i] & maskVal)) {502 if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal)) { 503 503 continue; 504 504 } … … 516 516 psImage *matrix = psImageAlloc(numTerms, numTerms, PS_TYPE_F64); // Least-squares matrix 517 517 psVector *vector = psVectorAlloc(numTerms, PS_TYPE_F64); // Least-squares vector 518 psVector *ownMask = psVectorAlloc(numValues, PS_TYPE_ U8); // Our own mask for input values518 psVector *ownMask = psVectorAlloc(numValues, PS_TYPE_VECTOR_MASK); // Our own mask for input values 519 519 psVectorInit(ownMask, 0); 520 520 if (mask) { 521 521 for (int i = 0; i < numValues; i++) { 522 if (mask->data.PS_TYPE_ MASK_DATA[i] & maskVal) {523 ownMask->data. U8[i] = 0xff;522 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal) { 523 ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff; 524 524 numGood--; 525 525 } … … 551 551 float limit = rej * poly->stdevFit; // Rejection limit 552 552 for (int i = 0; i < numValues; i++) { 553 if (ownMask->data. U8[i]) {553 if (ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 554 554 continue; 555 555 } … … 558 558 i, values->data.F32[i], psPolynomialMDEval(poly, coordsArray->data[i]), 559 559 deviations->data.F32[i], limit); 560 ownMask->data. U8[i] = 0xff;560 ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff; 561 561 numClipped++; 562 562 numGood--; -
trunk/psLib/src/math/psPolynomialMD.h
r19085 r21183 52 52 const psVector *errors, ///< Errors 53 53 const psVector *mask, ///< Mask 54 ps MaskType maskVal, ///< Value to mask54 psVectorMaskType maskVal, ///< Value to mask 55 55 const psArray *coordsArray ///< Array of coordinates 56 56 ); … … 61 61 const psVector *errors, ///< Errors 62 62 const psVector *mask, ///< Mask 63 ps MaskType maskVal, ///< Value to mask63 psVectorMaskType maskVal, ///< Value to mask 64 64 const psArray *coordsArray, ///< Array of coordinates 65 65 int numIter, ///< Number of rejection iterations -
trunk/psLib/src/math/psPolynomialUtils.c
r19844 r21183 21 21 psStats *stats, 22 22 const psVector *mask, 23 ps MaskType maskValue,23 psVectorMaskType maskValue, 24 24 const psVector *f, 25 25 const psVector *fErr, … … 36 36 if (mask != NULL) { 37 37 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, NULL); 38 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, NULL);38 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, NULL); 39 39 } 40 40 PS_ASSERT_VECTOR_NON_NULL(x, NULL); … … 106 106 // recovery is not allowed with this scheme 107 107 for (int i = 0; i < resid->n; i++) { 108 if ((mask != NULL) && (mask->data. U8[i] & maskValue)) {108 if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) { 109 109 continue; 110 110 } … … 112 112 if (resid->data.F64[i] - stats->sampleMedian > sigma*maxClipSigma) { 113 113 if (mask != NULL) { 114 mask->data. U8[i] |= 0x01;114 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01; 115 115 } 116 116 continue; … … 118 118 if (resid->data.F64[i] - stats->sampleMedian < sigma*minClipSigma) { 119 119 if (mask != NULL) { 120 mask->data. U8[i] |= 0x01;120 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01; 121 121 } 122 122 continue; -
trunk/psLib/src/math/psPolynomialUtils.h
r11248 r21183 2 2 * @brief extra psPolynomial-related functions 3 3 * 4 * $Revision: 1. 5$ $Name: not supported by cvs2svn $5 * $Date: 200 7-01-23 22:47:23$4 * $Revision: 1.6 $ $Name: not supported by cvs2svn $ 5 * $Date: 2009-01-27 06:39:38 $ 6 6 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 7 7 */ … … 24 24 psStats *stats, // Statistics to use in clipping 25 25 const psVector *mask, // Mask for input values 26 ps MaskType maskValue,// Mask value26 psVectorMaskType maskValue, // Mask value 27 27 const psVector *f, // Value of the function, f(x,y,z,t) 28 28 const psVector *fErr, // Error in the value -
trunk/psLib/src/math/psStats.c
r20515 r21183 13 13 * use ->min and ->max (PS_STAT_USE_RANGE) 14 14 * 15 * @version $Revision: 1.23 0$ $Name: not supported by cvs2svn $16 * @date $Date: 200 8-11-04 00:55:14$15 * @version $Revision: 1.231 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2009-01-27 06:39:38 $ 17 17 * 18 18 * Copyright 2006 IfA, University of Hawaii … … 68 68 #define PS_CLIPPED_SIGMA_UB 10.0 69 69 #define PS_POLY_MEDIAN_MAX_ITERATIONS 30 70 #define MASK_MARK 0x80 // bit to use internally to mark data as bad 70 71 #define MASK_MARK 0x80 // XXX : can we change this? bit to use internally to mark data as bad 71 72 #define PS_ROBUST_MAX_ITERATIONS 20 // Maximum number of iterations for robust statistics 72 73 … … 178 179 const psVector* errors, 179 180 const psVector* maskVector, 180 ps MaskType maskVal,181 psVectorMaskType maskVal, 181 182 psStats* stats) 182 183 { … … 190 191 int numData = myVector->n; // Number of data points 191 192 192 ps U8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8;193 psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA; 193 194 bool useRange = stats->options & PS_STAT_USE_RANGE; 194 195 … … 245 246 static long vectorMinMax(const psVector* myVector, 246 247 const psVector* maskVector, 247 ps MaskType maskVal,248 psVectorMaskType maskVal, 248 249 psStats* stats 249 250 ) … … 257 258 int numValid = 0; // Number of valid values 258 259 259 ps U8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8;260 psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA; 260 261 bool useRange = stats->options & PS_STAT_USE_RANGE; 261 262 … … 302 303 static bool vectorSampleMedian(const psVector* inVector, 303 304 const psVector* maskVector, 304 ps MaskType maskVal,305 psVectorMaskType maskVal, 305 306 psStats* stats) 306 307 { … … 308 309 309 310 bool useRange = stats->options & PS_STAT_USE_RANGE; 310 ps U8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8; // Dereference the vector311 psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA; // Dereference the vector 311 312 psF32 *input = inVector->data.F32; // Dereference the vector 312 313 … … 387 388 const psVector* errors, 388 389 const psVector* maskVector, 389 ps MaskType maskVal,390 psVectorMaskType maskVal, 390 391 psStats* stats) 391 392 { … … 407 408 408 409 psF32 *data = myVector->data.F32; // Dereference 409 ps U8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8;410 psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA; 410 411 bool useRange = stats->options & PS_STAT_USE_RANGE; 411 412 psF32 *errorsData = (errors == NULL) ? NULL : errors->data.F32; … … 468 469 static bool vectorSampleMoments(const psVector* myVector, 469 470 const psVector* maskVector, 470 ps MaskType maskVal,471 psVectorMaskType maskVal, 471 472 psStats* stats) 472 473 { … … 490 491 491 492 psF32 *data = myVector->data.F32; // Dereference 492 ps U8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8;493 psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA; 493 494 bool useRange = stats->options & PS_STAT_USE_RANGE; 494 495 … … 557 558 const psVector* errors, 558 559 psVector* maskInput, 559 ps MaskType maskValInput,560 psVectorMaskType maskValInput, 560 561 psStats* stats 561 562 ) … … 580 581 581 582 // We copy the mask vector, to preserve the original 582 ps MaskType maskVal = MASK_MARK | maskValInput;583 psVectorMaskType maskVal = MASK_MARK | maskValInput; 583 584 584 585 // use the temporary vector for local temporary mask 585 stats->tmpMask = psVectorRecycle (stats->tmpMask, myVector->n, PS_TYPE_ U8);586 stats->tmpMask = psVectorRecycle (stats->tmpMask, myVector->n, PS_TYPE_VECTOR_MASK); 586 587 psVector *tmpMask = stats->tmpMask; 587 588 psVectorInit(tmpMask, 0); 588 589 if (maskInput) { 589 590 for (long i = 0; i < myVector->n; i++) { 590 if (maskInput->data. U8[i] & maskValInput) {591 tmpMask->data. U8[i] = maskVal;591 if (maskInput->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValInput) { 592 tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = maskVal; 592 593 } 593 594 } … … 629 630 // sqrt(A)) 630 631 for (long j = 0; j < myVector->n; j++) { 631 if (!tmpMask->data. U8[j] &&632 if (!tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[j] && 632 633 fabsf(myVector->data.F32[j] - clippedMean) > stats->clipSigma * errors->data.F32[j]) { 633 tmpMask->data. U8[j] = 0xff;634 tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff; 634 635 psTrace(TRACE, 10, "Clipped %ld: %f +/- %f\n", j, 635 636 myVector->data.F32[j], errors->data.F32[j]); … … 640 641 } else { 641 642 for (long j = 0; j < myVector->n; j++) { 642 if (!tmpMask->data. U8[j] &&643 if (!tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[j] && 643 644 fabsf(myVector->data.F32[j] - clippedMean) > (stats->clipSigma * clippedStdev)) { 644 tmpMask->data. U8[j] = 0xff;645 tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff; 645 646 psTrace(TRACE, 10, "Clipped %ld: %f\n", j, myVector->data.F32[j]); 646 647 numClipped++; … … 715 716 const psVector* errors, 716 717 psVector* maskInput, 717 ps MaskType maskValInput,718 psVectorMaskType maskValInput, 718 719 psStats* stats) 719 720 { … … 726 727 // and tested even if there is no supplied mask (and/or the maskVal is 0) 727 728 // XXX this would be better if we had globally defined mask values 728 ps MaskType maskVal = MASK_MARK | maskValInput;729 psVector *mask = psVectorAlloc(myVector->n, PS_TYPE_ MASK); // The actual mask we will use729 psVectorMaskType maskVal = MASK_MARK | maskValInput; 730 psVector *mask = psVectorAlloc(myVector->n, PS_TYPE_VECTOR_MASK); // The actual mask we will use 730 731 psVectorInit(mask, 0); 731 732 if (maskInput) { 732 733 for (long i = 0; i < myVector->n; i++) { 733 if (maskInput->data. U8[i] & maskValInput) {734 mask->data. U8[i] = maskVal;734 if (maskInput->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValInput) { 735 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = maskVal; 735 736 } 736 737 } … … 934 935 if ((myVector->data.F32[i] < medianLo) || (myVector->data.F32[i] > medianHi)) { 935 936 // XXXX is this correct? is MASK_MARK safe? 936 mask->data. U8[i] |= MASK_MARK;937 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= MASK_MARK; 937 938 psTrace(TRACE, 6, "Masking element %ld is %f\n", i, myVector->data.F32[i]); 938 939 } … … 998 999 long N50 = 0; 999 1000 for (long i = 0 ; i < myVector->n ; i++) { 1000 if (!mask->data. U8[i] &&1001 if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[i] && 1001 1002 (binLo25F32 <= myVector->data.F32[i]) && (binHi25F32 >= myVector->data.F32[i])) { 1002 1003 N50++; … … 1046 1047 const psVector* errors, 1047 1048 psVector* mask, 1048 ps MaskType maskVal,1049 psVectorMaskType maskVal, 1049 1050 psStats* stats) 1050 1051 { … … 1224 1225 const psVector* errors, 1225 1226 psVector* mask, 1226 ps MaskType maskVal,1227 psVectorMaskType maskVal, 1227 1228 psStats* stats) 1228 1229 { … … 1347 1348 // fitStats->clipIter = 3.0; 1348 1349 // fitStats->clipSigma = 3.0; 1349 // psVector *fitMask = psVectorAlloc(y->n, PS_TYPE_ U8);1350 // psVector *fitMask = psVectorAlloc(y->n, PS_TYPE_VECTOR_MASK); 1350 1351 // psVectorInit (fitMask, 0); 1351 1352 … … 1418 1419 const psVector* errors, 1419 1420 psVector* mask, 1420 ps MaskType maskVal,1421 psVectorMaskType maskVal, 1421 1422 psStats* stats) 1422 1423 { … … 1713 1714 const psVector* errors, 1714 1715 psVector* mask, 1715 ps MaskType maskVal,1716 psVectorMaskType maskVal, 1716 1717 psStats* stats) 1717 1718 { … … 2225 2226 const psVector* errors, 2226 2227 const psVector* mask, 2227 ps MaskType maskVal)2228 psVectorMaskType maskVal) 2228 2229 { 2229 2230 psTrace(TRACE, 3,"---- %s() begin ----\n", __func__); … … 2233 2234 if (mask) { 2234 2235 PS_ASSERT_VECTORS_SIZE_EQUAL(mask, in, false); 2235 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);2236 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 2236 2237 } 2237 2238 if (errors) { … … 2255 2256 } 2256 2257 } 2257 psVector *mask U8= NULL; // Input mask vector, U8 version2258 psVector *maskVector = NULL; // Input mask vector, U8 version 2258 2259 if (mask) { 2259 if (mask->type.type == PS_TYPE_ MASK) {2260 mask U8= psMemIncrRefCounter((psPtr)mask);2260 if (mask->type.type == PS_TYPE_VECTOR_MASK) { 2261 maskVector = psMemIncrRefCounter((psPtr)mask); 2261 2262 } else { 2262 mask U8 = psVectorCopy(NULL, mask, PS_TYPE_MASK);2263 maskVector = psVectorCopy(NULL, mask, PS_TYPE_VECTOR_MASK); 2263 2264 } 2264 2265 } … … 2279 2280 // ************************************************************************ 2280 2281 if (stats->options & PS_STAT_SAMPLE_MEAN) { 2281 if (!vectorSampleMean(inF32, errorsF32, mask U8, maskVal, stats)) {2282 if (!vectorSampleMean(inF32, errorsF32, maskVector, maskVal, stats)) { 2282 2283 psError(PS_ERR_UNKNOWN, false, "Failed to calculate vector sample mean"); 2283 2284 status &= false; … … 2287 2288 // ************************************************************************ 2288 2289 if (stats->options & (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_QUARTILE)) { 2289 if (!vectorSampleMedian(inF32, mask U8, maskVal, stats)) {2290 if (!vectorSampleMedian(inF32, maskVector, maskVal, stats)) { 2290 2291 psError(PS_ERR_UNKNOWN, false, "Failed to calculate sample median"); 2291 2292 status &= false; … … 2295 2296 // ************************************************************************ 2296 2297 if (stats->options & PS_STAT_SAMPLE_STDEV) { 2297 if (!vectorSampleStdev(inF32, errorsF32, mask U8, maskVal, stats)) {2298 if (!vectorSampleStdev(inF32, errorsF32, maskVector, maskVal, stats)) { 2298 2299 psError(PS_ERR_UNKNOWN, false, "Failed to calculate sample stdev"); 2299 2300 status &= false; … … 2302 2303 2303 2304 if (stats->options & (PS_STAT_SAMPLE_SKEWNESS | PS_STAT_SAMPLE_KURTOSIS)) { 2304 if (!vectorSampleMoments(inF32, mask U8, maskVal, stats)) {2305 if (!vectorSampleMoments(inF32, maskVector, maskVal, stats)) { 2305 2306 psError(PS_ERR_UNKNOWN, false, "Failed to calculate sample moments"); 2306 2307 status &= false; … … 2310 2311 // ************************************************************************ 2311 2312 if (stats->options & (PS_STAT_MAX | PS_STAT_MIN)) { 2312 if (vectorMinMax(inF32, mask U8, maskVal, stats) == 0) {2313 if (vectorMinMax(inF32, maskVector, maskVal, stats) == 0) { 2313 2314 psError(PS_ERR_UNKNOWN, false, "Failed to calculate vector minimum and maximum"); 2314 2315 status &= false; … … 2318 2319 // ************************************************************************ 2319 2320 if (stats->options & (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV | PS_STAT_ROBUST_QUARTILE)) { 2320 if (!vectorRobustStats(inF32, errorsF32, mask U8, maskVal, stats)) {2321 if (!vectorRobustStats(inF32, errorsF32, maskVector, maskVal, stats)) { 2321 2322 psError(PS_ERR_UNKNOWN, false, _("Failed to calculate robust statistics")); 2322 2323 status &= false; … … 2326 2327 // ************************************************************************ 2327 2328 if (stats->options & (PS_STAT_FITTED_MEAN | PS_STAT_FITTED_STDEV)) { 2328 if (!vectorFittedStats(inF32, errorsF32, mask U8, maskVal, stats)) {2329 if (!vectorFittedStats(inF32, errorsF32, maskVector, maskVal, stats)) { 2329 2330 psError(PS_ERR_UNKNOWN, false, _("Failed to calculate fitted statistics")); 2330 2331 status &= false; … … 2337 2338 psAbort("you may not specify both FITTED_MEAN and FITTED_MEAN_V2"); 2338 2339 } 2339 if (!vectorFittedStats_v2(inF32, errorsF32, mask U8, maskVal, stats)) {2340 if (!vectorFittedStats_v2(inF32, errorsF32, maskVector, maskVal, stats)) { 2340 2341 psError(PS_ERR_UNKNOWN, false, _("Failed to calculate fitted statistics")); 2341 2342 status &= false; … … 2348 2349 psAbort("you may not specify both FITTED_MEAN and FITTED_MEAN_V3"); 2349 2350 } 2350 if (!vectorFittedStats_v3(inF32, errorsF32, mask U8, maskVal, stats)) {2351 if (!vectorFittedStats_v3(inF32, errorsF32, maskVector, maskVal, stats)) { 2351 2352 psError(PS_ERR_UNKNOWN, false, _("Failed to calculate fitted statistics")); 2352 2353 status &= false; … … 2359 2360 psAbort("you may not specify both FITTED_MEAN and FITTED_MEAN_V4"); 2360 2361 } 2361 if (!vectorFittedStats_v4(inF32, errorsF32, mask U8, maskVal, stats)) {2362 if (!vectorFittedStats_v4(inF32, errorsF32, maskVector, maskVal, stats)) { 2362 2363 psError(PS_ERR_UNKNOWN, false, _("Failed to calculate fitted statistics")); 2363 2364 status &= false; … … 2367 2368 // ************************************************************************ 2368 2369 if ((stats->options & PS_STAT_CLIPPED_MEAN) || (stats->options & PS_STAT_CLIPPED_STDEV)) { 2369 if (!vectorClippedStats(inF32, errorsF32, mask U8, maskVal, stats)) {2370 if (!vectorClippedStats(inF32, errorsF32, maskVector, maskVal, stats)) { 2370 2371 psError(PS_ERR_UNKNOWN, false, "Failed to calculate clipped statistics\n"); 2371 2372 status &= false; … … 2375 2376 psFree(inF32); 2376 2377 psFree(errorsF32); 2377 psFree(mask U8);2378 psFree(maskVector); 2378 2379 psTrace(TRACE, 3,"---- %s() end ----\n", __func__); 2379 2380 return status; -
trunk/psLib/src/math/psStats.h
r18876 r21183 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1.6 5$ $Name: not supported by cvs2svn $11 * @date $Date: 200 8-08-03 20:55:09$10 * @version $Revision: 1.66 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-01-27 06:39:38 $ 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 13 13 */ … … 96 96 */ 97 97 bool psVectorStats( 98 psStats* stats, ///< stats structure defines stats to be calculated and how99 const psVector* in, ///< Vector to be analysed.100 const psVector* errors, ///< Errors.101 const psVector* mask, ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL102 ps MaskType maskVal///< Only mask elements with one of these bits set in maskVector98 psStats* stats, ///< stats structure defines stats to be calculated and how 99 const psVector* in, ///< Vector to be analysed. 100 const psVector* errors, ///< Errors. 101 const psVector* mask, ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL 102 psVectorMaskType maskVal ///< Only mask elements with one of these bits set in maskVector 103 103 ); 104 104 -
trunk/psLib/src/mathtypes/psVector.c
r20547 r21183 10 10 * @author Joshua Hoblitt, University of Hawaii 11 11 * 12 * @version $Revision: 1.10 4$ $Name: not supported by cvs2svn $13 * @date $Date: 200 8-11-05 11:12:40$12 * @version $Revision: 1.105 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2009-01-27 06:39:38 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 987 987 } 988 988 989 // count number of pixels with given mask value 989 // count number of pixels with given mask value. the comparison is against a U64 type to 990 // allow any int-type of vector. all signed and unsigned int types are allowed 990 991 long psVectorCountPixelMask (psVector *mask, 991 ps MaskTypevalue)992 psU64 value) 992 993 { 993 994 long Npixels = 0; … … 998 999 } 999 1000 1000 psElemType type; 1001 type = mask->type.type; 1002 1003 if (type != PS_TYPE_MASK) { 1004 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1005 "psVector type does not match the specified psMaskType!\n"); 1006 return -1; 1007 } 1008 1001 # define PS_VECTOR_COUNT_PIXEL_MASK(NAME,TYPE) \ 1002 case PS_TYPE_##NAME: \ 1003 for (long i = 0; i < mask->n; i++) { \ 1004 if (mask->data.TYPE[i] & value) { \ 1005 Npixels ++; \ 1006 } \ 1007 } \ 1008 break; 1009 1010 psElemType type = mask->type.type; 1009 1011 switch (type) { 1010 case PS_TYPE_U8: 1011 case PS_TYPE_U16: 1012 for (long i = 0; i < mask->n; i++) { 1013 if (mask->data.PS_TYPE_MASK_DATA[i] & value) { 1014 Npixels ++; 1015 } 1016 } 1017 break; 1018 case PS_TYPE_S8: 1019 case PS_TYPE_S16: 1020 case PS_TYPE_S32: 1021 case PS_TYPE_S64: 1022 case PS_TYPE_U32: 1023 case PS_TYPE_U64: 1024 case PS_TYPE_F32: 1025 case PS_TYPE_F64: 1012 PS_VECTOR_COUNT_PIXEL_MASK(U8, U8); 1013 PS_VECTOR_COUNT_PIXEL_MASK(U16,U16); 1014 PS_VECTOR_COUNT_PIXEL_MASK(U32,U32); 1015 PS_VECTOR_COUNT_PIXEL_MASK(U64,U64); 1016 PS_VECTOR_COUNT_PIXEL_MASK(S8, S8); 1017 PS_VECTOR_COUNT_PIXEL_MASK(S16,S16); 1018 PS_VECTOR_COUNT_PIXEL_MASK(S32,S32); 1019 PS_VECTOR_COUNT_PIXEL_MASK(S64,S64); 1026 1020 default: 1027 1021 psError(PS_ERR_BAD_PARAMETER_TYPE, true, -
trunk/psLib/src/mathtypes/psVector.h
r19502 r21183 10 10 * @author Joshua Hoblitt, University of Hawaii 11 11 * 12 * @version $Revision: 1.7 3$ $Name: not supported by cvs2svn $13 * @date $Date: 200 8-09-12 00:22:48 $12 * @version $Revision: 1.74 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2009-01-27 06:39:38 $ 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 15 15 */ … … 379 379 */ 380 380 long psVectorCountPixelMask( 381 psVector *mask, ///< input vector to count382 ps MaskType value///< the mask value to satisfy381 psVector *mask, ///< input vector to count 382 psU64 value ///< the mask value to satisfy 383 383 ); 384 384 -
trunk/psLib/src/sys/psType.h
r14454 r21183 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.6 2$ $Name: not supported by cvs2svn $13 * @date $Date: 200 7-08-09 03:30:47$12 * @version $Revision: 1.63 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2009-01-27 06:39:38 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 141 141 } psDataType; 142 142 143 // macros to abstract the generic mask type : these values must be consistent 143 144 #define PS_TYPE_MASK PS_TYPE_U8 /**< the psElemType to use for mask image */ 144 145 #define PS_TYPE_MASK_DATA U8 /**< the data member to use for mask image */ 145 146 #define PS_TYPE_MASK_NAME "psU8" /**< the data type for mask as a string */ 146 147 #define PS_MIN_MASK_TYPE 0 /**< minimum valid Mask value */ 148 #define PS_MAX_MASK_TYPE UINT8_MAX /**< maximum valid Mask value */ 147 149 typedef psU8 psMaskType; ///< the C datatype for a mask image 150 #define PS_NOT_MASK(A)(UINT8_MAX-(A)) 151 152 // alternate versions if needed 153 // #define PS_NOT_MASK(A)(UINT16_MAX-(A)) 154 // #define PS_NOT_MASK(A)(UINT32_MAX-(A)) 155 // #define PS_NOT_MASK(A)(UINT64_MAX-(A)) 156 157 // macros to abstract the vector mask type : these values must be consistent 158 #define PS_TYPE_VECTOR_MASK PS_TYPE_U8 /**< the psElemType to use for mask image */ 159 #define PS_TYPE_VECTOR_MASK_DATA U8 /**< the data member to use for mask image */ 160 #define PS_TYPE_VECTOR_MASK_NAME "psU8" /**< the data type for mask as a string */ 161 #define PS_MIN_VECTOR_MASK_TYPE 0 /**< minimum valid Vector Mask value */ 162 #define PS_MAX_VECTOR_MASK_TYPE UINT8_MAX /**< maximum valid Vector Mask value */ 163 typedef psU8 psVectorMaskType; ///< the C datatype for a mask image 164 #define PS_NOT_VECTOR_MASK(A)(UINT8_MAX-(A)) 165 166 // macros to abstract the image mask type : these values must be consistent 167 #define PS_TYPE_IMAGE_MASK PS_TYPE_U16 /**< the psElemType to use for mask image */ 168 #define PS_TYPE_IMAGE_MASK_DATA U16 /**< the data member to use for mask image */ 169 #define PS_TYPE_IMAGE_MASK_NAME "psU16" /**< the data type for mask as a string */ 170 #define PS_MIN_IMAGE_MASK_TYPE 0 /**< minimum valid Image Mask value */ 171 #define PS_MAX_IMAGE_MASK_TYPE UINT16_MAX /**< maximum valid Image Mask value */ 172 typedef psU16 psImageMaskType; ///< the C datatype for a mask image 173 #define PS_NOT_IMAGE_MASK(A)(UINT16_MAX-(A)) 148 174 149 175 #define PS_MIN_S8 INT8_MIN /**< minimum valid psS8 value */ -
trunk/psLib/src/types/psMetadata.c
r20417 r21183 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.17 4$ $Name: not supported by cvs2svn $15 * @date $Date: 200 8-10-28 00:13:19$14 * @version $Revision: 1.175 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2009-01-27 06:39:38 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 866 866 METADATA_ADD_TYPE(F32,psF32,PS_DATA_F32) 867 867 METADATA_ADD_TYPE(F64,psF64,PS_DATA_F64) 868 869 METADATA_ADD_TYPE(Mask,psMaskType,PS_TYPE_MASK) 870 METADATA_ADD_TYPE(VectorMask,psVectorMaskType,PS_TYPE_VECTOR_MASK) 871 METADATA_ADD_TYPE(ImageMask,psImageMaskType,PS_TYPE_IMAGE_MASK) 872 868 873 METADATA_ADD_TYPE(List,psList*,PS_DATA_LIST) 869 874 METADATA_ADD_TYPE(Str,const char*,PS_DATA_STRING) … … 1011 1016 } 1012 1017 1013 #define psMetadataLookupNumTYPE(TYPE ) \1014 ps##TYPE psMetadataLookup## TYPE(bool *status, const psMetadata *md, const char *key) \1018 #define psMetadataLookupNumTYPE(TYPE,NAME) \ 1019 ps##TYPE psMetadataLookup##NAME(bool *status, const psMetadata *md, const char *key) \ 1015 1020 { \ 1016 1021 psMetadataItem *metadataItem = NULL; \ … … 1081 1086 } 1082 1087 1083 psMetadataLookupNumTYPE(F32) 1084 psMetadataLookupNumTYPE(F64) 1085 psMetadataLookupNumTYPE(S8) 1086 psMetadataLookupNumTYPE(S16) 1087 psMetadataLookupNumTYPE(S32) 1088 psMetadataLookupNumTYPE(S64) 1089 psMetadataLookupNumTYPE(U8) 1090 psMetadataLookupNumTYPE(U16) 1091 psMetadataLookupNumTYPE(U32) 1092 psMetadataLookupNumTYPE(U64) 1093 psMetadataLookupNumTYPE(Bool) 1088 psMetadataLookupNumTYPE(F32,F32) 1089 psMetadataLookupNumTYPE(F64,F64) 1090 psMetadataLookupNumTYPE(S8,S8) 1091 psMetadataLookupNumTYPE(S16,S16) 1092 psMetadataLookupNumTYPE(S32,S32) 1093 psMetadataLookupNumTYPE(S64,S64) 1094 psMetadataLookupNumTYPE(U8,U8) 1095 psMetadataLookupNumTYPE(U16,U16) 1096 psMetadataLookupNumTYPE(U32,U32) 1097 psMetadataLookupNumTYPE(U64,U64) 1098 psMetadataLookupNumTYPE(Bool,Bool) 1099 1100 psMetadataLookupNumTYPE(MaskType,Mask) 1101 psMetadataLookupNumTYPE(VectorMaskType,VectorMask) 1102 psMetadataLookupNumTYPE(ImageMaskType,ImageMask) 1094 1103 1095 1104 psMetadataItem* psMetadataGet(const psMetadata *md, -
trunk/psLib/src/types/psMetadata.h
r19056 r21183 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.10 5$ $Name: not supported by cvs2svn $12 * @date $Date: 200 8-08-14 03:18:41$11 * @version $Revision: 1.106 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2009-01-27 06:39:38 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 763 763 764 764 765 /** Add a psMaskType value to metadata collection. 766 * 767 * @return bool: True for success, False for failure. 768 */ 769 bool psMetadataAddMask( 770 psMetadata* md, ///< Metadata collection to insert metadata item 771 long location, ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL 772 const char* name, ///< Name of metadata item 773 int format, ///< psMetadataFlag options/flags 774 const char* comment, ///< Comment for metadata item 775 psMaskType value ///< Value for metadata item data 776 ); 777 778 779 /** Add a psVectorMaskType value to metadata collection. 780 * 781 * @return bool: True for success, False for failure. 782 */ 783 bool psMetadataAddVectorMask( 784 psMetadata* md, ///< Metadata collection to insert metadata item 785 long location, ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL 786 const char* name, ///< Name of metadata item 787 int format, ///< psMetadataFlag options/flags 788 const char* comment, ///< Comment for metadata item 789 psVectorMaskType value ///< Value for metadata item data 790 ); 791 792 793 /** Add a psImageMaskType value to metadata collection. 794 * 795 * @return bool: True for success, False for failure. 796 */ 797 bool psMetadataAddImageMask( 798 psMetadata* md, ///< Metadata collection to insert metadata item 799 long location, ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL 800 const char* name, ///< Name of metadata item 801 int format, ///< psMetadataFlag options/flags 802 const char* comment, ///< Comment for metadata item 803 psImageMaskType value ///< Value for metadata item data 804 ); 805 806 807 765 808 /** Add a psList to metadata collection. 766 809 * … … 1095 1138 */ 1096 1139 psU64 psMetadataLookupU64( 1140 bool *status, ///< Status of lookup. 1141 const psMetadata *md, ///< Metadata collection to lookup metadata item. 1142 const char *key ///< Name of metadata key. 1143 ); 1144 1145 1146 /** Find an item in the metadata collection based on key name and return its integer value. 1147 * 1148 * Items may be found in the metadata by providing a key. If the key is 1149 * non-unique, the value of the first item is returned. If the item is not 1150 * found, zero is returned. 1151 * 1152 * @return psMaskType : Value of metadata item. 1153 */ 1154 psMaskType psMetadataLookupMask( 1155 bool *status, ///< Status of lookup. 1156 const psMetadata *md, ///< Metadata collection to lookup metadata item. 1157 const char *key ///< Name of metadata key. 1158 ); 1159 1160 1161 /** Find an item in the metadata collection based on key name and return its integer value. 1162 * 1163 * Items may be found in the metadata by providing a key. If the key is 1164 * non-unique, the value of the first item is returned. If the item is not 1165 * found, zero is returned. 1166 * 1167 * @return psVectorMaskType : Value of metadata item. 1168 */ 1169 psVectorMaskType psMetadataLookupVectorMask( 1170 bool *status, ///< Status of lookup. 1171 const psMetadata *md, ///< Metadata collection to lookup metadata item. 1172 const char *key ///< Name of metadata key. 1173 ); 1174 1175 1176 /** Find an item in the metadata collection based on key name and return its integer value. 1177 * 1178 * Items may be found in the metadata by providing a key. If the key is 1179 * non-unique, the value of the first item is returned. If the item is not 1180 * found, zero is returned. 1181 * 1182 * @return psImageMaskType : Value of metadata item. 1183 */ 1184 psImageMaskType psMetadataLookupImageMask( 1097 1185 bool *status, ///< Status of lookup. 1098 1186 const psMetadata *md, ///< Metadata collection to lookup metadata item. -
trunk/psLib/src/types/psPixels.c
r19539 r21183 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.4 3$ $Name: not supported by cvs2svn $10 * @date $Date: 200 8-09-12 22:36:29$9 * @version $Revision: 1.44 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:38 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 150 150 const psPixels *pixels, 151 151 psRegion region, 152 ps MaskType maskVal)152 psImageMaskType maskVal) 153 153 { 154 154 PS_ASSERT_PIXELS_NON_NULL(pixels, NULL); … … 169 169 int numRows = y1 - y0 + 1, numCols = x1 - x0 + 1; // Size of image 170 170 171 out = psImageRecycle(out, numCols, numRows, PS_TYPE_ MASK);171 out = psImageRecycle(out, numCols, numRows, PS_TYPE_IMAGE_MASK); 172 172 if (!out) { 173 173 psError(PS_ERR_UNKNOWN, false, _("Failed to create image of size %dx%d."), numCols, numRows); … … 181 181 // cycle through the vector of pixels and insert pixels into image 182 182 long length = pixels->n; // Length of pixel array 183 ps MaskType** outData = out->data.PS_TYPE_MASK_DATA;183 psImageMaskType** outData = out->data.PS_TYPE_IMAGE_MASK_DATA; 184 184 for (int p = 0; p < length; p++) { 185 185 float x = pixels->data[p].x; … … 196 196 psPixels* psPixelsFromMask(psPixels* out, 197 197 const psImage* mask, 198 ps MaskType maskVal)198 psImageMaskType maskVal) 199 199 { 200 200 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 201 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, NULL);201 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 202 202 203 203 int numRows = mask->numRows, numCols = mask->numCols; // Size of image … … 214 214 for (int y = 0; y < numRows; y++) { 215 215 for (int x = 0; x < numCols; x++) { 216 if (mask->data.PS_TYPE_ MASK_DATA[y][x] & maskVal) {216 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) { 217 217 psPixelsAdd(out, out->nalloc, x, y); 218 218 } -
trunk/psLib/src/types/psPixels.h
r19539 r21183 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.3 0$ $Name: not supported by cvs2svn $9 * @date $Date: 200 8-09-12 22:36:29$8 * @version $Revision: 1.31 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-01-27 06:39:38 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 189 189 const psPixels* pixels, ///< list of pixels to use 190 190 psRegion region, ///< region to define the output mask image 191 ps MaskType maskVal///< the mask bit-values to act upon191 psImageMaskType maskVal ///< the mask bit-values to act upon 192 192 ); 193 193 … … 205 205 psPixels *out, ///< psPixels to recycle, or NULL 206 206 const psImage *mask, ///< the input mask psImage 207 ps MaskType maskVal///< the mask bit-values to act upon207 psImageMaskType maskVal ///< the mask bit-values to act upon 208 208 ); 209 209
Note:
See TracChangeset
for help on using the changeset viewer.
