Changeset 25212 for branches/czw_branch/cleanup/magic/remove/src
- Timestamp:
- Aug 26, 2009, 6:31:31 PM (17 years ago)
- Location:
- branches/czw_branch/cleanup
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
magic/remove/src/streaksio.c (modified) (4 diffs)
-
magic/remove/src/streaksremove.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/cleanup
- Property svn:mergeinfo changed
/trunk merged: 25194-25200,25207-25209
- Property svn:mergeinfo changed
-
branches/czw_branch/cleanup/magic/remove/src/streaksio.c
r25158 r25212 654 654 streaksExit("", PS_EXIT_DATA_ERROR); 655 655 } 656 657 // Ensure input is of the expected type 658 psDataType expected = isMask ? PS_TYPE_IMAGE_MASK : PS_TYPE_F32; // Expected type for image 659 for (int i = 0; i < in->imagecube->n; i++) { 660 psImage *image = in->imagecube->data[i]; // Image of interest 661 if (image->type.type != expected) { 662 psImage *temp = psImageCopy(NULL, image, expected); 663 psFree(image); 664 in->imagecube->data[i] = temp; 665 } 666 } 656 667 } 657 668 setDataExtent(stage, in, (stage == IPP_STAGE_RAW) && !isMask); … … 670 681 sfile->fits->options = psFitsOptionsAlloc(); 671 682 sfile->fits->options->scaling = PS_FITS_SCALE_MANUAL; 683 sfile->fits->options->fuzz = false; 672 684 sfile->fits->options->bitpix = bitpix; 673 685 sfile->fits->options->bscale = bscale; … … 1114 1126 // these gets are not necessary, we could just set the pixels to nan 1115 1127 // but I want to get the counts 1116 double imageVal = psImageGet(image, x, y);1128 double imageVal = image->data.F32[y][x]; 1117 1129 psU32 maskVal; 1118 1130 if (sfiles->stage == IPP_STAGE_RAW) { 1119 1131 unsigned int xChip, yChip; 1120 1132 cellToChipInt(&xChip, &yChip, sfiles->astrom, x, y); 1121 maskVal = psImageGet(mask, xChip, yChip);1133 maskVal = mask->data.PS_TYPE_IMAGE_MASK_DATA[yChip][xChip]; 1122 1134 } else { 1123 maskVal = psImageGet(mask, x, y);1135 maskVal = mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x]; 1124 1136 } 1125 1137 if (maskVal & maskMask) { … … 1127 1139 if (!isExciseValue(imageVal, sfiles->inImage->exciseValue)) { 1128 1140 ++nandPixels; 1129 psImageSet(image, x, y, exciseValue);1141 image->data.F32[y][x] = exciseValue; 1130 1142 } 1131 1143 if (weight) { 1132 double weightVal = weight ? psImageGet(weight, x, y): 0;1144 double weightVal = weight ? weight->data.F32[y][x] : 0; 1133 1145 if (!isnan(weightVal)) { 1134 1146 ++nandWeights; 1135 psImageSet(weight, x, y, NAN);1147 weight->data.F32[y][x] = NAN; 1136 1148 } 1137 1149 } -
branches/czw_branch/cleanup/magic/remove/src/streaksremove.c
r25158 r25212 12 12 static pmConfig *parseArguments(int argc, char **argv); 13 13 static bool readAndCopyToOutput(streakFiles *sf, bool exciseAll); 14 static void exciseNonWarpedPixels(streakFiles *sfiles, double newMaskValue);14 static void exciseNonWarpedPixels(streakFiles *sfiles, psImageMaskType newMaskValue); 15 15 static bool warpedPixel(streakFiles *sfiles, int x, int y); 16 static void excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, double newMaskValue);16 static void excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, psImageMaskType newMaskValue); 17 17 static void writeImages(streakFiles *sf, bool exciseImageCube); 18 18 static void updateAstrometry(streakFiles *sfiles); 19 static void censorSources(streakFiles *sfiles, psU32 maskStreak); 19 static void censorSources(streakFiles *sfiles, psImageMaskType maskStreak); 20 static long censorPixels(streakFiles *sfiles, psImage * pixels, bool checkNonWarpedPixels, psU16 maskStreak); 20 21 21 22 int … … 146 147 } 147 148 148 149 149 psTimerStart("REMOVE_STREAKS"); 150 150 151 for (int y=0 ; y < sfiles->inImage->numRows; y++) { 152 for (int x = 0; x < sfiles->inImage->numCols; x++) { 153 if (psImageGet(pixels, x, y)) { 154 ++totalStreakPixels; 155 if (!checkNonWarpedPixels || warpedPixel(sfiles, x, y)) { 156 157 excisePixel(sfiles, x, y, true, maskStreak); 158 159 } else { 160 // This pixel was not included in any warp and has thus already excised 161 // by exciseNonWarpedPixels 162 } 163 } 164 } 165 } 151 totalStreakPixels += censorPixels(sfiles, pixels, checkNonWarpedPixels, maskStreak); 166 152 167 153 psLogMsg("streaksremove", PS_LOG_INFO, "time to remove streak pixels: %f\n", psTimerClear("REMOVE_STREAKS")); … … 254 240 255 241 return 0; 242 } 243 244 static long 245 censorPixels(streakFiles *sfiles, psImage *pixels, bool checkNonWarpedPixels, psU16 maskStreak) 246 { 247 long streakPixels = 0; 248 249 for (int y=0 ; y < sfiles->inImage->numRows; y++) { 250 for (int x = 0; x < sfiles->inImage->numCols; x++) { 251 if (psImageGet(pixels, x, y)) { 252 ++streakPixels; 253 if (!checkNonWarpedPixels || warpedPixel(sfiles, x, y)) { 254 255 excisePixel(sfiles, x, y, true, maskStreak); 256 257 } else { 258 // This pixel was not included in any warp and has thus already excised 259 // by exciseNonWarpedPixels 260 } 261 } 262 } 263 } 264 return streakPixels; 256 265 } 257 266 … … 665 674 666 675 static void 667 excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, double newMaskValue)676 excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, psImageMaskType newMaskValue) 668 677 { 669 678 double exciseValue = sfiles->inImage->exciseValue; … … 674 683 } 675 684 676 double imageValue = psImageGet (sfiles->inImage->image, x, y);685 float imageValue = sfiles->inImage->image->data.F32[y][x]; 677 686 if (sfiles->recImage && !isExciseValue(imageValue, sfiles->inImage->exciseValue) ) { 678 psImageSet (sfiles->recImage->image, x, y, imageValue);687 sfiles->recImage->image->data.F32[y][x] = imageValue; 679 688 } 680 689 681 690 if (sfiles->transparentStreaks == 0) { 682 psImageSet (sfiles->outImage->image, x, y, exciseValue);691 sfiles->outImage->image->data.F32[y][x] = exciseValue; 683 692 } else { 684 693 if (streak) { 685 694 // as a visualization aid don't mask the pixel, just change the intensity 686 psImageSet (sfiles->outImage->image, x, y, imageValue + sfiles->transparentStreaks);695 sfiles->outImage->image->data.F32[y][x] = imageValue + sfiles->transparentStreaks; 687 696 } else { 688 psImageSet (sfiles->outImage->image, x, y, exciseValue);697 sfiles->outImage->image->data.F32[y][x] = exciseValue; 689 698 } 690 699 } … … 692 701 if (sfiles->outWeight) { 693 702 if (sfiles->recWeight) { 694 double weightValue = psImageGet (sfiles->inWeight->image, x, y); 695 psImageSet (sfiles->recWeight->image, x, y, weightValue); 703 sfiles->recWeight->image->data.F32[y][x] = sfiles->inWeight->image->data.F32[y][x]; 696 704 } 697 705 // Assume that weight images are always a floating point type 698 psImageSet (sfiles->outWeight->image, x, y, NAN);706 sfiles->outWeight->image->data.F32[y][x] = NAN; 699 707 } 700 708 if (sfiles->outMask) { 701 709 if (sfiles->recMask) { 702 double maskValue = psImageGet (sfiles->inMask->image, x, y); 703 psImageSet (sfiles->recMask->image, x, y, maskValue); 704 } 705 psImageSet (sfiles->outMask->image, x, y, newMaskValue); 710 sfiles->recMask->image->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = 711 sfiles->inMask->image->data.PS_TYPE_IMAGE_MASK_DATA[y][x]; 712 } 713 sfiles->outMask->image->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = 714 sfiles->inMask->image->data.PS_TYPE_IMAGE_MASK_DATA[y][x] | newMaskValue; 706 715 } 707 716 } 708 717 709 718 static void 710 exciseNonWarpedPixels(streakFiles *sfiles, double newMaskValue)719 exciseNonWarpedPixels(streakFiles *sfiles, psImageMaskType newMaskValue) 711 720 { 712 721 int cell_x0 = sfiles->astrom->cell_x0; … … 784 793 // streak mask 785 794 static void 786 censorSources(streakFiles *sfiles, ps U32maskStreak)795 censorSources(streakFiles *sfiles, psImageMaskType maskStreak) 787 796 { 788 797 if ((!sfiles->inSources) || (!sfiles->outMask)) { … … 855 864 psF32 y = psMetadataLookupF32(NULL, row, "Y_PSF"); 856 865 857 ps U32 mask = psImageGet(maskImage, x, y);866 psImageMaskType mask = maskImage->data.PS_TYPE_IMAGE_MASK_DATA[(int)y][(int)x]; 858 867 859 868 // Key the source if the center pixel is not masked with maskStreak
Note:
See TracChangeset
for help on using the changeset viewer.
