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;
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 = DoubleMatrix::Ones(3, 3);
56 unsigned int diff_timesteps,
double fh_stddevs,
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);
118 IMPEM2D_DEPRECATED_FUNCTION_DECL(2.26)
121 int radius,
double value = 0.0);
152 IMPEM2D_DEPRECATED_FUNCTION_DECL(2.26)
164 IMPEM2D_DEPRECATED_FUNCTION_DECL(2.26)
179 int neighbors_mode = 4);
208 double beta,
double pixelsize,
209 unsigned int time_steps);
241 IMPEM2D_DEPRECATED_FUNCTION_DECL(2.26)
256 double threshold = 0.0);
296 const
String &mode = "uniform",
double df = 3);
319 const algebra::Transformation2D &T);
333 double threshold = 0.0);
344 IMPEM2D_DEPRECATED_FUNCTION_DECL(2.26)
347 unsigned int iterations);
354 IMPEM2D_DEPRECATED_FUNCTION_DECL(2.26)
371 IMPEM2D_DEPRECATED_FUNCTION_DECL(2.26)
373 const IntPair ¢er);
393 IMPEM2D_END_NAMESPACE
void do_dilate_and_shrink_warp(DoubleMatrix &m, const DoubleMatrix &grayscale, DoubleMatrix &kernel)
(U. Adiga, 2005)
Floats get_histogram(const DoubleMatrix &m, int bins)
Computes the histogram of a matrix.
void do_combined_fill_holes_and_threshold(DoubleMatrix &m, DoubleMatrix &result, double n_stddevs, double threshold=0.0)
Combines the fill holes and thresholding operations together with normalize.
void get_morphologic_gradient(const DoubleMatrix &m, DoubleMatrix &result, const DoubleMatrix &kernel)
void do_segmentation(const DoubleMatrix &m, DoubleMatrix &result, const SegmentationParameters ¶ms)
Segmentation of images.
DoubleMatrix crop(const DoubleMatrix &m, const IntPair ¢er, int size)
Class to provide all the parameters to the segmentation function.
void apply_mask(const DoubleMatrix &m, DoubleMatrix &result, const IntMatrix &mask, double val)
Applies a binary mask to an image.
IntMatrix create_circular_mask(int rows, int cols, int radius)
void do_histogram_stretching(DoubleMatrix &m, int boxes, int offset)
void do_extend_borders(const DoubleMatrix &orig, DoubleMatrix &dst, unsigned int pix)
void do_resample_polar(const DoubleMatrix &input, DoubleMatrix &resampled, const PolarResamplingParameters &polar_params)
Resamples a matrix to polar coordinates.
A more IMP-like version of the std::vector.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
void get_domes(DoubleMatrix &m, DoubleMatrix &result, double h)
Gets the domes of m with height h.
void do_morphologic_reconstruction(const DoubleMatrix &mask, DoubleMatrix &marker, int neighbors_mode=4)
morphologic grayscale reconstruction (L Vincent, 1993)
double get_mean(const DoubleMatrix &mat, const IntMatrix &mask)
void apply_diffusion_filter(const DoubleMatrix &m, DoubleMatrix &result, double beta, double pixelsize, unsigned int time_steps)
void do_normalize(DoubleMatrix &m)
Normalize a matrix to mean 0 and stddev 1. It is done in place.
void apply_threshold(DoubleMatrix &m, DoubleMatrix &result, double threshold=0.0)
MatchTemplateResults get_best_template_matches(const DoubleMatrix &m, const DoubleMatrix &templ, unsigned int n)
Matrices used to store image data Copyright 2007-2026 IMP Inventors. All rights reserved.
Functions related with rotations in em2d Copyright 2007-2026 IMP Inventors. All rights reserved...
void do_remove_small_objects(IntMatrix &m, double percentage, int background=0, int foreground=1)
Removes small objects from a matrix of integers.
void get_diffusion_filtering_partial_derivative(const DoubleMatrix &m, DoubleMatrix &der, double dx, double dy, double ang)
void apply_circular_mask(const DoubleMatrix &mat, DoubleMatrix &result, int radius, double value=0.0)
int do_labeling(const IntMatrix &m, IntMatrix &mat_to_label)
Labeling function for a matrix.
void apply_variance_filter(const DoubleMatrix &input, DoubleMatrix &filtered, int kernelsize)
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node.
void do_morphologic_contrast_enhancement(const DoubleMatrix &m, DoubleMatrix &result, const DoubleMatrix &kernel, unsigned int iterations)
void do_fill_holes(const DoubleMatrix &m, DoubleMatrix &result, double h)
Fills the holes in the matrix m of height h.
Eigen::Array< int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > IntMatrix
Matrix of ints, used for masks and labels.
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.
Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > DoubleMatrix
Matrix of doubles, used to store the data of an image.
double get_overlap_percentage(DoubleMatrix &m1, DoubleMatrix &m2, const IntPair ¢er)
void add_noise(DoubleMatrix &v, double op1, double op2, const String &mode="uniform", double df=3)
Add noise to the values of a matrix.
std::string String
Basic string value.