8 #ifndef IMPEM2D_IMAGE_PROCESSING_H
9 #define IMPEM2D_IMAGE_PROCESSING_H
11 #include "IMP/em2d/em2d_config.h"
19 IMPEM2D_BEGIN_NAMESPACE
25 double image_pixel_size;
26 double diffusion_beta;
27 double diffusion_timesteps;
28 double fill_holes_stddevs;
29 cv::Mat opening_kernel;
30 double remove_sizing_percentage;
31 int binary_background;
32 int binary_foreground;
37 diffusion_timesteps(200),
38 fill_holes_stddevs(1.0),
39 remove_sizing_percentage (0.1),
43 opening_kernel = cv::Mat::ones(3,3,CV_64FC1);
48 unsigned int diff_timesteps,
53 image_pixel_size(apix),
54 diffusion_beta(diff_beta),
55 diffusion_timesteps(diff_timesteps),
56 fill_holes_stddevs(fh_stddevs),
58 binary_background(background),
59 binary_foreground(foreground) {};
61 void show(std::ostream &out = std::cout)
const {
62 out <<
"Diffusion parameters: " << std::endl;
63 out <<
"image_pixel_size " << image_pixel_size << std::endl;
64 out <<
"diffusion_beta " << diffusion_beta << std::endl;
65 out <<
"diffusion_timesteps " << diffusion_timesteps << std::endl;
66 out <<
"fill_holes_stddevs " << fill_holes_stddevs << std::endl;
67 out <<
"Opening kernel " << opening_kernel.rows
68 <<
"x" << opening_kernel.cols << std::endl;
69 out <<
"binary_background " << binary_background << std::endl;
70 out <<
"binary_foreground " << binary_foreground << std::endl;
82 double cross_correlation;
85 void show(std::ostream &out = std::cout)
const {
86 out <<
"MatchTemplateResult: Pair (" << pair.first <<
"," << pair.second
87 <<
") ccc = " << cross_correlation << std::endl;
102 IMPEM2DEXPORT
void apply_mask(
const cv::Mat &m,
104 const cvIntMat &mask,
124 IMPEM2DEXPORT
double get_mean(
const cv::Mat &mat,
const cvIntMat &mask);
145 IMPEM2DEXPORT
void do_remove_small_objects(cvIntMat &m,
151 IMPEM2DEXPORT
void do_histogram_stretching(cv::Mat &m,
163 const cv::Mat &greyscale,
178 int neighbors_mode=4);
190 cvIntMat &mat_to_label);
198 IMPEM2DEXPORT
void do_segmentation(
const cv::Mat &m,
213 unsigned int time_steps);
238 IMPEM2DEXPORT
void do_fill_holes(
const cv::Mat &m,
250 IMPEM2DEXPORT
void get_domes(cv::Mat &m,cv::Mat &result,
double h) ;
262 IMPEM2DEXPORT
void do_combined_fill_holes_and_threshold(cv::Mat &m,
265 double threshold=0.0);
287 cv::Mat &filtered,
int kernelsize);
307 IMPEM2DEXPORT
void add_noise(cv::Mat &v,
double op1,
double op2,
308 const String &mode =
"uniform",
double df = 3);
328 IMPEM2DEXPORT
void my_meanStdDev(
const cv::Mat &m,
337 cv::Mat &transformed,
347 IMPEM2DEXPORT
void do_extend_borders(cv::Mat &orig,
357 double threshold=0.0);
369 const cv::Mat &kernel,
370 unsigned int iterations);
377 const cv::Mat &kernel);
392 const IntPair ¢er);
401 const cv::Mat &templ,
410 IMPEM2DEXPORT cv::Mat
crop(
const cv::Mat &m,
411 const IntPair ¢er,
416 IMPEM2D_END_NAMESPACE