Changeset 13768
- Timestamp:
- Jun 12, 2007, 12:22:33 PM (19 years ago)
- Location:
- trunk/psModules/src
- Files:
-
- 3 edited
-
camera/pmFPARead.c (modified) (11 diffs)
-
camera/pmFPARead.h (modified) (2 diffs)
-
imcombine/pmReadoutCombine.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPARead.c
r13190 r13768 120 120 } 121 121 122 // Read a component of a readout 122 // Read a component of a readout. We read in only the rows from min to max for plane z, for 123 // the full region requested. if we request a range outside the region, we will pad to fill 124 // out the edges of the region with 'bad' pixels. The output image always has max-min rows. 125 // The region represents the maximum bounds of the full image 126 123 127 psImage *readoutReadComponent(psImage *image, // Image into which to read 124 128 psFits *fits, // FITS file from which to read 125 const psRegion * region, // Region to read129 const psRegion *fullImage, // full image region, read a subset 126 130 int readdir, // Read direction (1=rows, 2=cols) 127 131 int min, // Minimum row/col number to read … … 132 136 { 133 137 assert(fits); 134 assert(region); 135 136 bool resize = false; // Do we need to resize the image once read? 137 psRegion toRead = psRegionSet(region->x0, region->x1, region->y0, region->y1); // Region to read 138 psRegion fullSize = toRead; // Full sized region 138 assert(fullImage); 139 assert((readdir == 1) || (readdir == 2)); 140 141 int nRead = 0; 142 int nScans = max - min; 143 assert (nScans > 0); 144 145 psRegion toRead = *fullImage; // full image region 146 147 int dX = 0; 148 int dY = 0; 149 int nX = 0; 150 int nY = 0; 151 139 152 if (readdir == 1) { 140 if (toRead.y0 <= min) { 141 toRead.y0 = min; 142 } else { 143 fullSize.y0 = min; 144 resize = true; 145 } 146 if (toRead.y1 >= max) { 147 toRead.y1 = max; 148 } else { 149 fullSize.y1 = max; 150 resize = false; 151 } 152 } else if (readdir == 2) { 153 if (toRead.x0 <= min) { 154 toRead.x0 = min; 155 } else { 156 fullSize.x0 = min; 157 resize = true; 158 } 159 if (toRead.x1 >= max) { 160 toRead.x1 = max; 161 } else { 162 fullSize.x1 = max; 163 resize = false; 164 } 153 toRead.y0 = PS_MAX (toRead.y0, min); 154 toRead.y1 = PS_MIN (toRead.y1, max); 155 nRead = toRead.y1 - toRead.y0; 156 if (min < fullImage->y0) { 157 dY = toRead.y0; 158 } 159 nX = toRead.x1 - toRead.x0; 160 nY = nScans; 165 161 } else { 166 psAbort("Read direction can only be 1 (rows) or 2 (cols).\n"); 162 toRead.x0 = PS_MAX (toRead.x0, min); 163 toRead.x1 = PS_MIN (toRead.x1, max); 164 nRead = toRead.x1 - toRead.x0; 165 if (min < fullImage->x0) { 166 dX = toRead.x0; 167 } 168 nX = nScans; 169 nY = toRead.y1 - toRead.y0; 167 170 } 168 171 … … 179 182 } 180 183 181 if (resize) {182 // For some reason, the region of interest is smaller than the number of pixels we want.183 psTrace("psModules.camera", 5, "Resizing image to %.0fx%.0f\n",184 fullSize.x1 - fullSize.x0, fullSize.y1 - fullSize.y0);185 psImage *temp = psImageAlloc( fullSize.x1 - fullSize.x0, fullSize.y1 - fullSize.y0, image->type.type);184 // XXX this modification is not carried back up stream: it affects readout->row0,col0 185 if (nRead < nScans) { 186 // The region of interest is smaller than the number of pixels we want. 187 psTrace("psModules.camera", 5, "Resizing image to %d,%d\n", nX, nY); 188 psImage *temp = psImageAlloc(nX, nY, image->type.type); 186 189 psImageInit(temp, bad); 187 psImageOverlaySection(temp, image, toRead.x0, toRead.y0, "=");190 psImageOverlaySection(temp, image, dX, dY, "="); 188 191 psFree(image); 189 192 image = temp; … … 385 388 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 386 389 387 bool pmReadoutReadNext(pmReadout *readout, psFits *fits, int z, int numScans) 390 // XXX need to pass back the error conditions as well as the 'keep going' state 391 bool pmReadoutReadNext(bool *status, pmReadout *readout, psFits *fits, int z, int numScans) 388 392 { 389 393 PS_ASSERT_PTR_NON_NULL(readout, false); … … 392 396 PS_ASSERT_INT_NONNEGATIVE(numScans, false); 393 397 398 assert (numScans || !readout->image); // cannot have readout->image and !numScans 399 400 *status = false; 401 394 402 // Get the HDU and read the header 395 403 pmCell *cell = readout->parent; // The parent cell … … 397 405 pmHDU *hdu = pmHDUFromCell(cell); // The HDU 398 406 if (!hdu || hdu->blankPHU) { 407 // XXX is this an error condition? 408 *status = true; 399 409 return false; 400 410 } … … 443 453 if (naxis == 0) { 444 454 // No pixels to read, as for a PHU. 455 *status = true; 445 456 return false; 446 457 } … … 460 471 if (z >= naxis3) { 461 472 // Nothing to see here. Move along. 473 *status = true; 462 474 return false; 463 475 } … … 486 498 int maxSize; // Number of cols,rows in image 487 499 if (readdir == 1) { 488 maxSize = PS_MIN(naxis2, trimsec->y1 );500 maxSize = PS_MIN(naxis2, trimsec->y1 - trimsec->y0); 489 501 } else { 490 maxSize = PS_MIN(naxis1, trimsec->x1); 491 } 492 493 // Read the FITS image 494 int offset = 0; // The offset from the start of the image to where we are now 495 if (readout->image) { 496 if (readdir == 1) { 497 // Reading rows 498 if (numScans == 0) { 499 numScans = naxis2 - readout->row0; 500 } 501 readout->row0 += readout->image->numRows; 502 offset = readout->row0; 503 } else { 504 // Reading columns 505 if (numScans == 0) { 506 numScans = naxis1 - readout->col0; 507 } 508 readout->col0 += readout->image->numCols; 509 offset = readout->col0; 510 } 502 maxSize = PS_MIN(naxis1, trimsec->x1 - trimsec->x0); 503 } 504 505 int offset; // start of the segment 506 int upper; // end of the segment 507 int lastScan; // last possible scan 508 509 // Calculate the segment offset and upper limit, adjust readout->row0,col0 510 if (readdir == 1) { 511 // Reading rows 512 offset = (readout->image) ? readout->row0 + numScans : 0; // extend to next section or start at beginning? 513 offset = (numScans == 0) ? trimsec->x0 : offset; // full array ? read full trimsec : read section 514 readout->row0 = offset; 515 readout->col0 = trimsec->x0; 516 lastScan = trimsec->y1; 511 517 } else { 512 if (numScans == 0) { 513 if (readdir == 1) { 514 numScans = naxis2; 515 } else 516 numScans = naxis1; 517 } 518 } 518 // Reading cols 519 offset = (readout->image) ? readout->col0 + numScans : 0; 520 offset = (numScans == 0) ? trimsec->y0 : offset; // full array ? read full trimsec : read section 521 readout->col0 = offset; 522 readout->row0 = trimsec->y0; 523 lastScan = trimsec->x1; 524 } 525 upper = offset + numScans; 519 526 520 527 // Blow away existing data. … … 527 534 } 528 535 529 if (offset >= maxSize) {536 if (offset >= lastScan) { 530 537 // We've read everything there is 531 538 psTrace("psModules.camera", 7, "Read everything.\n"); 532 psFree(readout->image);533 return false; 534 } 535 int upper = PS_MIN(offset + numScans, maxSize); // The upper limit for the pixel read 539 *status = true; 540 return false; 541 } 542 536 543 psTrace("psModules.camera", 7, "offset=%d, upper = %d, image is %dx%d, trimsec [%.0f:%.0f,%.0f:%.0f]\n", 537 544 offset, upper, naxis1, naxis2, trimsec->x0, trimsec->x1, trimsec->y0, trimsec->y1); 538 545 539 546 // Get the new the trim section 540 readout->image = readoutReadComponent(readout->image, fits, trimsec, readdir, 541 offset, upper, z, bad); // The image 547 readout->image = readoutReadComponent(readout->image, fits, trimsec, readdir, offset, upper, z, bad); // The image 542 548 543 549 // Get the new bias sections … … 551 557 psFree(biassecsIter); 552 558 559 *status = true; 553 560 return true; 554 561 } -
trunk/psModules/src/camera/pmFPARead.h
r12696 r13768 4 4 * @author Paul Price, IfA 5 5 * 6 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-0 3-30 21:12:56$6 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-06-12 22:22:33 $ 8 8 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 9 9 */ … … 25 25 /// Use pmReadoutWriteNext to write the data that's read by this function. This function is intended for 26 26 /// reading in many readouts into memory at once (e.g., for stacking) where the input is not written out. 27 bool pmReadoutReadNext(pmReadout *readout, // Readout into which to read 27 bool pmReadoutReadNext(bool *status, // non-error exit condition? 28 pmReadout *readout, // Readout into which to read 28 29 psFits *fits, // FITS file from which to read 29 30 int z, // Readout number/plane; zero-offset indexing -
trunk/psModules/src/imcombine/pmReadoutCombine.c
r13766 r13768 142 142 143 143 // Range of pixels on output image 144 minInput Rows = PS_MAX (xMin, PS_MIN(minInputRows, readout->row0));145 maxInput Rows = PS_MIN (xMax, PS_MAX(maxInputRows, readout->row0 + readout->image->numRows));146 minInput Cols = PS_MAX (yMin, PS_MIN(minInputCols, readout->col0));147 maxInput Cols = PS_MIN (yMax, PS_MAX(maxInputCols, readout->col0 + readout->image->numCols));144 minInputCols = PS_MAX (xMin, PS_MIN(minInputCols, readout->col0)); 145 maxInputCols = PS_MIN (xMax, PS_MAX(maxInputCols, readout->col0 + readout->image->numCols)); 146 minInputRows = PS_MAX (yMin, PS_MIN(minInputRows, readout->row0)); 147 maxInputRows = PS_MIN (yMax, PS_MAX(maxInputRows, readout->row0 + readout->image->numRows)); 148 148 psTrace("psModules.imcombine", 7, "Readout %ld: offset %d,%d; size %dx%d\n", i, 149 149 readout->col0, readout->row0, readout->image->numCols, readout->image->numRows);
Note:
See TracChangeset
for help on using the changeset viewer.
