Changeset 26472
- Timestamp:
- Dec 22, 2009, 9:54:34 AM (16 years ago)
- Location:
- branches/eam_branches/20091201/psModules/src/imcombine
- Files:
-
- 2 edited
-
pmSubtractionVisual.c (modified) (1 diff)
-
pmSubtractionVisual.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/psModules/src/imcombine/pmSubtractionVisual.c
r26429 r26472 216 216 pmVisualScaleImage(kapa1, ref, "Reference", 1, true); 217 217 pmVisualScaleImage(kapa1, sub, "Subtraction", 2, true); 218 pmVisualAskUser(&plotImage); 219 return true; 220 } 221 222 bool pmSubtractionVisualShowKernels(pmSubtractionKernels *kernels) { 223 224 if (!pmVisualIsVisual()) return true; 225 if (!pmVisualInitWindow (&kapa1, "PPSub:Images")) { 226 return false; 227 } 228 229 // get the kernel sizes 230 int footprint = kernels->size; 231 232 // output image is a grid of NXsub by NYsub sub-images 233 int NXsub = sqrt(kernels->num); 234 int NYsub = kernels->num / NXsub; 235 if (kernels->num % NXsub) NYsub++; 236 237 int NXpix = NXsub * (2*footprint + 1 + 3); 238 int NYpix = NYsub * (2*footprint + 1 + 3); 239 240 psImage *output = psImageAlloc(NXpix, NYpix, PS_TYPE_F32); 241 psImageInit (output, 0.0); 242 243 for (int i = 0; i < kernels->num; i++) { 244 psArray *preCalc = kernels->preCalc->data[i]; 245 psKernel *kernel = preCalc->data[2]; 246 247 int xSub = i % NXsub; 248 int ySub = i / NXsub; 249 250 int xPix = xSub * (2*footprint + 1 + 3) + footprint; 251 int yPix = ySub * (2*footprint + 1 + 3) + footprint; 252 253 for (int y = -footprint; y <= footprint; y++) { 254 for (int x = -footprint; x <= footprint; x++) { 255 output->data.F32[y + yPix][x + xPix] = kernel->kernel[y][x]; 256 } 257 } 258 } 259 260 pmVisualScaleImage(kapa1, output, "Image", 0, true); 261 pmVisualAskUser(&plotImage); 262 return true; 263 } 264 265 bool pmSubtractionVisualShowBasis(pmSubtractionStampList *stamps) { 266 267 if (!pmVisualIsVisual()) return true; 268 if (!pmVisualInitWindow (&kapa2, "ppSub:StampMasterImage")) { 269 return false; 270 } 271 272 // get the kernel sizes 273 int footprint = stamps->footprint; 274 275 // choose the brightest stamp 276 pmSubtractionStamp *maxStamp = stamps->stamps->data[0]; 277 float maxFlux = maxStamp->flux; 278 for (int i = 1; i < stamps->num; i++) { 279 pmSubtractionStamp *stamp = stamps->stamps->data[i]; 280 if (stamp->flux > maxFlux) { 281 maxFlux = stamp->flux; 282 maxStamp = stamp; 283 } 284 } 285 286 int nKernels = 0; 287 288 if (maxStamp->convolutions1) { 289 // output image is a grid of NXsub by NYsub sub-images 290 nKernels = maxStamp->convolutions1->n; 291 int NXsub = sqrt(nKernels); 292 int NYsub = nKernels / NXsub; 293 if (nKernels % NXsub) NYsub++; 294 295 int NXpix = NXsub * (2*footprint + 1 + 3); 296 int NYpix = NYsub * (2*footprint + 1 + 3); 297 298 psImage *output = psImageAlloc(NXpix, NYpix, PS_TYPE_F32); 299 psImageInit (output, 0.0); 300 301 for (int i = 0; i < nKernels; i++) { 302 psKernel *kernel = maxStamp->convolutions1->data[i]; 303 304 int xSub = i % NXsub; 305 int ySub = i / NXsub; 306 307 int xPix = xSub * (2*footprint + 1 + 3) + footprint; 308 int yPix = ySub * (2*footprint + 1 + 3) + footprint; 309 310 for (int y = -footprint; y <= footprint; y++) { 311 for (int x = -footprint; x <= footprint; x++) { 312 output->data.F32[y + yPix][x + xPix] = kernel->kernel[y][x]; 313 } 314 } 315 } 316 pmVisualScaleImage(kapa2, output, "Image", 0, true); 317 } 318 319 if (maxStamp->convolutions2) { 320 // output image is a grid of NXsub by NYsub sub-images 321 nKernels = maxStamp->convolutions2->n; 322 int NXsub = sqrt(nKernels); 323 int NYsub = nKernels / NXsub; 324 if (nKernels % NXsub) NYsub++; 325 326 int NXpix = NXsub * (2*footprint + 1 + 3); 327 int NYpix = NYsub * (2*footprint + 1 + 3); 328 329 psImage *output = psImageAlloc(NXpix, NYpix, PS_TYPE_F32); 330 psImageInit (output, 0.0); 331 332 for (int i = 0; i < nKernels; i++) { 333 psKernel *kernel = maxStamp->convolutions2->data[i]; 334 335 int xSub = i % NXsub; 336 int ySub = i / NXsub; 337 338 int xPix = xSub * (2*footprint + 1 + 3) + footprint; 339 int yPix = ySub * (2*footprint + 1 + 3) + footprint; 340 341 for (int y = -footprint; y <= footprint; y++) { 342 for (int x = -footprint; x <= footprint; x++) { 343 output->data.F32[y + yPix][x + xPix] = kernel->kernel[y][x]; 344 } 345 } 346 } 347 pmVisualScaleImage(kapa2, output, "Image", 1, true); 348 } 349 218 350 pmVisualAskUser(&plotImage); 219 351 return true; -
branches/eam_branches/20091201/psModules/src/imcombine/pmSubtractionVisual.h
r26318 r26472 11 11 bool pmSubtractionVisualShowFit(); 12 12 bool pmSubtractionVisualPlotFit(const pmSubtractionKernels *kernels); 13 bool pmSubtractionVisualShowKernels(pmSubtractionKernels *kernels); 14 bool pmSubtractionVisualShowBasis(pmSubtractionStampList *stamps); 13 15 14 16 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
