GLAMERDOC++
Gravitational Lensing Code Library
|
8 #ifndef IMAGE_PROCESSING_H_
9 #define IMAGE_PROCESSING_H_
16 #include "image_info.h"
32 enum class PixelMapUnits {
41 std::string
to_string(PixelMapUnits unit);
56 PixelMap(
const double* center, std::size_t Npixels,
double resolution,PixelMapUnits u = PixelMapUnits::ndef);
57 PixelMap(
const double* center, std::size_t Nx, std::size_t Ny,
double resolution,PixelMapUnits u = PixelMapUnits::ndef);
59 ,
double resolution = -1,PixelMapUnits u = PixelMapUnits::ndef);
67 void ChangeUnits(PixelMapUnits u){units=u;}
68 PixelMapUnits getUnits()
const {
return units;}
70 inline bool valid()
const {
return map.size(); };
71 inline std::size_t size()
const {
return map.size(); };
73 inline std::size_t getNx()
const {
return Nx; }
74 inline std::size_t getNy()
const {
return Ny; }
75 inline double getRangeX()
const {
return rangeX; }
76 inline double getRangeY()
const {
return rangeY; }
78 void const getCenter(
Point_2d &c)
const{ c[0]=center[0]; c[1]=center[1];}
83 inline double getResolution()
const {
return resolution; }
97 void Clean(){
for(
auto &a : map) a = 0;}
100 void AddImages(std::vector<ImageInfo> &imageinfo,
int Nimages,
float rescale = 1.);
106 PosType AddSource(
Source &source);
108 PosType AddSource(
Source &source,
int oversample);
109 void AddPointSource(
const Point_2d &x,
double flux);
139 template <
typename T>
142 source.getTheta(s_center);
144 if( (s_center[0] + source.getRadius() ) < map_boundary_p1[0] )
return 0.0;
145 if( (s_center[0] - source.getRadius() ) > map_boundary_p2[0] )
return 0.0;
146 if( (s_center[1] + source.getRadius() ) < map_boundary_p1[1] )
return 0.0;
147 if( (s_center[1] - source.getRadius() ) > map_boundary_p2[1] )
return 0.0;
150 PosType totals[nthreads];
151 std::vector<std::thread> thr;
153 size_t block = map.size()/nthreads;
154 for(
int i = 0; i < nthreads ;++i){
155 thr.push_back(std::thread(&PixelMap::addsource_<T>,
this
156 ,i*block,std::min((i+1)*block-1,map.size()-1)
157 ,oversample,std::ref(source)
158 ,std::ref(totals[i])));
161 for(
int ii=0;ii < nthreads;++ii) thr[ii].join();
164 for(
int ii=0;ii < nthreads;++ii) total += totals[ii];
170 void AddCurve(Kist<Point> *imagekist,PosType value);
171 void AddCurve(std::vector<Point_2d> &curve,
double value);
172 void AddCurve(std::vector<RAY> &curve,
double value);
175 void drawline(
double x1[],
double x2[],
double value,
bool add);
177 void DrawLine(
long x0,
long x1,
long y0,
long y1,
double value,
bool add);
178 void DrawLineGS(
long x0,
long x1,
long y0,
long y1,
double value,
bool add);
179 void drawcircle(PosType r_center[],PosType radius,PosType value);
180 void drawdisk(PosType r_center[],PosType radius,PosType value,
int Nstrip);
185 void AddValue(std::size_t i,
double value);
189 void printFITS(std::string filename,
bool Xflip =
false,
bool verbose =
false);
190 void printFITS(std::string filename,std::vector< std::tuple<std::string,double,std::string> > &extra_header_info,
bool verbose);
194 ,std::vector<std::string> &headercards
197 void smooth(
double sigma);
199 inline double getValue(std::size_t i)
const {
return map[i]; }
200 inline double & operator[](std::size_t i) {
return map[i]; };
201 double operator[](std::size_t i)
const {
return map[i]; };
202 inline double operator()(std::size_t i)
const {
return map[i]; };
203 inline double operator()(std::size_t i,std::size_t j)
const {
return map[i + Nx*j]; };
204 inline double & operator()(std::size_t i,std::size_t j) {
return map[i + Nx*j]; };
223 std::valarray<double>& data() {
return map; }
232 PosType
ave()
const {
return map.sum()/map.size();}
234 PosType
sum()
const {
return map.sum();};
236 size_t size(){
return map.size();}
237 double max()
const{
return map.max(); }
238 double min()
const{
return map.min(); }
240 void FindArc(PosType &radius,PosType *xc,PosType *arc_center,PosType &arclength,PosType &width
244 long find_index(PosType
const x[],
long &ix,
long &iy)
const;
249 long find_index(PosType x,PosType y,
long &ix,
long &iy)
const;
254 void find_position(PosType x[],std::size_t
const index)
const;
256 void find_position(PosType x[],std::size_t
const ix,std::size_t
const iy)
const;
269 void drawPoints(std::vector<Point *> points,PosType size,PosType value);
271 void drawPoints(std::vector<Point> points,PosType size,PosType value);
273 void drawCurve(std::vector<Point *> points,PosType value){
274 for(
int i=0;i<points.size()-1;++i)
drawline(points[i]->x,points[i+1]->x,value,
false);
276 void drawCurve(std::vector<Point> points,PosType value){
277 for(
int i=0;i<points.size()-1;++i)
drawline(points[i].x,points[i+1].x,value,
false);
279 void drawPoints(std::vector<Point_2d> points,PosType size,PosType value);
280 void drawCurve(std::vector<Point_2d> points,PosType value){
281 for(
int i=0;i<points.size()-1;++i)
drawline(points[i].x,points[i+1].x,value,
false);
284 void drawSquare(PosType p1[],PosType p2[],PosType value);
285 void drawBox(PosType p1[],PosType p2[],PosType value,
int Nstrip);
289 ,std::vector<PosType> &lvec
290 ,
bool overwrite =
true
293 if(power_spectrum.size() != lvec.size())
throw std::invalid_argument(
"these must be the same size");
296 Utilities::powerspectrum2d(map,Nx,Ny,rangeX,rangeY, lvec, power_spectrum);
298 std::vector<PosType> tmp_power(power_spectrum.size());
299 Utilities::powerspectrum2d(map,Nx,Ny,rangeX,rangeY,lvec,tmp_power);
300 for(
size_t ii=0;ii<power_spectrum.size();++ii) power_spectrum[ii] += tmp_power[ii];
306 ,
const std::vector<PosType> &lbins
307 ,std::vector<PosType> &lave
308 ,
bool overwrite =
true
314 if(power_spectrum.size() != lbins.size()-1)
throw std::invalid_argument(
"these must be the same size");
315 std::vector<PosType> tmp_power(power_spectrum.size());
317 for(
size_t ii=0;ii<power_spectrum.size();++ii) power_spectrum[ii] += tmp_power[ii];
321 void AdaptiveSmooth(PosType value){
328 ,std::vector<std::vector<Point_2d> > &points
329 ,std::vector<bool> &hits_edge
338 std::vector<std::vector<size_t> > &points
354 ,
double pixel_threshold
356 ,
double &total_sig_noise_source
357 ,std::vector<size_t> &maxima_indexes
358 ,std::vector<std::vector<size_t> > &image_points
361 ,
size_t &n_pix_in_source
362 ,
bool verbose =
false
367 std::vector<size_t>
maxima(
double minlevel)
const;
379 size_t threshold(std::list<size_t> &pixel_index,PosType value){
380 for(
size_t i=0;i<map.size();++i)
if(value < map[i]) pixel_index.push_back(i);
381 return pixel_index.size();
386 for(
size_t i=0;i<Nx;++i){
387 for(
size_t j=0;j<(Ny-1)/2;++j){
388 std::swap( map[i + Nx*j],map[i + Nx*(Ny-j-1)] );
394 for(
size_t i=0;i<(Nx-1)/2;++i){
395 for(
size_t j=0;j<Ny;++j){
396 std::swap( map[i + Nx*j],map[Nx-i-1 + Nx*j] );
429 void addheader(std::string label,
long value,std::string comment){
431 for(
auto &a : headers_long){
432 if(std::get<0>(a) == label){
433 std::get<1>(a)=value;
434 std::get<2>(a)=comment;
439 if(!found) headers_long.push_back(std::make_tuple(label,value,comment));
441 void addheader(std::string label,
size_t value,std::string comment){
443 for(
auto &a : headers_long){
444 if(std::get<0>(a) == label){
445 std::get<1>(a)=value;
446 std::get<2>(a)=comment;
451 if(!found) headers_long.push_back(std::make_tuple(label,value,comment));
453 void addheader(std::string label,
float value,std::string comment){
455 for(
auto &a : headers_float){
456 if(std::get<0>(a) == label){
457 std::get<1>(a)=value;
458 std::get<2>(a)=comment;
463 if(!found) headers_float.push_back(std::make_tuple(label,value,comment));
465 void addheader(std::string label,
double value,std::string comment){
467 for(
auto &a : headers_float){
468 if(std::get<0>(a) == label){
469 std::get<1>(a)=value;
470 std::get<2>(a)=comment;
475 if(!found) headers_float.push_back(std::make_tuple(label,value,comment));
477 void addheader(std::string label,std::string value,std::string comment){
479 for(
auto &a : headers_string){
480 if(std::get<0>(a) == label){
481 std::get<1>(a)=value;
482 std::get<2>(a)=comment;
487 if(!found) headers_string.push_back(std::make_tuple(label,value,comment));
491 std::vector<std::tuple<std::string,float,std::string> > headers_float;
492 std::vector<std::tuple<std::string,long,std::string> > headers_long;
493 std::vector<std::tuple<std::string,std::string,std::string> > headers_string;
495 std::valarray<double> map;
498 double resolution,rangeX,rangeY,center[2];
500 double map_boundary_p1[2],map_boundary_p2[2];
501 PixelMapUnits units= PixelMapUnits::ndef;
505 double LeafPixelArea(IndexType i,
Branch * branch1);
506 void PointsWithinLeaf(
Branch * branch1, std::list <unsigned long> &neighborlist);
507 bool inMapBox(
Branch * branch1)
const;
508 bool inMapBox(
double * branch1)
const;
511 bool pixels_are_neighbors(
size_t i,
size_t j)
const;
515 void _count_islands_(
size_t current,std::list<size_t> &reservoir
516 ,std::list<size_t>::iterator &group)
const;
522 template <
typename T>
523 void addsource_(
size_t i1,
size_t i2,
int oversample,
526 PosType tmp_res = resolution*1.0/oversample;
527 PosType tmp = tmp_res*tmp_res;
528 PosType bl = resolution /2 - 0.5*tmp_res;
533 for(
size_t index = i1 ;index <= i2; ++index){
537 for(
int i = 0 ; i < oversample ; ++i){
538 x[0] = y[0] + i*tmp_res;
539 for(
int j=0; j < oversample;++j){
540 x[1] = y[1] + j*tmp_res;
541 map[index] += source.SurfaceBrightness(x)*tmp;
542 total += source.SurfaceBrightness(x)*tmp;
549 bool incurve(
long k,std::vector<Point_2d> &curve)
const;
552 enum class Telescope {Euclid_VIS,Euclid_Y,Euclid_J,Euclid_H,KiDS_u,KiDS_g,KiDS_r,KiDS_i,HST_ACS_I,CFHT_u,CFHT_g,CFHT_r,CFHT_i,CFHT_z};
554 enum class UnitType {counts_x_sec, flux} ;
560 Obs(
size_t Npix_xx,
size_t Npix_yy
568 size_t getNxInput()
const {
return Npix_x_input;}
569 size_t getNyInput()
const {
return Npix_y_input;}
571 size_t getNxOutput()
const {
return Npix_x_output;}
572 size_t getNyOutput()
const {
return Npix_y_output;}
574 std::valarray<double> getPSF(){
return map_psf;}
576 void setPSF(std::string psf_file,
double resolution=0);
579 void rotatePSF(
double theta
585 void coaddPSF(
double f
593 float getPixelSize()
const {
return pix_size;}
594 void setNoiseCorrelation(std::string nc_file);
598 virtual void AddNoise(
PixelMap &pmap
602 virtual void Convert(
PixelMap &map_in
609 virtual float getBackgroundNoise()
const = 0;
612 virtual double mag_to_counts(
double m)
const = 0;
613 virtual double counts_to_mag(
double flux)
const = 0;
614 virtual double zeropoint()
const = 0;
615 virtual void setZeropoint(
double zpoint) = 0;
621 void CorrelateNoise(
PixelMap &pmap);
625 size_t Npix_x_output,Npix_y_output;
627 size_t Npix_x_input,Npix_y_input;
629 float psf_oversample;
635 double input_psf_pixel_size;
639 std::valarray<double> map_psf;
640 std::valarray<double> map_psfo;
642 std::vector<std::complex<double> > fft_psf;
643 std::vector<std::complex<double> > fft_padded;
644 std::vector<double> image_padded;
645 std::vector<double> sqrt_noise_power;
648 size_t nborder_x = 0;
649 size_t nborder_y = 0;
655 fftw_plan image_to_fft;
656 fftw_plan fft_to_image;
659 std::vector<std::complex<double> > noise_fft_image;
660 std::vector<double> noise_in_zeropad;
661 fftw_plan p_noise_r2c;
662 std::vector<double> noise_image_out;
663 fftw_plan p_noise_c2r;
678 double zero_point = 24.4;
689 double sigma_background;
701 ObsVIS(
size_t Npix_x,
size_t Npix_y
703 ,
double resolution = 0.1*arcsecTOradians
709 ,
const std::vector<double> &exposure_times
715 ,
const std::vector<double> &exposure_times
718 ,
double background_sigma
742 double mag_to_counts(
double m)
const{
743 if(m == 100)
return 0;
744 return pow(10,-0.4*(m + zero_point));
746 double counts_to_mag(
double flux)
const{
747 if(flux <=0)
return 100;
748 return -2.5 * log10(flux) - zero_point;
751 double zeropoint()
const {
return zero_point;}
752 void setZeropoint(
double zpoint){zero_point=zpoint;}
756 double dt = Utilities::vec_sum(t_exp);
758 return sigma_background / sqrt(dt);
763 std::vector<double> t_exp;
778 Observation(Telescope tel_name,
double exposure_time,
int exposure_num
779 ,
size_t Npix_x,
size_t Npix_y,
float oversample);
780 Observation(
float diameter,
float transmission,
float exp_time,
int exp_num,
float back_mag,
float read_out_noise
781 ,
size_t Npix_x,
size_t Npix_y,
double pix_size,
float seeing = 0.);
782 Observation(
float diameter,
float transmission,
float exp_time,
int exp_num,
float back_mag,
float read_out_noise ,std::string psf_file,
size_t Npix_x,
size_t Npix_y,
double pix_size,
float oversample = 1.);
784 Observation(
float zeropoint_mag,
float exp_time,
int exp_num,
float back_mag,
float read_out_noise,
size_t Npix_x,
size_t Npix_y,
double pix_size,
float seeing=0);
785 Observation(
float zeropoint_mag,
float exp_time,
int exp_num,
float back_mag,
float read_out_noise ,std::string psf_file,
size_t Npix_x,
size_t Npix_y,
double pix_size,
float oversample = 1.);
789 float getExpTime()
const {
return exp_time;}
790 int getExpNum()
const {
return exp_num;}
791 float getBackMag()
const {
return back_mag;}
793 float getRon()
const {
return read_out_noise;}
796 float getZeropoint()
const {
return mag_zeropoint;}
797 void setZeropoint(
double zpoint){mag_zeropoint=zpoint;}
799 float getBackgroundNoise(
float resolution, UnitType unit = UnitType::counts_x_sec)
const;
817 void setPixelSize(
float pixel_size){pix_size=pixel_size;}
819 double mag_to_counts(
double m)
const {
820 if(m == 100)
return 0;
821 return pow(10,-0.4*(m - mag_zeropoint));
823 double counts_to_mag(
double flux)
const{
824 if(flux <=0)
return 100;
825 return -2.5 * log10(flux) + mag_zeropoint;
827 double zeropoint()
const{
828 return mag_zeropoint;
838 float read_out_noise;
842 float e_per_s_to_ergs_s_cm2;
843 float background_flux;
848 void ToSurfaceBrightness(
PixelMap &pmap);
853 void pixelize(
double *map,
long Npixels,
double range,
double *center
854 ,
ImageInfo *imageinfo,
int Nimages,
bool constant_sb,
bool cleanmap
855 ,
bool write_for_skymaker =
false, std::string filename=
"");
856 void _SplitFluxIntoPixels(
TreeHndl ptree,
Branch *leaf,
double *leaf_sb);
860 void LoadFitsImages(std::string dir,
const std::string& filespec,std::vector<PixelMap> & images,
int maxN,
double resolution = -1,
bool verbose =
false);
861 void LoadFitsImages(std::string dir,std::vector<std::string> filespecs,std::vector<std::string> file_non_specs ,std::vector<PixelMap> & images,std::vector<std::string> & names,
int maxN,
double resolution = -1,
bool verbose =
false);
862 void ReadFileNames(std::string dir,
const std::string filespec
863 ,std::vector<std::string> & filenames
864 ,
const std::string file_non_spec =
" "
865 ,
bool verbose =
false);
872 MultiGridSmoother(
double center[],std::size_t Nx,std::size_t Ny,
double resolution);
884 void add_particles(std::vector<PosType> x,std::vector<PosType> y);
887 void smooth(
int Nsmooth,
PixelMap &map);
890 void _smooth_(
int k,
size_t i,
size_t j,
int Nsmooth,
PixelMap &map);
891 std::vector<PixelMap> maps;
892 std::vector<Utilities::Interpolator<PixelMap>> interpolators;
PosType getHighestRes()
resolution of finest grid from which interpolation is done
Definition: image_processing.h:879
void AddUniformImages(ImageInfo *imageinfo, int Nimages, double value)
Add images with uniform surface brightness set by input parameter value.
Definition: pixelize.cpp:716
float getBackgroundNoise(float resolution, UnitType unit=UnitType::counts_x_sec) const
pixel size in radians
Definition: observation.cpp:1158
PixelMap & operator-=(const PixelMap &rhs)
Subtract the values of another PixelMap from this one.
Definition: pixelize.cpp:529
void AddCurve(ImageInfo *curve, double value)
Draws a closed curve through the points in curve->imagekist.
Definition: pixelize.cpp:1783
PosType getLowestRes()
resolution of coarsest grid from which interpolation is done
Definition: image_processing.h:881
double getRA()
returns right accention of center
Definition: image_processing.h:86
void AddGridMapBrightness(const GridMap &grid)
Add an image from a the surface brightnesses of a GridMap to the PixelMap.
Definition: pixelize.cpp:673
void AssignValue(std::size_t i, double value)
Assigns a value to the i-th pixel.
Definition: pixelize.cpp:490
Base class for all sources.
Definition: source.h:45
void AddValue(std::size_t i, double value)
Adds a value to the i-th pixel.
Definition: pixelize.cpp:484
Structure to contain both source and image trees.
Definition: grid_maintenance.h:25
void drawBox(PosType p1[], PosType p2[], PosType value, int Nstrip)
Draws a box (filling the inside with horizontal lines, starting from the top)
Definition: pixelize.cpp:1730
void printASCII() const
Print an ASCII table of all the pixel values.
Definition: pixelize.cpp:1218
The box representing a branch of a binary tree structure. Used specifically in TreeStruct for organiz...
Definition: point.h:624
void AddNoise(PixelMap &pmap, PixelMap &error_map, Utilities::RandomNumbers_NR &ran, bool cosmic=true)
Applies noise (read-out + Poisson) on an image, returns noise map.
Definition: observation.cpp:76
void drawdisk(PosType r_center[], PosType radius, PosType value, int Nstrip)
Draws a disk.
Definition: pixelize.cpp:1601
void setExpTime(float time)
returns factor by which code image units need to be multiplied by to get flux units
Definition: image_processing.h:816
void recenter(PosType newcenter[2])
recenter the map without changing anything else.
Definition: pixelize.cpp:2810
link list for points, uses the linking pointers within the Point type unlike Kist
Definition: point.h:751
size_t threshold(std::list< size_t > &pixel_index, PosType value)
get a list of pixels above value
Definition: image_processing.h:379
void paste(const PixelMap &pmap)
Replace overlaping pixel values with those of the input map.
Definition: pixelize.cpp:2746
PosType ave() const
return average pixel value
Definition: image_processing.h:232
void setRAandDec(double RAin, double DECin)
set the coordinates of center
Definition: image_processing.h:91
void AddNoise(PixelMap &pmap, PixelMap &error_map, Utilities::RandomNumbers_NR &ran, bool dummy)
Applies realistic noise (read-out + Poisson) on an image, returns noise map.
Definition: observation.cpp:1185
void printFITS(std::string filename, bool Xflip=false, bool verbose=false)
Output the pixel map as a fits file.
Definition: pixelize.cpp:1248
void addheader(std::string label, long value, std::string comment)
add a heaader keyword that will appear in fits output
Definition: image_processing.h:429
void drawSquare(PosType p1[], PosType p2[], PosType value)
Draw a rectangle.
Definition: pixelize.cpp:1699
void DrawLine(long x0, long x1, long y0, long y1, double value, bool add)
line by Bresenham's line algorithm
Definition: pixelize.cpp:1501
void AddGridBrightness(Grid &grid)
Add an image from a the surface brightnesses of a Grid to the PixelMap.
Definition: pixelize.cpp:640
void AddImages(ImageInfo *imageinfo, int Nimages, float rescale=1.)
Add an image to the map.
Definition: pixelize.cpp:597
Class for representing points or vectors in 2 dimensions. Not that the dereferencing operator is over...
Definition: point.h:48
void drawcircle(PosType r_center[], PosType radius, PosType value)
Draws a circle.
Definition: pixelize.cpp:1578
It creates a realistic image from the output of a ray-tracing simulation.
Definition: image_processing.h:674
void copy_in(const PixelMap &pmap)
copy a PixelMap into this one.
Definition: pixelize.cpp:2689
This is a class for generating random numbers. It simplifies and fool proofs initialization and allow...
Definition: utilities_slsim.h:1041
float getBackgroundNoise() const
returns std of pixels in e-
Definition: image_processing.h:755
A simplified version of the Grid structure for making non-adaptive maps of the lensing quantities (ka...
Definition: gridmap.h:31
void AddGrid(const Grid &grid, double value=1.0)
Fills in pixels where the image plane points in the grid are located with the value given.
Definition: pixelize.cpp:1849
PixelMap & operator+=(const PixelMap &rhs)
Add the values of another PixelMap to this one.
Definition: pixelize.cpp:507
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: pixelize.cpp:1086
PixelMap downsize(int n)
Creates a PixelMap with a lower resolution. The value of the pixels are added for the new pixels....
Definition: pixelize.cpp:412
PosType linear_interpolate(PosType x[])
interpolate to point x[]
Definition: pixelize.cpp:2419
void doubleFlip()
rotate the image by 180deg or equivalently reflect it through the origin
Definition: image_processing.h:401
double getDEC()
returns declination of center
Definition: image_processing.h:88
Warning: Not tested yet. Class for doing adaptive smoothing using multiply resolution grids.
Definition: image_processing.h:870
void find_contour(double level, std::vector< std::vector< Point_2d > > &points, std::vector< bool > &hits_edge) const
returns a vector of contour curves
Definition: pixelize.cpp:800
Tree: Exported struct.
Definition: Tree.h:31
PixelMap operator+(const PixelMap &) const
Add two PixelMaps.
Definition: pixelize.cpp:519
PixelMap & operator*=(const PixelMap &rhs)
Multiply the values of another PixelMap by this one.
Definition: pixelize.cpp:550
PixelMap operator/(const PixelMap &a) const
Multiply two PixelMaps.
Definition: pixelize.cpp:584
void smooth(double sigma)
Smoothes a map with a Gaussian kernel of width sigma (in arcseconds)
Definition: pixelize.cpp:1389
void printASCIItoFile(std::string filename) const
Print an ASCII table of all the pixel values.
Definition: pixelize.cpp:1228
PosType sum() const
return sum of all pixel values
Definition: image_processing.h:234
std::valarray< double > AdaptiveSmooth(const std::valarray< double > &map_in, size_t Nx, size_t Ny, double value)
Smooth a 2 dimensional map stored in a valarray with a density dependent kernel.
Definition: utilities.cpp:762
void find_islands_holes(double level, std::vector< std::vector< size_t > > &points) const
Definition: pixelize.cpp:819
void lens_definition(double min_sn_per_image, double pixel_threshold, int &Nimages, double &total_sig_noise_source, std::vector< size_t > &maxima_indexes, std::vector< std::vector< size_t > > &image_points, bool &lens_TF, double &level, size_t &n_pix_in_source, bool verbose=false)
Definition: pixelize.cpp:920
void ReadFileNames(std::string dir, const std::string filespec, std::vector< std::string > &filenames, const std::string file_non_spec=" ", bool verbose=false)
Definition: pixelize.cpp:2248
void flipX()
reflects the image about the vertical mid-line
Definition: image_processing.h:393
void add_particles(std::vector< PosType > x, std::vector< PosType > y)
Add particles to the map. These do not need to be kept in memory after they are added.
Definition: pixelize.cpp:2513
void powerspectrum2dprebin(std::valarray< double > &aa, int nx, int ny, double boxlx, double boxly, const std::vector< double > &ll, std::vector< double > &Pl, std::vector< double > &llave)
Definition: utilities.cpp:680
void flipY()
reflects the image about the horizontal mid-line
Definition: image_processing.h:385
bool agrees(const PixelMap &other) const
Check whether two PixelMaps agree in their physical dimensions.
Definition: pixelize.cpp:495
std::vector< size_t > maxima(double minlevel) const
find maxima that are above minlevel
Definition: pixelize.cpp:881
void Renormalize(double factor)
Multiplies the whole map by a scalar factor.
Definition: pixelize.cpp:478
void PowerSpectrum(std::vector< PosType > &power_spectrum, const std::vector< PosType > &lbins, std::vector< PosType > &lave, bool overwrite=true)
Find the power spectrum of the map.
Definition: image_processing.h:305
void LoadFitsImages(std::string dir, const std::string &filespec, std::vector< PixelMap > &images, int maxN, double resolution=-1, bool verbose=false)
Reads all the fits files in a directory into a vector of PixelMaps.
Definition: pixelize.cpp:2140
void find_position(PosType x[], std::size_t const index) const
get the index for a position, returns -1 if out of map
Definition: pixelize.cpp:2359
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: pixelize.cpp:1993
void duplicate(const PixelMap &pmap)
copy a PixelMap that must be the same without creating a new one..
Definition: pixelize.cpp:2677
size_t size()
Total number of pixels.
Definition: image_processing.h:236
void drawline(double x1[], double x2[], double value, bool add)
simple line
Definition: pixelize.cpp:1455
void convolve(PixelMap &kernel, long center_x=0, long center_y=0)
convolve the image with a kernel.
Definition: pixelize.cpp:2885
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: pixelize.cpp:2312
PixelMap operator-(const PixelMap &) const
Subtract two PixelMaps.
Definition: pixelize.cpp:540
void drawgrid(int N, PosType value)
draw a grid on the image that divides the each demension into N cells
Definition: pixelize.cpp:1637
void AddPoisson(PixelMap &pmap, Utilities::RandomNumbers_NR &ran)
add poisson noise to an image that is in units of electrons
Definition: observation.cpp:59
MultiGridSmoother(double center[], std::size_t Nx, std::size_t Ny, double resolution)
Definition: pixelize.cpp:2463
PosType AddSource_parallel(T &source, int oversample)
Adds source to map. This version breaks pixels up into blocks and does them in seporate threads.
Definition: image_processing.h:140
void output_map(PixelMap &map, int Nsmooth)
Output a map at the resolution of the map smoothed so that no superpixel as less than Nsmooth particl...
Definition: pixelize.cpp:2531
float getRon() const
read-out noise in electrons/pixel
Definition: image_processing.h:793
PixelMap rotate(PosType theta, PosType scale=1)
rotate and scale the image while keeping pixels, resoluiton
Definition: pixelize.cpp:2384
void Convert(PixelMap &map_in, PixelMap &map_out, PixelMap &error_map, bool psf, bool noise, Utilities::RandomNumbers_NR &ran, bool cosmic=false)
Converts the input map to a realistic image.
Definition: observation.cpp:1121
float getSeeing() const
seeing in arcsecs
Definition: image_processing.h:795
void PowerSpectrum(std::vector< PosType > &power_spectrum, std::vector< PosType > &lvec, bool overwrite=true)
Find the power spectrum of the map.
Definition: image_processing.h:288
Image structure that can be manipulated and exported to/from fits files.
Definition: image_processing.h:48
LensingVariable
output lensing variables
Definition: standard.h:89
Observation(Telescope tel_name, double exposure_time, int exposure_num, size_t Npix_x, size_t Npix_y, float oversample)
Creates an observation setup that mimics a known instrument.
Definition: observation.cpp:812
int GetNThreads()
returns the compiler variable N_THREADS that is maximum number of threads to be used.
Definition: utilities.cpp:846
Structure for storing information about images or curves.
Definition: image_info.h:20
PixelMap operator*(const PixelMap &a) const
Multiply two PixelMaps.
Definition: pixelize.cpp:576
Definition: utilities.h:30
It creates a realistic image from the output of a ray-tracing simulation.
Definition: image_processing.h:776