GLAMERDOC++
Gravitational Lensing Code Library
pixelmap.h
1 //
2 // pixelmap.h
3 // GLAMER
4 //
5 // Created by Robert Benton Metcalf on 26/04/24.
6 //
7 
8 #ifndef pixelmap_h
9 #define pixelmap_h
10 
11 #include <vector>
12 #include <tuple>
13 #include <type_traits>
14 
15 #include "utilities_slsim.h"
16 #include "point.h"
17 #include "cpfits.h"
18 
19 struct Grid;
20 struct GridMap;
21 class Source;
22 
23 
25 enum class PixelMapUnits {
26  ndef // not defined
27  ,surfb // ergs / s / cm**2
28  ,count_per_sec
29  ,ADU // Analogue-to-Digital Units
30  ,mass
31  ,mass_density
32 };
33 
34 std::string to_string(PixelMapUnits unit);
35 
40 template <typename T=double>
41 class PixelMap
42 {
43 
44  static_assert( std::is_same<T, float>::value || std::is_same<T, double>::value
45  , "PixeMap can only be instantated with a double or float template argument");
46 
47 public:
48  PixelMap(const PixelMap<T>& pmap, double res_ratio);
49  PixelMap();
50  PixelMap(const PixelMap<T>& other);
51  PixelMap(PixelMap<T>&& other);
52  PixelMap(const PixelMap<T>& pmap, const double* center, std::size_t Npixels);
53  PixelMap(const PixelMap<T>& pmap,long nx,long ny, std::size_t Npixels);
54  PixelMap(const double* center, std::size_t Npixels
55  ,double resolution
56  ,PixelMapUnits u = PixelMapUnits::ndef);
57  PixelMap(const double* center, std::size_t Nx, std::size_t Ny
58  ,double resolution
59  ,PixelMapUnits u = PixelMapUnits::ndef);
60 
61  PixelMap(std::string fitsfilename
62  ,double my_res=-1
63  ,PixelMapUnits u = PixelMapUnits::ndef
64  ,std::string extension = ""
65  );
66 
67  // for conversion from double to float
68  template<typename OtherT>
69  PixelMap(const PixelMap<OtherT>&);
70 
71  ~PixelMap(){
72  map.resize(0);
73  };
74 
75 
76  PixelMap<T>& operator=(const PixelMap<T> &other);
77  PixelMap<T>& operator=(PixelMap<T> &&other);
78 
79  void ChangeUnits(PixelMapUnits u){units=u;}
80  PixelMapUnits getUnits() const {return units;}
81 
82  inline bool valid() const { return map.size(); };
83  inline std::size_t size() const { return map.size(); };
84 
85  inline std::size_t getNx() const { return Nx; }
86  inline std::size_t getNy() const { return Ny; }
87  inline double getRangeX() const { return rangeX; }
88  inline double getRangeY() const { return rangeY; }
89  //inline double* getCenter() const{ return &center[0]; }
90  void const getCenter(Point_2d &c) const{ c[0]=center[0]; c[1]=center[1];}
91  Point_2d getCenter() const{
92  Point_2d c(center[0],center[1]);
93  return c;
94  }
95  inline double getResolution() const { return resolution; }
96 
97  // coordinates of lower left corner
98  inline Point_2d getLLBoundary() const{ return Point_2d(map_boundary_p1[0],map_boundary_p1[1]); }
99  inline Point_2d getURBoundary() const{ return Point_2d(map_boundary_p2[0],map_boundary_p2[1]); }
100 
102  double getRA(){return RA;}
104  double getDEC(){return DEC;}
105 
107  void setRAandDec(double RAin,double DECin){
108  RA = RAin;
109  DEC = DECin;
110  }
111 
112  // Zero the whole map
113  void Clean(){for(auto &a : map) a = 0;}
114  void clear(){Clean();}
115 
116  void AddImages(ImageInfo *imageinfo,int Nimages,float rescale = 1.);
117  void AddImages(std::vector<ImageInfo> &imageinfo,int Nimages,float rescale = 1.);
119  void AddGridBrightness(Grid &grid);
121  void AddGridMapBrightness(const GridMap &grid);
122  void AddUniformImages(ImageInfo *imageinfo,int Nimages,T value);
123  PosType AddSource(Source &source);
125  PosType AddSource(Source &source,int oversample);
126  void AddPointSource(const Point_2d &x,T flux);
127 
134  void copy_in(const PixelMap& pmap);
135 
144  void paste(const PixelMap& pmap);
145 
147  void paste(const PixelMap& pmap,long nx,long ny);
148 
156  PixelMap<T> convolve(const PixelMap<T> &kernel);
157  PixelMap<T> convolve2(const PixelMap<T> &kernel);
158 
159 
165  PixelMap<T> cutout(long xmin,long xmax,long ymin,long ymax);
166 
171  void duplicate(const PixelMap& pmap);
172 
174  template <typename S>
175  PosType AddSource_parallel(S &source,int oversample){
176  Point_2d s_center;
177  source.getTheta(s_center);
178 
179  if( (s_center[0] + source.getRadius() ) < map_boundary_p1[0] ) return 0.0;
180  if( (s_center[0] - source.getRadius() ) > map_boundary_p2[0] ) return 0.0;
181  if( (s_center[1] + source.getRadius() ) < map_boundary_p1[1] ) return 0.0;
182  if( (s_center[1] - source.getRadius() ) > map_boundary_p2[1] ) return 0.0;
183 
184  int nthreads = Utilities::GetNThreads();
185  PosType totals[nthreads];
186  std::vector<std::thread> thr;
187 
188  size_t block = map.size()/nthreads;
189  for(int i = 0; i < nthreads ;++i){
190  thr.push_back(std::thread(&PixelMap<T>::addsource_<S>,this
191  ,i*block,std::min((i+1)*block-1,map.size()-1)
192  ,oversample,std::ref(source)
193  ,std::ref(totals[i])));
194  }
195 
196  for(int ii=0;ii < nthreads;++ii) thr[ii].join();
197 
198  PosType total =0;
199  for(int ii=0;ii < nthreads;++ii) total += totals[ii];
200 
201  return total;
202  }
203 
204  void AddCurve(ImageInfo *curve,T value);
205  void AddCurve(Kist<Point> *imagekist,T value);
206  void AddCurve(std::vector<Point_2d> &curve,T value);
207  void AddCurve(std::vector<RAY> &curve,T value);
208 
210  void drawline(double x1[],double x2[],T value,bool add);
212  void DrawLine(long x0,long x1,long y0,long y1,T value,bool add);
213  void DrawLineGS(long x0,long x1,long y0,long y1,T value,bool add);
214  void drawcircle(PosType r_center[],PosType radius,PosType value);
215  void drawdisk(PosType r_center[],PosType radius,PosType value,int Nstrip);
216  void AddGrid(const Grid &grid,T value = 1.0);
217  void AddGrid(const Grid &grid,LensingVariable val);
218 
219  void Renormalize(T factor);
220  void AddValue(std::size_t i, T value);
221  void AssignValue(std::size_t i, T value);
222  void printASCII() const;
223  void printASCIItoFile(std::string filename) const;
224  void printFITS(std::string filename,bool Xflip = false, bool ctype = false, bool verbose = false);
225  void printFITS(std::string filename,std::vector< std::tuple<std::string,double,std::string> > &extra_header_info, bool verbose);
226 
228  void printFITS(std::string filename
229  ,std::vector<std::string> &headercards
230  );
231 
232  void smooth(double sigma);
233 
234  inline T getValue(std::size_t i) const { return map[i]; }
235  inline T & operator[](std::size_t i) { return map[i]; };
236  const T &operator[](std::size_t i) const { return map[i]; };
237  inline T & operator()(std::size_t i) { return map[i]; };
238  inline T operator()(std::size_t i) const { return map[i]; };
239  inline T operator()(std::size_t i,std::size_t j) const { return map[i + Nx*j]; };
240  inline T & operator()(std::size_t i,std::size_t j) { return map[i + Nx*j]; };
241 
242  PixelMap& operator+=(const PixelMap& rhs);
243  void operator+=(float f){map +=f;};
244  void operator+=(double f){map +=f;};
245  //friend PixelMap operator+(const PixelMap&, const PixelMap&);
246  PixelMap operator+(const PixelMap&) const;
247 
248  PixelMap& operator-=(const PixelMap& rhs);
249  //friend PixelMap operator-(const PixelMap&, const PixelMap&);
250  PixelMap operator-(const PixelMap&) const;
251  void operator-=(float f){map -=f;};
252  void operator-=(double f){map -=f;};
253 
254  PixelMap& operator*=(const PixelMap& rhs);
255  //friend PixelMap operator*(const PixelMap&, const PixelMap&);
256  PixelMap operator*(const PixelMap& a) const;
257  PixelMap operator/(const PixelMap& a) const;
258 
259  PixelMap& operator*=(PosType b);
260  PixelMap operator*(PosType b) const;
261 
262  std::valarray<T>& data() { return map; }
263 
265  bool agrees(const PixelMap& other) const;
266 
267  //friend void swap(PixelMap&, PixelMap&);
268  static void swap(PixelMap<T>&, PixelMap<T>&);
269 
271  PosType ave() const {return map.sum()/map.size();}
273  PosType sum() const {return map.sum();};
275  size_t size(){return map.size();}
276  T max() const{ return map.max(); }
277  T min() const{ return map.min(); }
278 
279  void FindArc(PosType &radius,PosType *xc,PosType *arc_center,PosType &arclength,PosType &width
280  ,PosType threshold);
281 
283  long find_index(PosType const x[],long &ix,long &iy) const;
285  long find_index(PosType const x[]) const;
286 
288  long find_index(PosType x,PosType y,long &ix,long &iy) const;
290  long find_index(PosType x,PosType y) const;
291 
293  void find_position(PosType x[],std::size_t const index) const;
295  void find_position(PosType x[],std::size_t const ix,std::size_t const iy) const;
296 
299  PosType theta
300  ,T scale=1
301  );
302 
304  T linear_interpolate(PosType x[]);
305 
307  void drawgrid(int N,PosType value);
308  void drawPoints(std::vector<Point *> points,PosType size,PosType value);
309 
310  void drawPoints(std::vector<Point> points,PosType size,PosType value);
311 
312  void drawCurve(std::vector<Point *> points,PosType value){
313  for(int i=0;i<points.size()-1;++i) drawline(points[i]->x,points[i+1]->x,value,false);
314  }
315  void drawCurve(std::vector<Point> points,PosType value){
316  for(int i=0;i<points.size()-1;++i) drawline(points[i].x,points[i+1].x,value,false);
317  }
318  void drawPoints(std::vector<Point_2d> points,PosType size,PosType value);
319  void drawCurve(std::vector<Point_2d> points,PosType value){
320  for(int i=0;i<points.size()-1;++i) drawline(points[i].x,points[i+1].x,value,false);
321  }
323  void drawSquare(PosType p1[],PosType p2[],PosType value);
324  void drawBox(PosType p1[],PosType p2[],PosType value,int Nstrip);
325 
327  void PowerSpectrum(std::vector<PosType> &power_spectrum
328  ,std::vector<PosType> &lvec
329  ,bool overwrite = true
330  );
331 
333  void PowerSpectrum(std::vector<PosType> &power_spectrum
334  ,const std::vector<PosType> &lbins
335  ,std::vector<PosType> &lave
336  ,bool overwrite = true
337  );
338 
339  void AdaptiveSmooth(PosType value);
340 
342  void find_contour(T level
343  ,std::vector<std::vector<Point_2d> > &points
344  ,std::vector<bool> &hits_edge
345  ) const;
346 
358  void find_islands_holes(T level,
359  std::vector<std::vector<size_t>> &points,
360  std::vector<std::vector<Point_2d>> &boundaries,
361  std::vector<bool> &hits_edge,
362  std::vector<std::vector<int> > &holes) const;
363 
370  void find_islands_holes(T level,std::vector<std::vector<size_t>> &points) const;
371 
384  void lens_definition(T min_sn_per_image
385  ,T pixel_threshold
386  ,int &Nimages
387  ,T &total_sig_noise_source
388  ,std::vector<size_t> &maxima_indexes
389  ,std::vector<std::vector<size_t> > &image_points
390  ,bool &lens_TF
391  ,T &level
392  ,size_t &n_pix_in_source
393  ,bool verbose = false
394  );
395 
412  void arc_parameters(T level, Point_2d center, bool &ring,
413  double &angle, double &thinness, double &radius, double &nonrad,double &range) const;
414 
416  std::vector<size_t> maxima(T minlevel) const;
417 
424  int count_islands(std::vector<size_t> &pixel_index) const;
425 
427  size_t threshold(std::list<size_t> &pixel_index, PosType value)
428  {
429  for (size_t i = 0; i < map.size(); ++i)
430  if (value < map[i])
431  pixel_index.push_back(i);
432  return pixel_index.size();
433  }
434 
436  void flipY()
437  {
438  for (size_t i = 0; i < Nx; ++i)
439  {
440  for (size_t j = 0; j < (Ny - 1) / 2; ++j)
441  {
442  std::swap(map[i + Nx * j], map[i + Nx * (Ny - j - 1)]);
443  }
444  }
445  }
447  void flipX()
448  {
449  for (size_t i = 0; i < (Nx - 1) / 2; ++i)
450  {
451  for (size_t j = 0; j < Ny; ++j)
452  {
453  std::swap(map[i + Nx * j], map[Nx - i - 1 + Nx * j]);
454  }
455  }
456  }
458  void doubleFlip()
459  {
460  flipX();
461  flipY();
462  }
463 
465 
466  void recenter(PosType newcenter[2]
467  );
468  void recenter(Point_2d newcenter
469  );
470 
471  /* \brief convolve the image with a kernel.
472 
473  It is assumed that the size of the kernel is much smaller than the image and
474  that the kernal has the same pixel size as the image.
475  **/
476  // void convolve(PixelMap &kernel,long center_x = 0,long center_y = 0);
477 
482  PixelMap<T> downsize(int n
483  );
484 
489  PixelMap interpolate(int n);
490 
492  void addheader(std::string label, long value, std::string comment)
493  {
494  bool found = false;
495  for (auto &a : headers_long)
496  {
497  if (std::get<0>(a) == label)
498  {
499  std::get<1>(a) = value;
500  std::get<2>(a) = comment;
501  found = true;
502  break;
503  }
504  }
505  if (!found)
506  headers_long.push_back(std::make_tuple(label, value, comment));
507  }
508  void addheader(std::string label, size_t value, std::string comment)
509  {
510  bool found = false;
511  for (auto &a : headers_long)
512  {
513  if (std::get<0>(a) == label)
514  {
515  std::get<1>(a) = value;
516  std::get<2>(a) = comment;
517  found = true;
518  break;
519  }
520  }
521  if (!found)
522  headers_long.push_back(std::make_tuple(label, value, comment));
523  }
524  void addheader(std::string label, float value, std::string comment)
525  {
526  bool found = false;
527  for (auto &a : headers_float)
528  {
529  if (std::get<0>(a) == label)
530  {
531  std::get<1>(a) = value;
532  std::get<2>(a) = comment;
533  found = true;
534  break;
535  }
536  }
537  if (!found)
538  headers_float.push_back(std::make_tuple(label, value, comment));
539  }
540  void addheader(std::string label, double value, std::string comment)
541  {
542  bool found = false;
543  for (auto &a : headers_float)
544  {
545  if (std::get<0>(a) == label)
546  {
547  std::get<1>(a) = value;
548  std::get<2>(a) = comment;
549  found = true;
550  break;
551  }
552  }
553  if (!found)
554  headers_float.push_back(std::make_tuple(label, value, comment));
555  }
556  void addheader(std::string label, std::string value, std::string comment)
557  {
558  bool found = false;
559  for (auto &a : headers_string)
560  {
561  if (std::get<0>(a) == label)
562  {
563  std::get<1>(a) = value;
564  std::get<2>(a) = comment;
565  found = true;
566  break;
567  }
568  }
569  if (!found)
570  headers_string.push_back(std::make_tuple(label, value, comment));
571  }
572 
573  private:
574  std::vector<std::tuple<std::string, float, std::string>> headers_float;
575  std::vector<std::tuple<std::string, long, std::string>> headers_long;
576  std::vector<std::tuple<std::string, std::string, std::string>> headers_string;
577 
578  std::valarray<T> map;
579  long Nx;
580  long Ny;
581  double resolution, rangeX, rangeY, center[2];
582  double RA = 0, DEC = 0; // optional coordinates of center
583  double map_boundary_p1[2], map_boundary_p2[2];
584  PixelMapUnits units = PixelMapUnits::ndef;
585 
586  void AddGrid_(const PointList &list, LensingVariable val);
587 
588  double LeafPixelArea(IndexType i, Branch * branch1);
589  void PointsWithinLeaf(Branch * branch1, std::list<unsigned long> & neighborlist);
590  bool inMapBox(Branch * branch1) const;
591  bool inMapBox(double *branch1) const;
592 
594  bool pixels_are_neighbors(size_t i, size_t j) const;
598  void _count_islands_(size_t current, std::list<size_t> &reservoir, std::list<size_t>::iterator &group) const;
599 
600  // void addsource_(size_t i1,size_t i2,int oversample,Source source,PosType &total);
601  // void addsource_(size_t i1,size_t i2,int oversample,Po,
602  // PosType &total);
603 
604  template <typename S>
605  void addsource_(size_t i1, size_t i2, int oversample,
606  S &source,
607  PosType &total)
608  {
609  PosType tmp_res = resolution * 1.0 / oversample;
610  PosType tmp = tmp_res * tmp_res;
611  PosType bl = resolution / 2 - 0.5 * tmp_res;
612  PosType y[2], x[2];
613 
614  total = 0;
615 
616  for (size_t index = i1; index <= i2; ++index)
617  {
618  find_position(y, index);
619  y[0] -= bl;
620  y[1] -= bl;
621  for (int i = 0; i < oversample; ++i)
622  {
623  x[0] = y[0] + i * tmp_res;
624  for (int j = 0; j < oversample; ++j)
625  {
626  x[1] = y[1] + j * tmp_res;
627  map[index] += source.SurfaceBrightness(x) * tmp;
628  total += source.SurfaceBrightness(x) * tmp;
629  }
630  }
631  }
632  }
633 
634  // find if pixel k is in the curve which must be in pixel units, meant to be used in conjunction with Utilities::find_boundaries<>
635  bool incurve(long k, std::vector<Point_2d> &curve) const;
636  };
637 
638 template<typename T>
639 void swap(PixelMap<T>& x, PixelMap<T>& y)
640 {
641  using std::swap;
642 
643  swap(x.map,y.map);
644 
645  swap(x.Nx, y.Nx);
646  swap(x.Ny, y.Ny);
647  swap(x.resolution, y.resolution);
648  swap(x.rangeX, y.rangeX);
649  swap(x.rangeY, y.rangeY);
650 
651  swap(x.center[0], y.center[0]);
652  swap(x.center[1], y.center[1]);
653 
654  swap(x.map_boundary_p1[0], y.map_boundary_p1[0]);
655  swap(x.map_boundary_p1[1], y.map_boundary_p1[1]);
656  swap(x.map_boundary_p2[0], y.map_boundary_p2[0]);
657  swap(x.map_boundary_p2[1], y.map_boundary_p2[1]);
658 }
659 
660 #endif /* pixelmap_h */
PixelMap::operator-=
PixelMap & operator-=(const PixelMap &rhs)
Subtract the values of another PixelMap from this one.
Definition: pixelmap.cpp:566
to_string
std::string to_string(const Band &band)
convert a Band type to a string name.
Definition: InputParams.cpp:878
PixelMap::interpolate
PixelMap interpolate(int n)
Makes a PixelMap with resolution 1/n of the original with the values linearly interpolated.
Definition: pixelmap.cpp:398
PixelMap::flipX
void flipX()
reflects the image about the vertical mid-line
Definition: pixelmap.h:447
Source
Base class for all sources.
Definition: source.h:44
PixelMap::paste
void paste(const PixelMap &pmap)
Replace overlaping pixel values with those of the input map.
Definition: pixelmap.cpp:2871
PixelMap::find_index
long find_index(PosType const x[], long &ix, long &iy) const
get the index for a position, returns -1 if out of map, this version returns the 2D grid coordinates
Definition: pixelmap.cpp:2522
PixelMap::setRAandDec
void setRAandDec(double RAin, double DECin)
set the coordinates of center
Definition: pixelmap.h:107
Grid
Structure to contain both source and image trees.
Definition: grid_maintenance.h:24
Branch
The box representing a branch of a binary tree structure. Used specifically in TreeStruct for organiz...
Definition: point.h:677
PixelMap::addheader
void addheader(std::string label, long value, std::string comment)
add a heaader keyword that will appear in fits output
Definition: pixelmap.h:492
PixelMap::drawcircle
void drawcircle(PosType r_center[], PosType radius, PosType value)
Draws a circle.
Definition: pixelmap.cpp:1952
PixelMap::AddValue
void AddValue(std::size_t i, T value)
Adds a value to the i-th pixel.
Definition: pixelmap.cpp:516
PixelMap::drawgrid
void drawgrid(int N, PosType value)
draw a grid on the image that divides the each demension into N cells
Definition: pixelmap.cpp:2012
PixelMap::getDEC
double getDEC()
returns declination of center
Definition: pixelmap.h:104
PointList
link list for points, uses the linking pointers within the Point type unlike Kist
Definition: point.h:804
PixelMap::maxima
std::vector< size_t > maxima(T minlevel) const
find maxima that are above minlevel
Definition: pixelmap.cpp:1029
PixelMap::AssignValue
void AssignValue(std::size_t i, T value)
Assigns a value to the i-th pixel.
Definition: pixelmap.cpp:523
PixelMap::sum
PosType sum() const
return sum of all pixel values
Definition: pixelmap.h:273
PixelMap::printASCIItoFile
void printASCIItoFile(std::string filename) const
Print an ASCII table of all the pixel values.
Definition: pixelmap.cpp:1592
PixelMap::recenter
void recenter(PosType newcenter[2])
recenter the map without changing anything else.
Definition: pixelmap.cpp:3052
PixelMap::AddGrid
void AddGrid(const Grid &grid, T value=1.0)
Fills in pixels where the image plane points in the grid are located with the value given.
Definition: pixelmap.cpp:2231
PixelMap::convolve
PixelMap< T > convolve(const PixelMap< T > &kernel)
convolve the image with a kernel.
Definition: pixelmap.cpp:2937
Point_2d
Class for representing points or vectors in 2 dimensions. Not that the dereferencing operator is over...
Definition: point.h:48
PixelMap::operator+=
PixelMap & operator+=(const PixelMap &rhs)
Add the values of another PixelMap to this one.
Definition: pixelmap.cpp:542
PixelMap::AddGridBrightness
void AddGridBrightness(Grid &grid)
Add an image from a the surface brightnesses of a Grid to the PixelMap.
Definition: pixelmap.cpp:685
PixelMap::find_islands_holes
void find_islands_holes(T level, std::vector< std::vector< size_t >> &points, std::vector< std::vector< Point_2d >> &boundaries, std::vector< bool > &hits_edge, std::vector< std::vector< int > > &holes) const
Definition: pixelmap.cpp:942
GridMap
A simplified version of the Grid structure for making non-adaptive maps of the lensing quantities (ka...
Definition: gridmap.h:31
PixelMap::operator*=
PixelMap & operator*=(const PixelMap &rhs)
Multiply the values of another PixelMap by this one.
Definition: pixelmap.cpp:589
PixelMap::operator*
PixelMap operator*(const PixelMap &a) const
Multiply two PixelMaps.
Definition: pixelmap.cpp:618
PixelMap::downsize
PixelMap< T > downsize(int n)
Creates a PixelMap with a lower resolution. The value of the pixels are added for the new pixels....
Definition: pixelmap.cpp:371
PixelMap::size
size_t size()
Total number of pixels.
Definition: pixelmap.h:275
PixelMap::getRA
double getRA()
returns right accention of center
Definition: pixelmap.h:102
PixelMap::DrawLine
void DrawLine(long x0, long x1, long y0, long y1, T value, bool add)
line by Bresenham's line algorithm
Definition: pixelmap.cpp:1873
PixelMap::copy_in
void copy_in(const PixelMap &pmap)
copy a PixelMap into this one.
Definition: pixelmap.cpp:2775
PixelMap::agrees
bool agrees(const PixelMap &other) const
Check whether two PixelMaps agree in their physical dimensions.
Definition: pixelmap.cpp:529
PixelMap::printFITS
void printFITS(std::string filename, bool Xflip=false, bool ctype=false, bool verbose=false)
Output the pixel map as a fits file.
Definition: pixelmap.cpp:1613
PixelMap::drawline
void drawline(double x1[], double x2[], T value, bool add)
simple line
Definition: pixelmap.cpp:1826
PixelMap::count_islands
int count_islands(std::vector< size_t > &pixel_index) const
For a list of pixel indexes this will count and separated islands that are not connected.
Definition: pixelmap.cpp:1445
PixelMap::lens_definition
void lens_definition(T min_sn_per_image, T pixel_threshold, int &Nimages, T &total_sig_noise_source, std::vector< size_t > &maxima_indexes, std::vector< std::vector< size_t > > &image_points, bool &lens_TF, T &level, size_t &n_pix_in_source, bool verbose=false)
Definition: pixelmap.cpp:1071
PixelMap::operator-
PixelMap operator-(const PixelMap &) const
Subtract two PixelMaps.
Definition: pixelmap.cpp:578
PixelMap::threshold
size_t threshold(std::list< size_t > &pixel_index, PosType value)
get a list of pixels above value
Definition: pixelmap.h:427
PixelMap::AddGridMapBrightness
void AddGridMapBrightness(const GridMap &grid)
Add an image from a the surface brightnesses of a GridMap to the PixelMap.
Definition: pixelmap.cpp:720
PixelMap::AddImages
void AddImages(ImageInfo *imageinfo, int Nimages, float rescale=1.)
Add an image to the map.
Definition: pixelmap.cpp:641
PixelMap::drawBox
void drawBox(PosType p1[], PosType p2[], PosType value, int Nstrip)
Draws a box (filling the inside with horizontal lines, starting from the top)
Definition: pixelmap.cpp:2110
PixelMap::FindArc
void FindArc(PosType &radius, PosType *xc, PosType *arc_center, PosType &arclength, PosType &width, PosType threshold)
Find arcs in image WARNING: THIS IS UNDER CONSTRUCTION!
Definition: pixelmap.cpp:2377
PixelMap::find_contour
void find_contour(T level, std::vector< std::vector< Point_2d > > &points, std::vector< bool > &hits_edge) const
returns a vector of contour curves
Definition: pixelmap.cpp:858
PixelMap::find_position
void find_position(PosType x[], std::size_t const index) const
get the index for a position, returns -1 if out of map
Definition: pixelmap.cpp:2573
PixelMap::ave
PosType ave() const
return average pixel value
Definition: pixelmap.h:271
PixelMap::flipY
void flipY()
reflects the image about the horizontal mid-line
Definition: pixelmap.h:436
PixelMap::find_islands_holes
void find_islands_holes(T level, std::vector< std::vector< size_t >> &points) const
PixelMap::operator+
PixelMap operator+(const PixelMap &) const
Add two PixelMaps.
Definition: pixelmap.cpp:555
PixelMap::doubleFlip
void doubleFlip()
rotate the image by 180deg or equivalently reflect it through the origin
Definition: pixelmap.h:458
PixelMap::drawSquare
void drawSquare(PosType p1[], PosType p2[], PosType value)
Draw a rectangle.
Definition: pixelmap.cpp:2078
PixelMap::duplicate
void duplicate(const PixelMap &pmap)
copy a PixelMap that must be the same without creating a new one..
Definition: pixelmap.cpp:2763
PixelMap::drawdisk
void drawdisk(PosType r_center[], PosType radius, PosType value, int Nstrip)
Draws a disk.
Definition: pixelmap.cpp:1976
PixelMap::AddCurve
void AddCurve(ImageInfo *curve, T value)
Draws a closed curve through the points in curve->imagekist.
Definition: pixelmap.cpp:2164
PixelMap::operator/
PixelMap operator/(const PixelMap &a) const
Multiply two PixelMaps.
Definition: pixelmap.cpp:627
PixelMap::linear_interpolate
T linear_interpolate(PosType x[])
interpolate to point x[]
Definition: pixelmap.cpp:2635
PixelMap
Image structure that can be manipulated and exported to/from fits files.
Definition: pixelmap.h:42
PixelMap::printASCII
void printASCII() const
Print an ASCII table of all the pixel values.
Definition: pixelmap.cpp:1581
PixelMap::PowerSpectrum
void PowerSpectrum(std::vector< PosType > &power_spectrum, std::vector< PosType > &lvec, bool overwrite=true)
Find the power spectrum of the map.
Definition: pixelmap.cpp:3075
PixelMap::AddSource_parallel
PosType AddSource_parallel(S &source, int oversample)
Adds source to map. This version breaks pixels up into blocks and does them in seporate threads.
Definition: pixelmap.h:175
LensingVariable
LensingVariable
output lensing variables
Definition: standard.h:89
PixelMap::arc_parameters
void arc_parameters(T level, Point_2d center, bool &ring, double &angle, double &thinness, double &radius, double &nonrad, double &range) const
find arc parameters for a contour at level inputs: level : contour level to use center : proposed cen...
Definition: pixelmap.cpp:1237
Utilities::GetNThreads
int GetNThreads()
returns the compiler variable N_THREADS that is maximum number of threads to be used.
Definition: utilities.cpp:553
PixelMap::smooth
void smooth(double sigma)
Smoothes a map with a Gaussian kernel of width sigma (in arcseconds)
Definition: pixelmap.cpp:1760
PixelMap::rotate
PixelMap< T > rotate(PosType theta, T scale=1)
rotate and scale the image while keeping pixels, resoluiton
Definition: pixelmap.cpp:2600
PixelMap::Renormalize
void Renormalize(T factor)
Multiplies the whole map by a scalar factor.
Definition: pixelmap.cpp:509
PixelMap::AddUniformImages
void AddUniformImages(ImageInfo *imageinfo, int Nimages, T value)
Add images with uniform surface brightness set by input parameter value.
Definition: pixelmap.cpp:769
ImageInfo
Structure for storing information about images or curves.
Definition: image_info.h:20
PixelMap::cutout
PixelMap< T > cutout(long xmin, long xmax, long ymin, long ymax)
cut out a part of the PixelMap
Definition: pixelmap.cpp:3007