8 #ifndef IMPEM2D_IMAGE_PROCESSING_H
9 #define IMPEM2D_IMAGE_PROCESSING_H
11 #include "IMP/em2d/em2d_config.h"
18 IMPEM2D_BEGIN_NAMESPACE
23 double image_pixel_size;
24 double diffusion_beta;
25 double diffusion_timesteps;
26 double fill_holes_stddevs;
27 cv::Mat opening_kernel;
28 double remove_sizing_percentage;
29 int binary_background;
30 int binary_foreground;
34 : image_pixel_size(1),
36 diffusion_timesteps(200),
37 fill_holes_stddevs(1.0),
38 remove_sizing_percentage(0.1),
42 opening_kernel = cv::Mat::ones(3, 3, CV_64FC1);
46 unsigned int diff_timesteps,
double fh_stddevs,
47 const cv::Mat &kr,
int background,
int foreground)
48 : image_pixel_size(apix),
49 diffusion_beta(diff_beta),
50 diffusion_timesteps(diff_timesteps),
51 fill_holes_stddevs(fh_stddevs),
53 binary_background(background),
54 binary_foreground(foreground) {};
56 void show(std::ostream &out = std::cout)
const {
57 out <<
"Diffusion parameters: " << std::endl;
58 out <<
"image_pixel_size " << image_pixel_size << std::endl;
59 out <<
"diffusion_beta " << diffusion_beta << std::endl;
60 out <<
"diffusion_timesteps " << diffusion_timesteps << std::endl;
61 out <<
"fill_holes_stddevs " << fill_holes_stddevs << std::endl;
62 out <<
"Opening kernel " << opening_kernel.rows <<
"x"
63 << opening_kernel.cols << std::endl;
64 out <<
"binary_background " << binary_background << std::endl;
65 out <<
"binary_foreground " << binary_foreground << std::endl;
76 double cross_correlation;
79 void show(std::ostream &out = std::cout)
const {
80 out <<
"MatchTemplateResult: Pair (" << pair.first <<
"," << pair.second
81 <<
") ccc = " << cross_correlation << std::endl;
94 IMPEM2DEXPORT
void apply_mask(
const cv::Mat &m, cv::Mat &result,
95 const cvIntMat &mask,
double val);
100 int radius,
double value = 0.0);
107 IMPEM2DEXPORT
double get_mean(
const cv::Mat &mat,
const cvIntMat &mask);
130 IMPEM2DEXPORT
void do_histogram_stretching(cv::Mat &m,
int boxes,
int offset);
140 const cv::Mat &grayscale,
153 int neighbors_mode = 4);
162 IMPEM2DEXPORT
int do_labeling(
const cvIntMat &m, cvIntMat &mat_to_label);
181 double beta,
double pixelsize,
182 unsigned int time_steps);
194 const cv::Mat &m, cv::Mat &der,
double dx,
double dy,
double ang);
203 IMPEM2DEXPORT
void do_fill_holes(
const cv::Mat &m, cv::Mat &result,
double h);
212 IMPEM2DEXPORT
void get_domes(cv::Mat &m, cv::Mat &result,
double h);
226 double threshold = 0.0);
245 cv::Mat &filtered,
int kernelsize);
264 IMPEM2DEXPORT
void add_noise(cv::Mat &v,
double op1,
double op2,
265 const String &mode =
"uniform",
double df = 3);
277 const cv::Mat &input, cv::Mat &resampled,
286 IMPEM2DEXPORT
void get_transformed(
const cv::Mat &input, cv::Mat &transformed,
301 double threshold = 0.0);
313 const cv::Mat &kernel,
314 unsigned int iterations);
321 const cv::Mat &kernel);
335 const IntPair ¢er);
352 IMPEM2DEXPORT cv::Mat
crop(
const cv::Mat &m,
const IntPair ¢er,
int size);
354 IMPEM2D_END_NAMESPACE
void do_morphologic_contrast_enhancement(const cv::Mat &m, cv::Mat &result, const cv::Mat &kernel, unsigned int iterations)
double get_mean(const cv::Mat &mat, const cvIntMat &mask)
void apply_threshold(cv::Mat &m, cv::Mat &result, double threshold=0.0)
cv::Mat crop(const cv::Mat &m, const IntPair ¢er, int size)
Class to provide all the parameters to the segmentation function.
cvIntMat create_circular_mask(int rows, int cols, int radius)
void do_dilate_and_shrink_warp(cv::Mat &m, const cv::Mat &grayscale, cv::Mat &kernel)
(U. Adiga, 2005)
int do_labeling(const cvIntMat &m, cvIntMat &mat_to_label)
Labeling function for a matrix.
MatchTemplateResults get_best_template_matches(const cv::Mat &m, const cv::Mat &templ, unsigned int n)
void do_extend_borders(cv::Mat &orig, cv::Mat &dst, unsigned int pix)
Interface with OpenCV Copyright 2007-2018 IMP Inventors. All rights reserved.
A more IMP-like version of the std::vector.
Floats get_histogram(const cv::Mat &m, int bins)
Computes the histogram of a matrix.
void do_resample_polar(const cv::Mat &input, cv::Mat &resampled, const PolarResamplingParameters &polar_params)
Resamples a matrix to polar coordinates.
void do_combined_fill_holes_and_threshold(cv::Mat &m, cv::Mat &result, double n_stddevs, double threshold=0.0)
Combines the fill holes and thresholding operations together with normalize.
void do_normalize(cv::Mat &m)
Normalize a openCV matrix to mean 0 and stddev 1. It is done in place.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
void do_fill_holes(const cv::Mat &m, cv::Mat &result, double h)
Fills the holes in the matrix m of height h.
void apply_circular_mask(const cv::Mat &mat, cv::Mat &result, int radius, double value=0.0)
Functions related with rotations in em2d Copyright 2007-2018 IMP Inventors. All rights reserved...
void get_morphologic_gradient(const cv::Mat &m, cv::Mat &result, const cv::Mat &kernel)
void apply_mask(const cv::Mat &m, cv::Mat &result, const cvIntMat &mask, double val)
Applies a binary mask to an image.
void get_domes(cv::Mat &m, cv::Mat &result, double h)
Gets the domes of m with height h.
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node.
void apply_diffusion_filter(const cv::Mat &m, cv::Mat &result, double beta, double pixelsize, unsigned int time_steps)
void do_segmentation(const cv::Mat &m, cv::Mat &result, const SegmentationParameters ¶ms)
Segmentation of images.
double get_overlap_percentage(cv::Mat &m1, cv::Mat &m2, const IntPair ¢er)
void apply_variance_filter(const cv::Mat &input, cv::Mat &filtered, int kernelsize)
void get_diffusion_filtering_partial_derivative(const cv::Mat &m, cv::Mat &der, double dx, double dy, double ang)
void add_noise(cv::Mat &v, double op1, double op2, const String &mode="uniform", double df=3)
Add noise to the values of a matrix.
void do_remove_small_objects(cvIntMat &m, double percentage, int background=0, int foreground=1)
Removes small objects from a matrix of integers.
DensityMap * get_transformed(const DensityMap *input, const algebra::Transformation3D &tr, double threshold)
Return a new density map containing a rotated version of the old one.
void do_morphologic_reconstruction(const cv::Mat &mask, cv::Mat &marker, int neighbors_mode=4)
morphologic grayscale reconstruction (L Vincent, 1993)
std::string String
Basic string value.