8 #ifndef IMPEM2D_IMAGE_PROCESSING_H
9 #define IMPEM2D_IMAGE_PROCESSING_H
11 #include <IMP/em2d/em2d_config.h>
17 #include <cereal/access.hpp>
19 IMPEM2D_BEGIN_NAMESPACE
24 friend class cereal::access;
26 template<
class Archive>
void serialize(Archive &ar) {
27 ar(image_pixel_size, diffusion_beta, diffusion_timesteps,
28 fill_holes_stddevs, opening_kernel, remove_sizing_percentage,
29 binary_background, binary_foreground, threshold);
33 double image_pixel_size;
34 double diffusion_beta;
35 double diffusion_timesteps;
36 double fill_holes_stddevs;
37 cv::Mat opening_kernel;
38 double remove_sizing_percentage;
39 int binary_background;
40 int binary_foreground;
44 : image_pixel_size(1),
46 diffusion_timesteps(200),
47 fill_holes_stddevs(1.0),
48 remove_sizing_percentage(0.1),
52 opening_kernel = cv::Mat::ones(3, 3, CV_64FC1);
56 unsigned int diff_timesteps,
double fh_stddevs,
57 const cv::Mat &kr,
int background,
int foreground)
58 : image_pixel_size(apix),
59 diffusion_beta(diff_beta),
60 diffusion_timesteps(diff_timesteps),
61 fill_holes_stddevs(fh_stddevs),
63 binary_background(background),
64 binary_foreground(foreground) {};
66 void show(std::ostream &out = std::cout)
const {
67 out <<
"Diffusion parameters: " << std::endl;
68 out <<
"image_pixel_size " << image_pixel_size << std::endl;
69 out <<
"diffusion_beta " << diffusion_beta << std::endl;
70 out <<
"diffusion_timesteps " << diffusion_timesteps << std::endl;
71 out <<
"fill_holes_stddevs " << fill_holes_stddevs << std::endl;
72 out <<
"Opening kernel " << opening_kernel.rows <<
"x"
73 << opening_kernel.cols << std::endl;
74 out <<
"binary_background " << binary_background << std::endl;
75 out <<
"binary_foreground " << binary_foreground << std::endl;
86 double cross_correlation;
91 void show(std::ostream &out = std::cout)
const {
92 out <<
"MatchTemplateResult: Pair (" << pair.first <<
"," << pair.second
93 <<
") ccc = " << cross_correlation << std::endl;
96 friend class cereal::access;
98 template<
class Archive>
void serialize(Archive &ar) {
99 ar(pair.first, pair.second, cross_correlation);
112 IMPEM2DEXPORT
void apply_mask(
const cv::Mat &m, cv::Mat &result,
113 const cvIntMat &mask,
double val);
118 int radius,
double value = 0.0);
125 IMPEM2DEXPORT
double get_mean(
const cv::Mat &mat,
const cvIntMat &mask);
148 IMPEM2DEXPORT
void do_histogram_stretching(cv::Mat &m,
int boxes,
int offset);
158 const cv::Mat &grayscale,
171 int neighbors_mode = 4);
180 IMPEM2DEXPORT
int do_labeling(
const cvIntMat &m, cvIntMat &mat_to_label);
199 double beta,
double pixelsize,
200 unsigned int time_steps);
212 const cv::Mat &m, cv::Mat &der,
double dx,
double dy,
double ang);
221 IMPEM2DEXPORT
void do_fill_holes(
const cv::Mat &m, cv::Mat &result,
double h);
230 IMPEM2DEXPORT
void get_domes(cv::Mat &m, cv::Mat &result,
double h);
244 double threshold = 0.0);
263 cv::Mat &filtered,
int kernelsize);
282 IMPEM2DEXPORT
void add_noise(cv::Mat &v,
double op1,
double op2,
283 const String &mode =
"uniform",
double df = 3);
295 const cv::Mat &input, cv::Mat &resampled,
304 IMPEM2DEXPORT
void get_transformed(
const cv::Mat &input, cv::Mat &transformed,
319 double threshold = 0.0);
331 const cv::Mat &kernel,
332 unsigned int iterations);
339 const cv::Mat &kernel);
353 const IntPair ¢er);
370 IMPEM2DEXPORT cv::Mat
crop(
const cv::Mat &m,
const IntPair ¢er,
int size);
372 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-2022 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-2022 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.