Changeset 21183 for trunk/psLib/src/imageops
- Timestamp:
- Jan 26, 2009, 8:40:07 PM (17 years ago)
- Location:
- trunk/psLib/src/imageops
- Files:
-
- 19 edited
-
psImageBackground.c (modified) (2 diffs)
-
psImageBackground.h (modified) (2 diffs)
-
psImageConvolve.c (modified) (45 diffs)
-
psImageConvolve.h (modified) (7 diffs)
-
psImageGeomManip.c (modified) (13 diffs)
-
psImageGeomManip.h (modified) (4 diffs)
-
psImageInterpolate.c (modified) (14 diffs)
-
psImageInterpolate.h (modified) (4 diffs)
-
psImageMap.c (modified) (6 diffs)
-
psImageMapFit.c (modified) (11 diffs)
-
psImageMapFit.h (modified) (4 diffs)
-
psImageMaskOps.c (modified) (14 diffs)
-
psImageMaskOps.h (modified) (6 diffs)
-
psImagePixelExtract.c (modified) (17 diffs)
-
psImagePixelExtract.h (modified) (4 diffs)
-
psImagePixelInterpolate.c (modified) (11 diffs)
-
psImagePixelInterpolate.h (modified) (2 diffs)
-
psImageStats.c (modified) (7 diffs)
-
psImageStats.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.
