OPERA  1.0
Open source echelle spectrograph reduction pipeline
operaFITSSubImage.h
Go to the documentation of this file.
00001 /*******************************************************************
00002 ****                            OPERA PIPELINE v1.0                     ****
00003 ********************************************************************
00004 Library name: liboperaFITSSubImage
00005 Class: operaFITSSubImage
00006 Version: 1.0
00007 Author(s): CFHT OPERA team
00008 Affiliation: Canada France Hawaii Telescope 
00009 Location: Hawaii USA
00010 Date: Aug/2011
00011 
00012  Copyright (C) 2011  Opera Pipeline team, Canada France Hawaii Telescope
00013  
00014  This program is free software: you can redistribute it and/or modify
00015  it under the terms of the GNU General Public License as published by
00016  the Free Software Foundation, either version 3 of the License, or
00017  (at your option) any later version.
00018  
00019  This program is distributed in the hope that it will be useful,
00020  but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  GNU General Public License for more details.
00023  
00024  You should have received a copy of the GNU General Public License
00025  along with this program.  If not, see:
00026  http://software.cfht.hawaii.edu/licenses
00027  -or-
00028  http://www.gnu.org/licenses/gpl-3.0.html
00029 ********************************************************************/
00030 
00031 #ifndef operaFITSSubImage_H
00032 #define operaFITSSubImage_H
00033 
00034 #include <fitsio.h>
00035 #include <string>
00036 
00037 #include <libraries/operaEspadonsImage.h>
00038 
00039 extern "C" {
00040 #include "libraries/operaImage.h"
00041 #include "libraries/operaParameterAccess.h"
00042 #include "libraries/operaConfigurationAccess.h"
00043 }
00044 
00045 using namespace std;
00046 
00047 class operaFITSImage;
00048 class operaFITSSubImage;
00049 
00058 unsigned *where(operaFITSSubImage* b, unsigned *count);
00059 unsigned *where(operaFITSSubImage& b, unsigned *count);
00060 unsigned *where(operaFITSSubImage* b);
00061 unsigned *where(operaFITSSubImage& b);
00062 
00063 
00064 /*
00065  * operaFITSSubImage class
00066  * \author Doug Teeple
00067  * \brief This class encapsulates a FITS subimage.
00068  * \ingroup libraries
00069  */
00070 class operaFITSSubImage {
00071 
00072         friend class operaEspadonsSubImage;
00073         friend class operaEspadonsImage;
00074         friend class operaFITSImage;
00075 
00076 protected:
00077         unsigned nx;            // x-dimension from arguments (ncols) 
00078         unsigned ny;            // y-dimension arguments (nrows)
00079         unsigned npixels;       // number of subimage pixels    
00080         unsigned x;                     // start x, not used after the initial copy
00081         unsigned y;                     // start y, not used after the initial copy     
00082         void *pixptr;           // pixel base
00083         bool istemp;            // set if this instance is a temp created in an expression
00084         Matrix matrix;          // matrix view of an image (Matrix is defined in operaFITSImage.h)
00085         
00086 public:
00091         operaFITSSubImage();                                                                                                            // simply construct a default image
00096         operaFITSSubImage(unsigned nx, unsigned ny);                                                            // simply construct a default image
00105         operaFITSSubImage(operaFITSSubImage &from, ImageIndexVector v);
00114         operaFITSSubImage(operaFITSImage &from, ImageIndexVector v);
00122         operaFITSSubImage *operator[](ImageIndexVector v) {return new operaFITSSubImage(*this, v);};
00130         float *operator[](unsigned i) { return (float *)pixptr+(nx*i);};
00138         operaFITSSubImage& operator=(operaFITSSubImage* b) {
00139                 float *p = (float *)pixptr; 
00140                 float *bp = (float *)b->pixptr; 
00141                 unsigned n = npixels; 
00142                 while (n--) *p++ = *bp++;
00143                 if (b->istemp) delete b;
00144                 return *this;
00145         };
00153         operaFITSSubImage& operator=(operaFITSSubImage& b) {
00154                 float *p = (float *)pixptr; 
00155                 float *bp = (float *)b.pixptr; 
00156                 unsigned n = npixels; 
00157                 while (n--) *p++ = *bp++;
00158                 if (b.istemp) delete &b;
00159                 return *this;
00160         };
00168         operaFITSSubImage& operator=(float f) {
00169                 float *p = (float *)pixptr; 
00170                 unsigned n = npixels; 
00171                 while (n--) *p++ = f;
00172                 return *this;
00173         };
00181         operaFITSSubImage& operator+=(operaFITSSubImage* b) {
00182                 float *p = (float *)pixptr; 
00183                 float *bp = (float *)b->pixptr; 
00184                 unsigned n = npixels; 
00185                 while (n--) *p++ += *bp++;
00186                 if (b->istemp) delete b;
00187                 return *this;
00188         };
00196         operaFITSSubImage& operator+=(operaFITSSubImage& b) {
00197                 float *p = (float *)pixptr; 
00198                 float *bp = (float *)b.pixptr; 
00199                 unsigned n = npixels; 
00200                 while (n--) *p++ += *bp++;
00201                 if (b.istemp) delete &b;
00202                 return *this;
00203         };
00211         operaFITSSubImage& operator+=(float f) {
00212                 float *p = (float *)pixptr; 
00213                 unsigned n = npixels; 
00214                 while (n--) *p++ += f;
00215                 return *this;
00216         };
00224         operaFITSSubImage& operator-=(operaFITSSubImage* b) {
00225                 float *p = (float *)pixptr; 
00226                 float *bp = (float *)b->pixptr; 
00227                 unsigned n = npixels; 
00228                 while (n--) *p++ -= *bp++;
00229                 if (b->istemp) delete b;
00230                 return *this;
00231         };
00239         operaFITSSubImage& operator-=(operaFITSSubImage& b) {
00240                 float *p = (float *)pixptr; 
00241                 float *bp = (float *)b.pixptr; 
00242                 unsigned n = npixels; 
00243                 while (n--) *p++ -= *bp++;
00244                 if (b.istemp) delete &b;
00245                 return *this;
00246         };
00254         operaFITSSubImage& operator-=(float f) {
00255                 float *p = (float *)pixptr; 
00256                 unsigned n = npixels; 
00257                 while (n--) *p++ -= f;
00258                 return *this;
00259         };
00267         operaFITSSubImage& operator*=(operaFITSSubImage* b) {
00268                 float *p = (float *)pixptr; 
00269                 float *bp = (float *)b->pixptr; 
00270                 unsigned n = npixels; 
00271                 while (n--) *p++ *= *bp++;
00272                 if (b->istemp) delete b;
00273                 return *this;
00274         };
00282         operaFITSSubImage& operator*=(operaFITSSubImage& b) {
00283                 float *p = (float *)pixptr; 
00284                 float *bp = (float *)b.pixptr; 
00285                 unsigned n = npixels; 
00286                 while (n--) *p++ *= *bp++;
00287                 if (b.istemp) delete &b;
00288                 return *this;
00289         };
00297         operaFITSSubImage& operator*=(float f) {
00298                 float *p = (float *)pixptr; 
00299                 unsigned n = npixels; 
00300                 while (n--) *p++ *= f;
00301                 return *this;
00302         };
00310         operaFITSSubImage& operator/=(operaFITSSubImage* b) {
00311                 float *p = (float *)pixptr; 
00312                 float *bp = (float *)b->pixptr; 
00313                 unsigned n = npixels; 
00314                 while (n--) *p++ /= (*bp!=0.0?*bp++:(bp++,1.0));
00315                 if (b->istemp) delete b;
00316                 return *this;
00317         };
00325         operaFITSSubImage& operator/=(operaFITSSubImage& b) {
00326                 float *p = (float *)pixptr; 
00327                 float *bp = (float *)b.pixptr; 
00328                 unsigned n = npixels; 
00329                 while (n--) *p++ /= (*bp!=0.0?*bp++:(bp++,1.0));
00330                 if (b.istemp) delete &b;
00331                 return *this;
00332         };
00340         operaFITSSubImage& operator/=(float f) {
00341                 float *p = (float *)pixptr; 
00342                 unsigned n = npixels; 
00343                 while (n--) *p++ /= (f!=0.0?f:1.0);
00344                 return *this;
00345         };
00353         operaFITSSubImage* operator*(operaFITSSubImage* b) {
00354                 float *tp;
00355                 operaFITSSubImage *t;
00356                 if (this->istemp) {
00357                         t = this;
00358                         tp = (float *)this->pixptr; 
00359                 } else {
00360                         t = new operaFITSSubImage(this->nx, this->ny);
00361                         t->istemp = true;
00362                         tp = (float *)t->pixptr; 
00363                 }
00364                 float *p = (float *)this->pixptr; 
00365                 float *bp = (float *)b->pixptr; 
00366                 unsigned n = npixels; 
00367                 while (n--) *tp++ = *p++ * *bp++;
00368                 if (b->istemp) delete b;
00369                 return t;
00370         };
00378         operaFITSSubImage* operator*(operaFITSSubImage& b) {
00379                 float *tp;
00380                 operaFITSSubImage *t;
00381                 if (this->istemp) {
00382                         t = this;
00383                         tp = (float *)this->pixptr; 
00384                 } else {
00385                         t = new operaFITSSubImage(this->nx, this->ny);
00386                         t->istemp = true;
00387                         tp = (float *)t->pixptr; 
00388                 }
00389                 float *p = (float *)this->pixptr; 
00390                 float *bp = (float *)b.pixptr; 
00391                 unsigned n = npixels; 
00392                 while (n--) *tp++ = *p++ * *bp++;
00393                 if (b.istemp) delete &b;
00394                 return t;
00395         };
00403         operaFITSSubImage* operator*(float f) {
00404                 operaFITSSubImage *t = new operaFITSSubImage(this->nx, this->ny);
00405                 t->istemp = true;
00406                 float *tp = (float *)t->pixptr; 
00407                 float *p = (float *)this->pixptr; 
00408                 unsigned n = npixels; 
00409                 while (n--) *tp++ = *p++ * f;
00410                 return t;
00411         };
00419         operaFITSSubImage* operator/(operaFITSSubImage* b) {
00420                 float *tp;
00421                 operaFITSSubImage *t;
00422                 if (this->istemp) {
00423                         t = this;
00424                         tp = (float *)this->pixptr; 
00425                 } else {
00426                         t = new operaFITSSubImage(this->nx, this->ny);
00427                         t->istemp = true;
00428                         tp = (float *)t->pixptr; 
00429                 }
00430                 float *p = (float *)this->pixptr; 
00431                 float *bp = (float *)b->pixptr; 
00432                 unsigned n = npixels; 
00433                 while (n--) *tp++ = *p++ / (*bp!=0.0?*bp++:(bp++,1.0));
00434                 if (b->istemp) delete b;
00435                 return t;
00436         };
00444         operaFITSSubImage* operator/(operaFITSSubImage& b) {
00445                 float *tp;
00446                 operaFITSSubImage *t;
00447                 if (this->istemp) {
00448                         t = this;
00449                         tp = (float *)this->pixptr; 
00450                 } else {
00451                         t = new operaFITSSubImage(this->nx, this->ny);
00452                         t->istemp = true;
00453                         tp = (float *)t->pixptr; 
00454                 }
00455                 float *p = (float *)this->pixptr; 
00456                 float *bp = (float *)b.pixptr; 
00457                 unsigned n = npixels; 
00458                 while (n--) *tp++ = *p++ / (*bp!=0.0?*bp++:(bp++,1.0));
00459                 if (b.istemp) delete &b;
00460                 return t;
00461         };
00469         operaFITSSubImage* operator/(float f) {
00470                 operaFITSSubImage *t = new operaFITSSubImage(this->nx, this->ny);
00471                 t->istemp = true;
00472                 float *tp = (float *)t->pixptr; 
00473                 float *p = (float *)this->pixptr; 
00474                 unsigned n = npixels; 
00475                 while (n--) *tp++ = *p++ / (f!=0.0?f:1.0);
00476                 return t;
00477         };
00485         operaFITSSubImage* operator+(operaFITSSubImage* b) {
00486                 float *tp;
00487                 operaFITSSubImage *t;
00488                 if (this->istemp) {
00489                         t = this;
00490                         tp = (float *)this->pixptr; 
00491                 } else {
00492                         t = new operaFITSSubImage(this->nx, this->ny);
00493                         t->istemp = true;
00494                         tp = (float *)t->pixptr; 
00495                 }
00496                 float *p = (float *)this->pixptr; 
00497                 float *bp = (float *)b->pixptr; 
00498                 unsigned n = npixels; 
00499                 while (n--) *tp++ = *p++ + *bp++;
00500                 if (b->istemp) delete b;
00501                 return t;
00502         };
00510         operaFITSSubImage* operator+(operaFITSSubImage& b) {
00511                 float *tp;
00512                 operaFITSSubImage *t;
00513                 if (this->istemp) {
00514                         t = this;
00515                         tp = (float *)this->pixptr; 
00516                 } else {
00517                         t = new operaFITSSubImage(this->nx, this->ny);
00518                         t->istemp = true;
00519                         tp = (float *)t->pixptr; 
00520                 }
00521                 float *p = (float *)this->pixptr; 
00522                 float *bp = (float *)b.pixptr; 
00523                 unsigned n = npixels; 
00524                 while (n--) *tp++ = *p++ + *bp++;
00525                 if (b.istemp) delete &b;
00526                 return t;
00527         };
00535         operaFITSSubImage* operator+(float f) {
00536                 operaFITSSubImage *t = new operaFITSSubImage(this->nx, this->ny);
00537                 t->istemp = true;
00538                 float *tp = (float *)t->pixptr; 
00539                 float *p = (float *)this->pixptr; 
00540                 unsigned n = npixels; 
00541                 while (n--) *tp++ = *p++ + f;
00542                 return t;
00543         };
00551         operaFITSSubImage* operator-(operaFITSSubImage* b) {
00552                 float *tp;
00553                 operaFITSSubImage *t;
00554                 if (this->istemp) {
00555                         t = this;
00556                         tp = (float *)this->pixptr; 
00557                 } else {
00558                         t = new operaFITSSubImage(this->nx, this->ny);
00559                         t->istemp = true;
00560                         tp = (float *)t->pixptr; 
00561                 }
00562                 float *p = (float *)this->pixptr; 
00563                 float *bp = (float *)b->pixptr; 
00564                 unsigned n = npixels; 
00565                 while (n--) *tp++ = *p++ - *bp++;
00566                 if (b->istemp) delete b;
00567                 return t;
00568         };
00576         operaFITSSubImage* operator-(operaFITSSubImage& b) {
00577                 float *tp;
00578                 operaFITSSubImage *t;
00579                 if (this->istemp) {
00580                         t = this;
00581                         tp = (float *)this->pixptr; 
00582                 } else {
00583                         t = new operaFITSSubImage(this->nx, this->ny);
00584                         t->istemp = true;
00585                         tp = (float *)t->pixptr; 
00586                 }
00587                 float *p = (float *)this->pixptr; 
00588                 float *bp = (float *)b.pixptr; 
00589                 unsigned n = npixels; 
00590                 while (n--) *tp++ = *p++ - *bp++;
00591                 if (b.istemp) delete &b;
00592                 return t;
00593         };
00601         operaFITSSubImage* operator-(float f) {
00602                 operaFITSSubImage *t = new operaFITSSubImage(this->nx, this->ny);
00603                 t->istemp = true;
00604                 float *tp = (float *)t->pixptr; 
00605                 float *p = (float *)this->pixptr; 
00606                 unsigned n = npixels; 
00607                 while (n--) *tp++ = *p++ - f;
00608                 return t;
00609         };
00616         operaFITSSubImage* operator!() {
00617                 float *tp;
00618                 operaFITSSubImage *t;
00619                 if (this->istemp) {
00620                         t = this;
00621                         tp = (float *)this->pixptr; 
00622                 } else {
00623                         t = new operaFITSSubImage(this->nx, this->ny);
00624                         t->istemp = true;
00625                         tp = (float *)t->pixptr; 
00626                 }
00627                 float *p = (float *)this->pixptr; 
00628                 unsigned n = npixels; 
00629                 while (n--) *tp++ = (*p++==0.0?1.0:0.0);
00630                 return t;
00631         };
00639         operaFITSSubImage* operator>(operaFITSSubImage* b) {
00640                 float *tp;
00641                 operaFITSSubImage *t;
00642                 if (this->istemp) {
00643                         t = this;
00644                         tp = (float *)this->pixptr; 
00645                 } else {
00646                         t = new operaFITSSubImage(this->nx, this->ny);
00647                         t->istemp = true;
00648                         tp = (float *)t->pixptr; 
00649                 }
00650                 float *p = (float *)this->pixptr; 
00651                 float *bp = (float *)b->pixptr; 
00652                 unsigned n = npixels; 
00653                 while (n--) *tp++ = (*p++>*bp++?1.0:0.0);
00654                 if (b->istemp) delete b;
00655                 return t;
00656         };
00664         operaFITSSubImage* operator>(operaFITSSubImage& b) {
00665                 float *tp;
00666                 operaFITSSubImage *t;
00667                 if (this->istemp) {
00668                         t = this;
00669                         tp = (float *)this->pixptr; 
00670                 } else {
00671                         t = new operaFITSSubImage(this->nx, this->ny);
00672                         t->istemp = true;
00673                         tp = (float *)t->pixptr; 
00674                 }
00675                 float *p = (float *)this->pixptr; 
00676                 float *bp = (float *)b.pixptr; 
00677                 unsigned n = npixels; 
00678                 while (n--) *tp++ = (*p++>*bp++?1.0:0.0);
00679                 if (b.istemp) delete &b;
00680                 return t;
00681         };
00689         operaFITSSubImage* operator>(float f) {
00690                 operaFITSSubImage *t = new operaFITSSubImage(this->nx, this->ny);
00691                 t->istemp = true;
00692                 float *tp = (float *)t->pixptr; 
00693                 float *p = (float *)this->pixptr; 
00694                 unsigned n = npixels; 
00695                 while (n--) *tp++ = (*p++>f?1.0:0.0);
00696                 return t;
00697         };
00705         operaFITSSubImage* operator>=(operaFITSSubImage* b) {
00706                 float *tp;
00707                 operaFITSSubImage *t;
00708                 if (this->istemp) {
00709                         t = this;
00710                         tp = (float *)this->pixptr; 
00711                 } else {
00712                         t = new operaFITSSubImage(this->nx, this->ny);
00713                         t->istemp = true;
00714                         tp = (float *)t->pixptr; 
00715                 }
00716                 float *p = (float *)this->pixptr; 
00717                 float *bp = (float *)b->pixptr; 
00718                 unsigned n = npixels; 
00719                 while (n--) *tp++ = (*p++>=*bp++?1.0:0.0);
00720                 if (b->istemp) delete b;
00721                 return t;
00722         };
00730         operaFITSSubImage* operator>=(operaFITSSubImage& b) {
00731                 float *tp;
00732                 operaFITSSubImage *t;
00733                 if (this->istemp) {
00734                         t = this;
00735                         tp = (float *)this->pixptr; 
00736                 } else {
00737                         t = new operaFITSSubImage(this->nx, this->ny);
00738                         t->istemp = true;
00739                         tp = (float *)t->pixptr; 
00740                 }
00741                 float *p = (float *)this->pixptr; 
00742                 float *bp = (float *)b.pixptr; 
00743                 unsigned n = npixels; 
00744                 while (n--) *tp++ = (*p++>=*bp++?1.0:0.0);
00745                 if (b.istemp) delete &b;
00746                 return t;
00747         };
00755         operaFITSSubImage* operator>=(float f) {
00756                 operaFITSSubImage *t = new operaFITSSubImage(this->nx, this->ny);
00757                 t->istemp = true;
00758                 float *tp = (float *)t->pixptr; 
00759                 float *p = (float *)this->pixptr; 
00760                 unsigned n = npixels; 
00761                 while (n--) *tp++ = (*p++>=f?1.0:0.0);
00762                 return t;
00763         };
00771         operaFITSSubImage* operator<(operaFITSSubImage* b) {
00772                 float *tp;
00773                 operaFITSSubImage *t;
00774                 if (this->istemp) {
00775                         t = this;
00776                         tp = (float *)this->pixptr; 
00777                 } else {
00778                         t = new operaFITSSubImage(this->nx, this->ny);
00779                         t->istemp = true;
00780                         tp = (float *)t->pixptr; 
00781                 }
00782                 float *p = (float *)this->pixptr; 
00783                 float *bp = (float *)b->pixptr; 
00784                 unsigned n = npixels; 
00785                 while (n--) *tp++ = (*p++<*bp++?1.0:0.0);
00786                 if (b->istemp) delete b;
00787                 return t;
00788         };
00796         operaFITSSubImage* operator<(operaFITSSubImage& b) {
00797                 float *tp;
00798                 operaFITSSubImage *t;
00799                 if (this->istemp) {
00800                         t = this;
00801                         tp = (float *)this->pixptr; 
00802                 } else {
00803                         t = new operaFITSSubImage(this->nx, this->ny);
00804                         t->istemp = true;
00805                         tp = (float *)t->pixptr; 
00806                 }
00807                 float *p = (float *)this->pixptr; 
00808                 float *bp = (float *)b.pixptr; 
00809                 unsigned n = npixels; 
00810                 while (n--) *tp++ = (*p++<*bp++?1.0:0.0);
00811                 if (b.istemp) delete &b;
00812                 return t;
00813         };
00821         operaFITSSubImage* operator<(float f) {
00822                 operaFITSSubImage *t = new operaFITSSubImage(this->nx, this->ny);
00823                 t->istemp = true;
00824                 float *tp = (float *)t->pixptr; 
00825                 float *p = (float *)this->pixptr; 
00826                 unsigned n = npixels; 
00827                 while (n--) *tp++ = (*p++<f?1.0:0.0);
00828                 return t;
00829         };
00837         operaFITSSubImage* operator<=(operaFITSSubImage* b) {
00838                 float *tp;
00839                 operaFITSSubImage *t;
00840                 if (this->istemp) {
00841                         t = this;
00842                         tp = (float *)this->pixptr; 
00843                 } else {
00844                         t = new operaFITSSubImage(this->nx, this->ny);
00845                         t->istemp = true;
00846                         tp = (float *)t->pixptr; 
00847                 }
00848                 float *p = (float *)this->pixptr; 
00849                 float *bp = (float *)b->pixptr; 
00850                 unsigned n = npixels; 
00851                 while (n--) *tp++ = (*p<=*bp?(bp++,*p++):(p++,*bp++));
00852                 if (b->istemp) delete b;
00853                 return t;
00854         };
00862         operaFITSSubImage* operator<=(operaFITSSubImage& b) {
00863                 float *tp;
00864                 operaFITSSubImage *t;
00865                 if (this->istemp) {
00866                         t = this;
00867                         tp = (float *)this->pixptr; 
00868                 } else {
00869                         t = new operaFITSSubImage(this->nx, this->ny);
00870                         t->istemp = true;
00871                         tp = (float *)t->pixptr; 
00872                 }
00873                 float *p = (float *)this->pixptr; 
00874                 float *bp = (float *)b.pixptr; 
00875                 unsigned n = npixels; 
00876                 while (n--) *tp++ = (*p<=*bp?(bp++,*p++):(p++,*bp++));
00877                 if (b.istemp) delete &b;
00878                 return t;
00879         };
00887         operaFITSSubImage* operator<=(float f) {
00888                 operaFITSSubImage *t = new operaFITSSubImage(this->nx, this->ny);
00889                 t->istemp = true;
00890                 float *tp = (float *)t->pixptr; 
00891                 float *p = (float *)this->pixptr; 
00892                 unsigned n = npixels; 
00893                 while (n--) *tp++ = (*p++<=f?1.0:0.0);
00894                 return t;
00895         };
00903         operaFITSSubImage* operator&&(operaFITSSubImage* b) {
00904                 float *tp;
00905                 operaFITSSubImage *t;
00906                 if (this->istemp) {
00907                         t = this;
00908                         tp = (float *)this->pixptr; 
00909                 } else {
00910                         t = new operaFITSSubImage(this->nx, this->ny);
00911                         t->istemp = true;
00912                         tp = (float *)t->pixptr; 
00913                 }
00914                 float *p = (float *)this->pixptr; 
00915                 float *bp = (float *)b->pixptr; 
00916                 unsigned n = npixels; 
00917                 while (n--) *tp++ = (*p++!=0.0&&*bp++!=0.0?1.0:0.0);
00918                 if (b->istemp) delete b;
00919                 return t;
00920         };
00928         operaFITSSubImage* operator&&(operaFITSSubImage& b) {
00929                 float *tp;
00930                 operaFITSSubImage *t;
00931                 if (this->istemp) {
00932                         t = this;
00933                         tp = (float *)this->pixptr; 
00934                 } else {
00935                         t = new operaFITSSubImage(this->nx, this->ny);
00936                         t->istemp = true;
00937                         tp = (float *)t->pixptr; 
00938                 }
00939                 float *p = (float *)this->pixptr; 
00940                 float *bp = (float *)b.pixptr; 
00941                 unsigned n = npixels; 
00942                 while (n--) *tp++ = (*p++!=0.0&&*bp++!=0.0?1.0:0.0);
00943                 if (b.istemp) delete &b;
00944                 return t;
00945         };
00953         operaFITSSubImage* operator||(operaFITSSubImage* b) {
00954                 float *tp;
00955                 operaFITSSubImage *t;
00956                 if (this->istemp) {
00957                         t = this;
00958                         tp = (float *)this->pixptr; 
00959                 } else {
00960                         t = new operaFITSSubImage(this->nx, this->ny);
00961                         t->istemp = true;
00962                         tp = (float *)t->pixptr; 
00963                 }
00964                 float *p = (float *)this->pixptr; 
00965                 float *bp = (float *)b->pixptr; 
00966                 unsigned n = npixels; 
00967                 while (n--) *tp++ = (*p++!=0.0||*bp++!=0.0?1.0:0.0);
00968                 if (b->istemp) delete b;
00969                 return t;
00970         };
00978         operaFITSSubImage* operator||(operaFITSSubImage& b) {
00979                 float *tp;
00980                 operaFITSSubImage *t;
00981                 if (this->istemp) {
00982                         t = this;
00983                         tp = (float *)this->pixptr; 
00984                 } else {
00985                         t = new operaFITSSubImage(this->nx, this->ny);
00986                         t->istemp = true;
00987                         tp = (float *)t->pixptr; 
00988                 }
00989                 float *p = (float *)this->pixptr; 
00990                 float *bp = (float *)b.pixptr; 
00991                 unsigned n = npixels; 
00992                 while (n--) *tp++ = (*p++!=0.0||*bp++!=0.0?1.0:0.0);
00993                 if (b.istemp) delete &b;
00994                 return t;
00995         };
00996         
00997         
01007         operaFITSSubImage(string filename, unsigned X, unsigned Y, unsigned NX, unsigned NY);
01017         operaFITSSubImage(operaFITSImage &from, unsigned X, unsigned Y, unsigned NX, unsigned NY);
01023         float* operaFITSSubImageClonePixels();
01030         void operaFITSSubImageSetData(float* data);                                                                     // set pixptr to a data buffer
01031         
01039         inline float getpixel(unsigned x, unsigned y) {return ((float *)pixptr)[(nx*y)+x];};
01040         
01049         inline void setpixel(float value, unsigned x, unsigned y) {((float *)pixptr)[(nx*y)+x] = value;};
01050         
01056         void transpose();
01057         
01058         /* getters and setters */
01059 
01065         void *getpixels();
01071         Matrix getmatrix();
01077         unsigned getnx();
01083         unsigned getny();
01089         unsigned getnpixels();
01095         bool getIstemp() {return istemp;};
01096 };
01097 
01098 #endif