- Timestamp:
- Dec 2, 2009, 12:04:51 PM (16 years ago)
- Location:
- branches/pap/psModules/src/imcombine
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
pmSubtractionVisual.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap/psModules/src/imcombine
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/eam_branches/20091201/psModules/src/imcombine merged eligible /branches/eam_branches/20091113/psModules/src/imcombine 26119-26255
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/pap/psModules/src/imcombine/pmSubtractionVisual.c
r23487 r26321 16 16 17 17 #include "pmKapaPlots.h" 18 #include "pmSubtraction.h" 18 19 #include "pmSubtractionStamps.h" 20 #include "pmSubtractionEquation.h" 19 21 20 22 #include "pmVisual.h" … … 32 34 static bool plotLeastSquares = true; 33 35 static bool plotImage = true; 36 34 37 // variables to store plotting window indices 35 static int kapa = -1;38 static int kapa1 = -1; 36 39 static int kapa2 = -1; 40 static int kapa3 = -1; 37 41 38 42 /** function prototypes*/ … … 46 50 bool pmSubtractionVisualClose(void) 47 51 { 48 if(kapa != -1) 49 KiiClose(kapa); 50 if(kapa2 != -1) 51 KiiClose(kapa2); 52 if(kapa1 != -1) KiiClose(kapa1); 53 if(kapa2 != -1) KiiClose(kapa2); 52 54 return true; 53 55 } … … 60 62 bool pmSubtractionVisualPlotConvKernels(psImage *convKernels) { 61 63 if (!pmVisualIsVisual() || !plotConvKernels) return true; 62 if (!pmVisualInitWindow(&kapa , "ppSub:Images")) {63 return false; 64 } 65 pmVisualScaleImage(kapa , convKernels, "Convolution_Kernels", 0, true);64 if (!pmVisualInitWindow(&kapa1, "ppSub:Images")) { 65 return false; 66 } 67 pmVisualScaleImage(kapa1, convKernels, "Convolution_Kernels", 0, true); 66 68 pmVisualAskUser(&plotConvKernels); 67 69 return true; … … 74 76 bool pmSubtractionVisualPlotStamps(pmSubtractionStampList *stamps, pmReadout *ro) { 75 77 if (!pmVisualIsVisual() || !plotStamps) return true; 76 if (!pmVisualInitWindow (&kapa , "ppSub:Images")) {78 if (!pmVisualInitWindow (&kapa1, "ppSub:Images")) { 77 79 return false; 78 80 } … … 134 136 stampNum++; 135 137 } 136 pmVisualScaleImage(kapa , canvas, "Subtraction_Stamps", 0, true);138 pmVisualScaleImage(kapa1, canvas, "Subtraction_Stamps", 0, true); 137 139 138 140 pmVisualAskUser(&plotStamps); … … 144 146 145 147 if (!pmVisualIsVisual() || !plotLeastSquares) return true; 146 if (!pmVisualInitWindow (&kapa , "PPSub:Images")) {148 if (!pmVisualInitWindow (&kapa1, "PPSub:Images")) { 147 149 return false; 148 150 } … … 197 199 198 200 psImage *canvas32 = pmVisualImageToFloat(canvas); 199 pmVisualScaleImage(kapa , canvas32, "Least_Squares", 0, true);201 pmVisualScaleImage(kapa1, canvas32, "Least_Squares", 0, true); 200 202 201 203 pmVisualAskUser(&plotLeastSquares); … … 207 209 bool pmSubtractionVisualShowSubtraction(psImage *image, psImage *ref, psImage *sub) { 208 210 if (!pmVisualIsVisual() || !plotImage) return true; 209 if (!pmVisualInitWindow (&kapa , "PPSub:Images")) {210 return false; 211 } 212 213 pmVisualScaleImage(kapa , image, "Image", 0, true);214 pmVisualScaleImage(kapa , ref, "Reference", 1, true);215 pmVisualScaleImage(kapa , sub, "Subtraction", 2, true);211 if (!pmVisualInitWindow (&kapa1, "PPSub:Images")) { 212 return false; 213 } 214 215 pmVisualScaleImage(kapa1, image, "Image", 0, true); 216 pmVisualScaleImage(kapa1, ref, "Reference", 1, true); 217 pmVisualScaleImage(kapa1, sub, "Subtraction", 2, true); 216 218 pmVisualAskUser(&plotImage); 217 219 return true; … … 255 257 } 256 258 259 static int footprint = 0; 260 static int NX = 0; 261 static int NY = 0; 262 static psImage *sourceImage = NULL; 263 static psImage *targetImage = NULL; 264 static psImage *residualImage = NULL; 265 static psImage *differenceImage = NULL; 266 static psImage *convolutionImage = NULL; 267 268 bool pmSubtractionVisualShowFitInit(pmSubtractionStampList *stamps) { 269 270 // if (!pmVisualIsVisual()) return true; 271 272 // generate 4 storage images large enough to hold the N stamps: 273 274 footprint = stamps->footprint; 275 276 float NXf = sqrt(stamps->num); 277 NX = (int) NXf == NXf ? NXf : NXf + 1.0; 278 279 float NYf = stamps->num / NX; 280 NY = (int) NYf == NY ? NYf : NYf + 1.0; 281 282 int NXpix = (2*footprint + 1) * NX; 283 NXpix += (NX > 1) ? 3 * NX : 0; 284 285 int NYpix = (2*footprint + 1) * NY; 286 NYpix += (NY > 1) ? 3 * NY : 0; 287 288 sourceImage = psImageAlloc (NXpix, NYpix, PS_TYPE_F32); 289 targetImage = psImageAlloc (NXpix, NYpix, PS_TYPE_F32); 290 residualImage = psImageAlloc (NXpix, NYpix, PS_TYPE_F32); 291 differenceImage = psImageAlloc (NXpix, NYpix, PS_TYPE_F32); 292 convolutionImage = psImageAlloc (NXpix, NYpix, PS_TYPE_F32); 293 294 psImageInit (sourceImage, 0.0); 295 psImageInit (targetImage, 0.0); 296 psImageInit (residualImage, 0.0); 297 psImageInit (differenceImage, 0.0); 298 psImageInit (convolutionImage, 0.0); 299 300 return true; 301 } 302 303 bool pmSubtractionVisualShowFitAddStamp(psKernel *target, psKernel *source, psKernel *convolution, double background, double norm, int index) { 304 305 // if (!pmVisualIsVisual()) return true; 306 307 int NXoff = index % NX; 308 int NYoff = index / NX; 309 310 int NXpix = NXoff * (2*footprint + 1 + 3) + footprint; 311 int NYpix = NYoff * (2*footprint + 1 + 3) + footprint; 312 313 // insert the (target) kernel into the (target) image: 314 for (int y = -footprint; y <= footprint; y++) { 315 for (int x = -footprint; x <= footprint; x++) { 316 targetImage->data.F32[y + NYpix][x + NXpix] = target->kernel[y][x]; 317 } 318 } 319 320 // insert the (source) kernel into the (source) image: 321 for (int y = -footprint; y <= footprint; y++) { 322 for (int x = -footprint; x <= footprint; x++) { 323 sourceImage->data.F32[y + NYpix][x + NXpix] = source->kernel[y][x]; 324 } 325 } 326 327 // insert the (convolution) kernel into the (convolution) image: 328 for (int y = -footprint; y <= footprint; y++) { 329 for (int x = -footprint; x <= footprint; x++) { 330 convolutionImage->data.F32[y + NYpix][x + NXpix] = -convolution->kernel[y][x]; 331 } 332 } 333 334 // insert the (difference) kernel into the (difference) image: 335 for (int y = -footprint; y <= footprint; y++) { 336 for (int x = -footprint; x <= footprint; x++) { 337 differenceImage->data.F32[y + NYpix][x + NXpix] = target->kernel[y][x] - background - source->kernel[y][x] * norm; 338 } 339 } 340 341 // insert the (residual) kernel into the (residual) image: 342 for (int y = -footprint; y <= footprint; y++) { 343 for (int x = -footprint; x <= footprint; x++) { 344 residualImage->data.F32[y + NYpix][x + NXpix] = target->kernel[y][x] - background - source->kernel[y][x] * norm + convolution->kernel[y][x]; 345 } 346 } 347 return true; 348 } 349 350 bool pmSubtractionVisualShowFit() { 351 352 // if (!pmVisualIsVisual()) return true; 353 if (!pmVisualInitWindow(&kapa1, "ppSub:Images")) return false; 354 if (!pmVisualInitWindow(&kapa2, "ppSub:Misc")) return false; 355 356 pmVisualScaleImage(kapa1, targetImage, "Target Stamps", 0, true); 357 pmVisualScaleImage(kapa1, sourceImage, "Source Stamps", 1, true); 358 pmVisualScaleImage(kapa1, convolutionImage, "Convolution Stamps", 2, true); 359 360 pmVisualScaleImage(kapa2, differenceImage, "Difference Stamps", 0, true); 361 pmVisualScaleImage(kapa2, residualImage, "Residual Stamps", 1, true); 362 pmVisualAskUser(NULL); 363 364 psFree(targetImage); 365 psFree(sourceImage); 366 psFree(convolutionImage); 367 psFree(differenceImage); 368 psFree(residualImage); 369 370 targetImage = NULL; 371 sourceImage = NULL; 372 convolutionImage = NULL; 373 differenceImage = NULL; 374 residualImage = NULL; 375 376 return true; 377 } 378 379 bool pmSubtractionVisualPlotFit(const pmSubtractionKernels *kernels) { 380 381 Graphdata graphdata; 382 383 // if (!pmVisualIsVisual()) return true; 384 if (!pmVisualInitWindow(&kapa3, "ppSub:plots")) return false; 385 386 KapaClearSections (kapa3); 387 KapaInitGraph (&graphdata); 388 389 psVector *x = psVectorAllocEmpty (kernels->num, PS_TYPE_F32); 390 psVector *y = psVectorAllocEmpty (kernels->num, PS_TYPE_F32); 391 392 graphdata.xmin = -1.0; 393 graphdata.xmax = kernels->num + 1.0; 394 graphdata.ymin = +32.0; 395 graphdata.ymax = -32.0; 396 397 psImage *polyValues = p_pmSubtractionPolynomial(NULL, kernels->spatialOrder, 0.0, 0.0); 398 399 // construct the plot vectors 400 for (int i = 0; i < kernels->num; i++) { 401 x->data.F32[i] = i; 402 y->data.F32[i] = p_pmSubtractionSolutionCoeff(kernels, polyValues, i, false); 403 graphdata.ymin = PS_MIN(graphdata.ymin, y->data.F32[i]); 404 graphdata.ymax = PS_MAX(graphdata.ymax, y->data.F32[i]); 405 } 406 x->n = y->n = kernels->num; 407 408 float range; 409 range = graphdata.xmax - graphdata.xmin; 410 graphdata.xmax += 0.05*range; 411 graphdata.xmin -= 0.05*range; 412 range = graphdata.ymax - graphdata.ymin; 413 graphdata.ymax += 0.05*range; 414 graphdata.ymin -= 0.05*range; 415 416 KapaSetLimits (kapa3, &graphdata); 417 418 KapaSetFont (kapa3, "helvetica", 14); 419 KapaBox (kapa3, &graphdata); 420 KapaSendLabel (kapa3, "kernel number", KAPA_LABEL_XM); 421 KapaSendLabel (kapa3, "coeff", KAPA_LABEL_YM); 422 423 graphdata.color = KapaColorByName ("black"); 424 graphdata.ptype = 2; 425 graphdata.size = 0.5; 426 graphdata.style = 2; 427 428 KapaPrepPlot (kapa3, x->n, &graphdata); 429 KapaPlotVector (kapa3, x->n, x->data.F32, "x"); 430 KapaPlotVector (kapa3, x->n, y->data.F32, "y"); 431 432 psFree (x); 433 psFree (y); 434 435 pmVisualAskUser(NULL); 436 return true; 437 } 438 257 439 #else 258 440 bool pmSubtractionVisualClose(void) {return true;} … … 261 443 bool pmSubtractionVisualPlotLeastSquares(pmSubtractionStampList *stamps) {return true;} 262 444 bool pmSubtractionVisualShowSubtraction(psImage *image, psImage *ref, psImage *sub) {return true;} 445 bool pmSubtractionVisualShowFitInit(pmSubtractionStampList *stamps) {return true;} 446 bool pmSubtractionVisualShowFitAddStamp(psKernel *target, psKernel *source, psKernel *convolution, double background, double norm, int index) {return true;} 447 bool pmSubtractionVisualShowFit() {return true;} 448 bool pmSubtractionVisualPlotFit(const pmSubtractionKernels *kernels); 263 449 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
