- Timestamp:
- Oct 2, 2009, 5:10:19 PM (17 years ago)
- Location:
- branches/eam_branches/20090820
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
magic/remove/src/streaksremove.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090820
- Property svn:mergeinfo changed
-
branches/eam_branches/20090820/magic/remove/src/streaksremove.c
r25084 r25766 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 psU32 mask = psImageGet(maskImage, x, y); 866 psImageMaskType mask; 867 if ((x >= maskImage->numCols) || (y >= maskImage->numRows) || (x < 0) || (y < 0)) { 868 mask = maskStreak; 869 } else { 870 mask = maskImage->data.PS_TYPE_IMAGE_MASK_DATA[(int)y][(int)x]; 871 } 858 872 859 873 // Key the source if the center pixel is not masked with maskStreak
Note:
See TracChangeset
for help on using the changeset viewer.
