00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031
00032
00033
00034
00035
00036 #include <stdio.h>
00037 #include <stdlib.h>
00038 #include <math.h>
00039
00040 #include "omega_trim.h"
00041 #include "omega_fits.h"
00042 #include "omega_pfits.h"
00043 #include "omega_stats.h"
00044 #include "omega_utils.h"
00045
00087 cpl_image * TrimOscanCorrect(const cpl_frame *frame, int oscan, int extn)
00088 {
00089
00090 int x0 = 1;
00091 int x1 = 1;
00092 int ry0 = 1;
00093 int ry1 = 1;
00094
00095 const char *_id = "TrimOscanCorrect";
00096
00097 cpl_image *image=NULL;
00098 cpl_image *trim_image=NULL;
00099 cpl_image *tmp_img=NULL;
00100 cpl_vector *region=NULL;
00101 cpl_stats *px = NULL;
00102 cpl_stats *py = NULL;
00103 cpl_stats *ox = NULL;
00104 cpl_stats *oy = NULL;
00105
00106 if(frame == NULL) {
00107 cpl_msg_error(_id,"NULL input frame. %s",cpl_error_get_message());
00108 return NULL;
00109 }
00110
00111 image = cpl_image_load(cpl_frame_get_filename(frame), CPL_TYPE_FLOAT, 0, extn);
00112 if(image == NULL) {
00113 cpl_msg_error(_id,"Cannot load input image. %s",cpl_error_get_message());
00114 return NULL;
00115 }
00116
00117 if(oscan == 0){
00118 tmp_img = cpl_image_duplicate(image);
00119 }
00120
00121
00122 if (oscan > 0 && oscan < 5){
00123
00124
00125
00126
00127
00128 DoStatistics(frame, image, extn, &px,&py,&ox,&oy);
00129
00130 switch(oscan){
00131 case 1:
00132 if(px != NULL){
00133 tmp_img = cpl_image_subtract_scalar_create(image,cpl_stats_get_median(px));
00134 }
00135 else{
00136 tmp_img = cpl_image_duplicate(image);
00137 cpl_msg_warning(_id,"The overscan method %d may not suit these data",oscan);
00138 }
00139 break;
00140
00141 case 2:
00142 if(ox != NULL){
00143 tmp_img = cpl_image_subtract_scalar_create(image,cpl_stats_get_median(ox));
00144 }
00145 else{
00146 tmp_img = cpl_image_duplicate(image);
00147 cpl_msg_warning(_id,"The overscan method %d may not suit these data",oscan);
00148 }
00149 break;
00150
00151 case 3:
00152 if(py != NULL){
00153 tmp_img = cpl_image_subtract_scalar_create(image,cpl_stats_get_median(py));
00154 }
00155 else{
00156 tmp_img = cpl_image_duplicate(image);
00157 cpl_msg_warning(_id,"The overscan method %d may not suit these data",oscan);
00158 }
00159 break;
00160
00161 case 4:
00162 if(oy != NULL){
00163 tmp_img = cpl_image_subtract_scalar_create(image,cpl_stats_get_median(oy));
00164 }
00165 else{
00166 tmp_img = cpl_image_duplicate(image);
00167 cpl_msg_warning(_id,"The overscan method %d may not suit these data",oscan);
00168 }
00169 break;
00170 }
00171
00172 }
00173 else {
00174 cpl_propertylist *plist = cpl_propertylist_load(cpl_frame_get_filename(frame), extn);
00175 if(oscan == 5){
00176 region = omega_get_scan_coord(plist, 0);
00177 tmp_img = oscan_row(image, (int)cpl_vector_get(region,0),(int)cpl_vector_get(region,2));
00178 freevector(region);
00179 }
00180 if(oscan == 6){
00181 region = omega_get_scan_coord(plist, 2);
00182 tmp_img = oscan_row(image, (int)cpl_vector_get(region,0),(int)cpl_vector_get(region,2));
00183 freevector(region);
00184 }
00185 freeplist(plist);
00186 }
00187
00188 region = get_trim_region(frame, extn);
00189 x0 = (int)cpl_vector_get(region,0);
00190 ry0 = (int)cpl_vector_get(region,1);
00191 x1 = (int)cpl_vector_get(region,2);
00192 ry1 = (int)cpl_vector_get(region,3);
00193
00194 trim_image = cpl_image_extract(tmp_img, x0, ry0, x1, ry1);
00195 if (trim_image == NULL) {
00196 cpl_msg_error (_id,"Cannot extract trimmed image <%s>", cpl_error_get_message());
00197 freeimage(image);
00198 freeimage(tmp_img);
00199 freevector(region);
00200 freestats(px);
00201 freestats(py);
00202 freestats(ox);
00203 freestats(oy);
00204 return NULL;
00205 }
00206
00207 freeimage(image);
00208 freeimage(tmp_img);
00209 freevector(region);
00210 freestats(px);
00211 freestats(py);
00212 freestats(ox);
00213 freestats(oy);
00214
00215 return trim_image;
00216 }
00217
00248 cpl_image *omega_trim_oscan_correct(omega_fits *ofits, int oscan)
00249 {
00250
00251 int x0 = 1;
00252 int x1 = 1;
00253 int ry0 = 1;
00254 int ry1 = 1;
00255
00256 cpl_image *trim_image;
00257 cpl_image *tmp_img;
00258 cpl_vector *region;
00259 cpl_propertylist *xlist;
00260 cpl_stats *px = NULL;
00261 cpl_stats *py = NULL;
00262 cpl_stats *ox = NULL;
00263 cpl_stats *oy = NULL;
00264
00265 if(ofits == NULL) {
00266 cpl_msg_error(cpl_func,"NULL input file. %s",cpl_error_get_message());
00267 return NULL;
00268 }
00269
00270 if(oscan == 0){
00271 tmp_img = cpl_image_duplicate(omega_fits_get_image(ofits));
00272 }
00273
00274
00275 if (oscan > 0 && oscan < 5){
00276
00277 omega_scan_stats(ofits,&px ,&py, &ox, &oy);
00278
00279 switch(oscan){
00280 case 1:
00281 if(px != NULL){
00282 tmp_img = cpl_image_subtract_scalar_create(omega_fits_get_image(ofits),cpl_stats_get_median(px));
00283 }
00284 else{
00285 tmp_img = cpl_image_duplicate(omega_fits_get_image(ofits));
00286 cpl_msg_warning(cpl_func,"The overscan method %d may not suit these data",oscan);
00287 }
00288 break;
00289
00290 case 2:
00291 if(ox != NULL){
00292 tmp_img = cpl_image_subtract_scalar_create(omega_fits_get_image(ofits),cpl_stats_get_median(ox));
00293 }
00294 else{
00295 tmp_img = cpl_image_duplicate(omega_fits_get_image(ofits));
00296 cpl_msg_warning(cpl_func,"The overscan method %d may not suit these data",oscan);
00297 }
00298 break;
00299
00300 case 3:
00301 if(py != NULL){
00302 tmp_img = cpl_image_subtract_scalar_create(omega_fits_get_image(ofits),cpl_stats_get_median(py));
00303 }
00304 else{
00305 tmp_img = cpl_image_duplicate(omega_fits_get_image(ofits));
00306 cpl_msg_warning(cpl_func,"The overscan method %d may not suit these data",oscan);
00307 }
00308 break;
00309
00310 case 4:
00311 if(oy != NULL){
00312 tmp_img = cpl_image_subtract_scalar_create(omega_fits_get_image(ofits),cpl_stats_get_median(oy));
00313 }
00314 else{
00315 tmp_img = cpl_image_duplicate(omega_fits_get_image(ofits));
00316 cpl_msg_warning(cpl_func,"The overscan method %d may not suit these data",oscan);
00317 }
00318 break;
00319 }
00320
00321 }
00322 else {
00323 xlist = omega_fits_get_ehu(ofits);
00324 if(oscan == 5){
00325 region = omega_get_scan_coord(xlist, 0);
00326 tmp_img = oscan_row(omega_fits_get_image(ofits), (int)cpl_vector_get(region,0),
00327 (int)cpl_vector_get(region,2));
00328 }
00329 if(oscan == 6){
00330 region = omega_get_scan_coord(xlist, 2);
00331 tmp_img = oscan_row(omega_fits_get_image(ofits), (int)cpl_vector_get(region,0),
00332 (int)cpl_vector_get(region,2));
00333 }
00334 xlist = NULL;
00335 }
00336
00337 region = omega_get_trim_region(ofits);
00338 x0 = (int)cpl_vector_get(region,0);
00339 ry0 = (int)cpl_vector_get(region,1);
00340 x1 = (int)cpl_vector_get(region,2);
00341 ry1 = (int)cpl_vector_get(region,3);
00342
00343 trim_image = cpl_image_extract(tmp_img, x0, ry0, x1, ry1);
00344 if (trim_image == NULL) {
00345 cpl_msg_error (cpl_func,"Cannot extract trimmed image <%s>", cpl_error_get_message());
00346 freeimage(tmp_img);
00347 freevector(region);
00348 freestats(px);
00349 freestats(py);
00350 freestats(ox);
00351 freestats(oy);
00352 return NULL;
00353 }
00354
00355 freeimage(tmp_img);
00356 freevector(region);
00357 freestats(px);
00358 freestats(py);
00359 freestats(ox);
00360 freestats(oy);
00361
00362 return trim_image;
00363 }
00364
00365
00366
00375
00376 cpl_image *oscan_row (cpl_image *img, int x1, int x2)
00377 {
00378
00379 int i = 0;
00380 int j = 0;
00381 int lx = 256;
00382 int ly = 256;
00383 int offset = 0;
00384 int oscanoffset = 0;
00385 int oscansize = 0;
00386 float med = 0.0f;
00387
00388 float * pindata;
00389 float * poutdata;
00390
00391 cpl_image *image_out;
00392
00393
00394 lx = cpl_image_get_size_x (img);
00395 ly = cpl_image_get_size_y (img);
00396
00397 image_out = cpl_image_new (lx, ly, CPL_TYPE_FLOAT);
00398
00399 oscansize = x2-x1+1;
00400
00401
00402 pindata = (float *)cpl_image_get_data (img);
00403 poutdata = (float *)cpl_image_get_data (image_out);
00404
00405 for (i=0; i<ly; i++)
00406 {
00407 offset = i * lx;
00408 oscanoffset = offset+x1-1;
00409 med = 0.0;
00410
00411 for (j=0; j<oscansize; j++)
00412 {
00413 med += pindata[oscanoffset+j];
00414 }
00415
00416
00417 med /= oscansize;
00418
00419 for (j=0; j<lx; j++){
00420 poutdata[offset+j] = pindata[offset+j]-med;
00421 }
00422 }
00423
00424
00425
00426 return image_out;
00427 }
00428
00429
00443 cpl_vector * get_trim_region(const cpl_frame *frame, int extnum)
00444 {
00445
00446 int orient = 0;
00447 int naxis1 = 0;
00448 int naxis2 = 0;
00449 int ovscx = 0;
00450 int ovscy = 0;
00451 int prscx = 0;
00452 int prscy = 0;
00453 int x0 = 1;
00454 int x1 = 1;
00455 int ry0 = 1;
00456 int ry1 = 1;
00457
00458 const char *filename = NULL;
00459
00460 cpl_propertylist *xplist;
00461 cpl_vector *region;
00462 cpl_vector *sregion;
00463
00464
00465 if(frame == NULL){
00466 cpl_msg_error(cpl_func,"Input frame is NULL");
00467 return NULL;
00468 }
00469
00470 filename = cpl_frame_get_filename(frame);
00471
00472
00473 xplist = cpl_propertylist_load(filename, extnum);
00474 if(xplist == NULL) {
00475 cpl_msg_error(cpl_func,"Cannot load header");
00476 return NULL;
00477 }
00478
00479 naxis1 = cpl_propertylist_get_int(xplist, "NAXIS1");
00480 naxis2 = cpl_propertylist_get_int(xplist, "NAXIS2");
00481 if (naxis1 == 0 || naxis2 == 0){
00482 cpl_msg_error(cpl_func,"NAXIS1 or NAXIS2 is 0");
00483 freeplist(xplist);
00484 return NULL;
00485 }
00486
00487
00488 sregion = omega_pfits_get_preovscan(xplist);
00489 if(sregion == NULL){
00490 cpl_msg_warning(cpl_func,"Cannot get pre and overscan regions");
00491 freeplist(xplist);
00492 return NULL;
00493 }
00494
00495 prscx = cpl_vector_get(sregion,0);
00496 prscy = cpl_vector_get(sregion,1);
00497 ovscx = cpl_vector_get(sregion,2);
00498 ovscy = cpl_vector_get(sregion,3);
00499
00500 freeplist(xplist);
00501
00502
00503
00504 orient = omega_get_chip_orientation(extnum);
00505
00506 switch(orient){
00507 case 1:
00508 x0 = prscx + 1;
00509 ry0 = prscy + 1;
00510 x1 = naxis1 - ovscx;
00511 ry1 = naxis2 - ovscy;
00512 break;
00513 case 2:
00514 x0 = ovscx + 1;
00515 ry0 = ovscy + 1;
00516 x1 = naxis1 - prscx;
00517 ry1 = naxis2 - prscy;
00518 break;
00519 default:
00520 x0 = prscx + 1;
00521 ry0 = prscy + 1;
00522 x1 = naxis1 - ovscx;
00523 ry1 = naxis2 - ovscy;
00524 cpl_msg_warning(cpl_func,"Using default chip layout");
00525 break;
00526 }
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567 region = cpl_vector_new(4);
00568 cpl_vector_set(region, 0, x0);
00569 cpl_vector_set(region, 1, ry0);
00570 cpl_vector_set(region, 2, x1);
00571 cpl_vector_set(region, 3, ry1);
00572
00573 freevector(sregion);
00574
00575 return region;
00576
00577 }
00578
00593 cpl_vector * omega_get_trim_region(omega_fits *ofits)
00594 {
00595
00596 int orient = 0;
00597 int naxis1 = 0;
00598 int naxis2 = 0;
00599 int ovscx = 0;
00600 int ovscy = 0;
00601 int prscx = 0;
00602 int prscy = 0;
00603 int x0 = 1;
00604 int x1 = 1;
00605 int ry0 = 1;
00606 int ry1 = 1;
00607
00608 cpl_vector *region;
00609 cpl_vector *sregion;
00610 cpl_propertylist *xlist;
00611
00612
00613 if(ofits == NULL){
00614 cpl_msg_error(cpl_func,"Input frame is NULL");
00615 return NULL;
00616 }
00617
00618 xlist = omega_fits_get_ehu(ofits);
00619 naxis1 = cpl_propertylist_get_int(xlist, "NAXIS1");
00620 naxis2 = cpl_propertylist_get_int(xlist, "NAXIS2");
00621 if (naxis1 == 0 || naxis2 == 0){
00622 cpl_msg_error(cpl_func,"NAXIS1 or NAXIS2 is 0");
00623 xlist = NULL;
00624 return NULL;
00625 }
00626
00627
00628 sregion = omega_pfits_get_preovscan(xlist);
00629 if(sregion == NULL){
00630 cpl_msg_warning(cpl_func,"Cannot get pre and overscan regions");
00631 return NULL;
00632 }
00633
00634 prscx = cpl_vector_get(sregion,0);
00635 prscy = cpl_vector_get(sregion,1);
00636 ovscx = cpl_vector_get(sregion,2);
00637 ovscy = cpl_vector_get(sregion,3);
00638
00639
00640
00641 orient = omega_get_chip_orientation(omega_fits_get_extnum(ofits));
00642 switch(orient){
00643 case 1:
00644 x0 = prscx + 1;
00645 ry0 = prscy + 1;
00646 x1 = naxis1 - ovscx;
00647 ry1 = naxis2 - ovscy;
00648 break;
00649 case 2:
00650 x0 = ovscx + 1;
00651 ry0 = ovscy + 1;
00652 x1 = naxis1 - prscx;
00653 ry1 = naxis2 - prscy;
00654 break;
00655 default:
00656 x0 = prscx + 1;
00657 ry0 = prscy + 1;
00658 x1 = naxis1 - ovscx;
00659 ry1 = naxis2 - ovscy;
00660 cpl_msg_warning(cpl_func,"Using default chip layout");
00661 break;
00662 }
00663
00664 region = cpl_vector_new(4);
00665 cpl_vector_set(region, 0, x0);
00666 cpl_vector_set(region, 1, ry0);
00667 cpl_vector_set(region, 2, x1);
00668 cpl_vector_set(region, 3, ry1);
00669
00670 freevector(sregion);
00671 xlist = NULL;
00672
00673 return region;
00674
00675 }
00676
00692 void DoStatistics (const cpl_frame *frame, cpl_image *image, int extnum,
00693 cpl_stats **px,cpl_stats **py,cpl_stats **ox,cpl_stats **oy)
00694 {
00695 int x0 = 0;
00696 int ry0 = 0;
00697 int x1 = 0;
00698 int ry1 = 0;
00699 int iscan = 0;
00700 double threshold = 1.0;
00701 int iter = 5;
00702 cpl_vector *region;
00703 cpl_propertylist *plist;
00704
00705
00706 if((plist = cpl_propertylist_load(cpl_frame_get_filename(frame), extnum)) == NULL)
00707 return;
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720 iscan = 0;
00721 region = omega_get_scan_coord(plist, iscan);
00722 x0 = (int)cpl_vector_get(region,0);
00723 ry0 = (int)cpl_vector_get(region,1);
00724 x1 = (int)cpl_vector_get(region,2);
00725 ry1 = (int)cpl_vector_get(region,3);
00726
00727
00728
00729
00730
00731
00732
00733 if (x1 - x0 +1 > 0){
00734 *px = omega_iter_stat_opts(image,region, threshold, iter);
00735 }
00736 freevector(region);
00737
00738 iscan = 1;
00739 region = omega_get_scan_coord(plist, iscan);
00740 x0 = (int)cpl_vector_get(region,0);
00741 ry0 = (int)cpl_vector_get(region,1);
00742 x1 = (int)cpl_vector_get(region,2);
00743 ry1 = (int)cpl_vector_get(region,3);
00744
00745
00746
00747
00748
00749
00750
00751 if (ry1 - ry0 +1 > 0){
00752 *py = omega_iter_stat_opts(image,region,threshold, iter);
00753 }
00754 freevector(region);
00755
00756 iscan = 2;
00757 region = omega_get_scan_coord(plist, iscan);
00758 x0 = (int)cpl_vector_get(region,0);
00759 ry0 = (int)cpl_vector_get(region,1);
00760 x1 = (int)cpl_vector_get(region,2);
00761 ry1 = (int)cpl_vector_get(region,3);
00762
00763
00764
00765
00766
00767
00768
00769 if (x1 - x0 +1 > 0){
00770 *ox = omega_iter_stat_opts(image,region,threshold, iter);
00771 }
00772 freevector(region);
00773
00774 iscan = 3;
00775 region = omega_get_scan_coord(plist, iscan);
00776 x0 = (int)cpl_vector_get(region,0);
00777 ry0 = (int)cpl_vector_get(region,1);
00778 x1 = (int)cpl_vector_get(region,2);
00779 ry1 = (int)cpl_vector_get(region,3);
00780
00781
00782
00783
00784
00785
00786
00787 if (ry1 - ry0 +1 > 0){
00788 *oy = omega_iter_stat_opts(image,region,threshold, iter);
00789 }
00790
00791 freevector(region);
00792 freeplist(plist);
00793
00794 return;
00795
00796 }
00797
00811 void omega_scan_stats (omega_fits *ofits,cpl_stats **px,cpl_stats **py,
00812 cpl_stats **ox,cpl_stats **oy)
00813 {
00814 int x0 = 0;
00815 int ry0 = 0;
00816 int x1 = 0;
00817 int ry1 = 0;
00818 int iscan = 0;
00819 double threshold = 1.0;
00820 int iter = 5;
00821 cpl_vector *region;
00822 cpl_propertylist *xlist;
00823
00824 if(ofits == NULL)
00825 return;
00826
00827 xlist = omega_fits_get_ehu(ofits);
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840 iscan = 0;
00841 region = omega_get_scan_coord(xlist, iscan);
00842 x0 = (int)cpl_vector_get(region,0);
00843 ry0 = (int)cpl_vector_get(region,1);
00844 x1 = (int)cpl_vector_get(region,2);
00845 ry1 = (int)cpl_vector_get(region,3);
00846
00847
00848 if (x1 - x0 +1 > 0){
00849 *px = omega_iter_stat_opts(omega_fits_get_image(ofits),region, threshold, iter);
00850 }
00851 freevector(region);
00852
00853 iscan = 1;
00854 region = omega_get_scan_coord(xlist, iscan);
00855 x0 = (int)cpl_vector_get(region,0);
00856 ry0 = (int)cpl_vector_get(region,1);
00857 x1 = (int)cpl_vector_get(region,2);
00858 ry1 = (int)cpl_vector_get(region,3);
00859
00860 if (ry1 - ry0 +1 > 0){
00861 *py = omega_iter_stat_opts(omega_fits_get_image(ofits),region,threshold, iter);
00862 }
00863 freevector(region);
00864
00865 iscan = 2;
00866 region = omega_get_scan_coord(xlist, iscan);
00867 x0 = (int)cpl_vector_get(region,0);
00868 ry0 = (int)cpl_vector_get(region,1);
00869 x1 = (int)cpl_vector_get(region,2);
00870 ry1 = (int)cpl_vector_get(region,3);
00871
00872 if (x1 - x0 +1 > 0){
00873 *ox = omega_iter_stat_opts(omega_fits_get_image(ofits),region,threshold, iter);
00874 }
00875 freevector(region);
00876
00877 iscan = 3;
00878 region = omega_get_scan_coord(xlist, iscan);
00879 x0 = (int)cpl_vector_get(region,0);
00880 ry0 = (int)cpl_vector_get(region,1);
00881 x1 = (int)cpl_vector_get(region,2);
00882 ry1 = (int)cpl_vector_get(region,3);
00883
00884 if (ry1 - ry0 +1 > 0){
00885 *oy = omega_iter_stat_opts(omega_fits_get_image(ofits),region,threshold, iter);
00886 }
00887
00888 freevector(region);
00889 xlist = NULL;
00890
00891 return;
00892
00893 }
00894
00919 cpl_vector * omega_get_scan_coord(const cpl_propertylist *plist, int iscan)
00920 {
00921
00922 int naxis1 = 0;
00923 int naxis2 = 0;
00924 int ovscx = 0;
00925 int ovscy = 0;
00926 int prscx = 0;
00927 int prscy = 0;
00928 int x0 = 0;
00929 int x1 = 0;
00930 int ry0 = 0;
00931 int ry1 = 0;
00932 const char * chipid;
00933 int chipornt=0;
00934
00935 cpl_vector *region;
00936 cpl_vector *sregion;
00937
00938
00939 if(plist == NULL)
00940 return NULL;
00941
00942 naxis1 = cpl_propertylist_get_int(plist, "NAXIS1");
00943 naxis2 = cpl_propertylist_get_int(plist, "NAXIS2");
00944 if (naxis1 == 0 || naxis2 == 0){
00945 cpl_msg_error(cpl_func,"NAXIS1 or NAXIS2 is 0");
00946 return NULL;
00947 }
00948
00949 chipid = omega_pfits_get_chipid(plist);
00950 chipornt = omega_pfits_get_orientation(chipid);
00951
00952 if(chipornt == 0) chipornt = 1;
00953
00954
00955 sregion = omega_pfits_get_preovscan(plist);
00956
00957 prscx = (int)cpl_vector_get(sregion,0);
00958 prscy = (int)cpl_vector_get(sregion,1);
00959 ovscx = (int)cpl_vector_get(sregion,2);
00960 ovscy = (int)cpl_vector_get(sregion,3);
00961
00962
00963
00964 if(chipornt==1)
00965 {
00966 switch(iscan){
00967 case 0:
00968
00969 x0 = 1;
00970 ry0 = prscy+1;
00971 x1 = prscx;
00972 ry1 = naxis2 - ovscy;
00973 cpl_msg_debug(cpl_func,"px: x0:%5d ry0:%5d x1:%5d ry1:%5d", x0,ry0,x1,ry1 );
00974 break;
00975 case 1:
00976
00977 x0 = prscx+1;
00978 ry0 = 1;
00979 x1 = naxis1-ovscx;
00980 ry1 = prscy;
00981 cpl_msg_debug(cpl_func,"py: x0:%5d ry0:%5d x1:%5d ry1:%5d", x0,ry0,x1,ry1 );
00982 break;
00983 case 2:
00984
00985 x0 = naxis1-ovscx+1;
00986 ry0 = prscy+1;
00987 x1 = naxis1;
00988 ry1 = naxis2 - ovscy;
00989 cpl_msg_debug(cpl_func,"ox: x0:%5d ry0:%5d x1:%5d ry1:%5d", x0,ry0,x1,ry1 );
00990 break;
00991 case 3:
00992
00993 x0 = prscx+1;
00994 ry0 = naxis2-ovscy+1;
00995 x1 = naxis1-ovscx;
00996 ry1 = naxis2;
00997 cpl_msg_debug(cpl_func,"oy: x0:%5d ry0:%5d x1:%5d ry1:%5d", x0,ry0,x1,ry1 );
00998 break;
00999 default:
01000 cpl_msg_error(cpl_func,"Unable to get pre/overscan coordinates");
01001 freevector(sregion);
01002 return NULL;
01003
01004 }
01005 }
01006 if(chipornt==2)
01007 {
01008 switch(iscan){
01009 case 0:
01010
01011 x0 = naxis1 - prscx + 1;
01012 ry0 = ovscy+1;
01013 x1 = naxis1;
01014 ry1 = naxis2-prscy;
01015 cpl_msg_debug(cpl_func,"px: x0:%5d ry0:%5d x1:%5d ry1:%5d", x0,ry0,x1,ry1 );
01016 break;
01017 case 1:
01018
01019 x0 = ovscx+1;
01020 ry0 = naxis2-prscy;
01021 x1 = naxis1-prscx;
01022 ry1 = naxis2;
01023 cpl_msg_debug(cpl_func,"py: x0:%5d ry0:%5d x1:%5d ry1:%5d", x0,ry0,x1,ry1 );
01024 break;
01025 case 2:
01026
01027 x0 = 1;
01028 ry0 = ovscy+1;
01029 x1 = ovscx;
01030 ry1 = naxis2 - prscy;
01031 cpl_msg_debug(cpl_func,"ox: x0:%5d ry0:%5d x1:%5d ry1:%5d", x0,ry0,x1,ry1 );
01032 break;
01033 case 3:
01034
01035 x0 = ovscx+1;
01036 ry0 = 1;
01037 x1 = naxis1-prscx;
01038 ry1 = ovscy;
01039 cpl_msg_debug(cpl_func,"oy: x0:%5d ry0:%5d x1:%5d ry1:%5d", x0,ry0,x1,ry1 );
01040 break;
01041 default:
01042 cpl_msg_error(cpl_func,"Unable to get pre/overscan coordinates");
01043 freevector(sregion);
01044 return NULL;
01045
01046 }
01047 }
01048
01049 region = cpl_vector_new(4);
01050 cpl_vector_set(region, 0, x0);
01051 cpl_vector_set(region, 1, ry0);
01052 cpl_vector_set(region, 2, x1);
01053 cpl_vector_set(region, 3, ry1);
01054
01055
01056 freevector(sregion);
01057
01058 return region;
01059
01060 }
01061