Trait opencv::prelude::PCTSignatures
source · pub trait PCTSignatures: AlgorithmTrait + PCTSignaturesConst {
Show 22 methods
// Required method
fn as_raw_mut_PCTSignatures(&mut self) -> *mut c_void;
// Provided methods
fn set_grayscale_bits(&mut self, grayscale_bits: i32) -> Result<()> { ... }
fn set_window_radius(&mut self, radius: i32) -> Result<()> { ... }
fn set_weight_x(&mut self, weight: f32) -> Result<()> { ... }
fn set_weight_y(&mut self, weight: f32) -> Result<()> { ... }
fn set_weight_l(&mut self, weight: f32) -> Result<()> { ... }
fn set_weight_a(&mut self, weight: f32) -> Result<()> { ... }
fn set_weight_b(&mut self, weight: f32) -> Result<()> { ... }
fn set_weight_contrast(&mut self, weight: f32) -> Result<()> { ... }
fn set_weight_entropy(&mut self, weight: f32) -> Result<()> { ... }
fn set_weight(&mut self, idx: i32, value: f32) -> Result<()> { ... }
fn set_weights(&mut self, weights: &Vector<f32>) -> Result<()> { ... }
fn set_translation(&mut self, idx: i32, value: f32) -> Result<()> { ... }
fn set_translations(&mut self, translations: &Vector<f32>) -> Result<()> { ... }
fn set_sampling_points(
&mut self,
sampling_points: Vector<Point2f>
) -> Result<()> { ... }
fn set_init_seed_indexes(
&mut self,
init_seed_indexes: Vector<i32>
) -> Result<()> { ... }
fn set_iteration_count(&mut self, iteration_count: i32) -> Result<()> { ... }
fn set_max_clusters_count(&mut self, max_clusters_count: i32) -> Result<()> { ... }
fn set_cluster_min_size(&mut self, cluster_min_size: i32) -> Result<()> { ... }
fn set_joining_distance(&mut self, joining_distance: f32) -> Result<()> { ... }
fn set_drop_threshold(&mut self, drop_threshold: f32) -> Result<()> { ... }
fn set_distance_function(&mut self, distance_function: i32) -> Result<()> { ... }
}
Expand description
Class implementing PCT (position-color-texture) signature extraction as described in KrulisLS16. The algorithm is divided to a feature sampler and a clusterizer. Feature sampler produces samples at given set of coordinates. Clusterizer then produces clusters of these samples using k-means algorithm. Resulting set of clusters is the signature of the input image.
A signature is an array of SIGNATURE_DIMENSION-dimensional points.
Used dimensions are:
weight, x, y position; lab color, contrast, entropy.
Required Methods§
fn as_raw_mut_PCTSignatures(&mut self) -> *mut c_void
Provided Methods§
sourcefn set_grayscale_bits(&mut self, grayscale_bits: i32) -> Result<()>
fn set_grayscale_bits(&mut self, grayscale_bits: i32) -> Result<()>
Color resolution of the greyscale bitmap represented in allocated bits (i.e., value 4 means that 16 shades of grey are used). The greyscale bitmap is used for computing contrast and entropy values.
sourcefn set_window_radius(&mut self, radius: i32) -> Result<()>
fn set_window_radius(&mut self, radius: i32) -> Result<()>
Size of the texture sampling window used to compute contrast and entropy (center of the window is always in the pixel selected by x,y coordinates of the corresponding feature sample).
sourcefn set_weight_x(&mut self, weight: f32) -> Result<()>
fn set_weight_x(&mut self, weight: f32) -> Result<()>
Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)
sourcefn set_weight_y(&mut self, weight: f32) -> Result<()>
fn set_weight_y(&mut self, weight: f32) -> Result<()>
Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)
sourcefn set_weight_l(&mut self, weight: f32) -> Result<()>
fn set_weight_l(&mut self, weight: f32) -> Result<()>
Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)
sourcefn set_weight_a(&mut self, weight: f32) -> Result<()>
fn set_weight_a(&mut self, weight: f32) -> Result<()>
Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)
sourcefn set_weight_b(&mut self, weight: f32) -> Result<()>
fn set_weight_b(&mut self, weight: f32) -> Result<()>
Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)
sourcefn set_weight_contrast(&mut self, weight: f32) -> Result<()>
fn set_weight_contrast(&mut self, weight: f32) -> Result<()>
Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)
sourcefn set_weight_entropy(&mut self, weight: f32) -> Result<()>
fn set_weight_entropy(&mut self, weight: f32) -> Result<()>
Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)
sourcefn set_weight(&mut self, idx: i32, value: f32) -> Result<()>
fn set_weight(&mut self, idx: i32, value: f32) -> Result<()>
Weights (multiplicative constants) that linearly stretch individual axes of the feature space.
Parameters
- idx: ID of the weight
- value: Value of the weight
Note: WEIGHT_IDX = 0; X_IDX = 1; Y_IDX = 2; L_IDX = 3; A_IDX = 4; B_IDX = 5; CONTRAST_IDX = 6; ENTROPY_IDX = 7;
sourcefn set_weights(&mut self, weights: &Vector<f32>) -> Result<()>
fn set_weights(&mut self, weights: &Vector<f32>) -> Result<()>
Weights (multiplicative constants) that linearly stretch individual axes of the feature space.
Parameters
- weights: Values of all weights.
Note: WEIGHT_IDX = 0; X_IDX = 1; Y_IDX = 2; L_IDX = 3; A_IDX = 4; B_IDX = 5; CONTRAST_IDX = 6; ENTROPY_IDX = 7;
sourcefn set_translation(&mut self, idx: i32, value: f32) -> Result<()>
fn set_translation(&mut self, idx: i32, value: f32) -> Result<()>
Translations of the individual axes of the feature space.
Parameters
- idx: ID of the translation
- value: Value of the translation
Note: WEIGHT_IDX = 0; X_IDX = 1; Y_IDX = 2; L_IDX = 3; A_IDX = 4; B_IDX = 5; CONTRAST_IDX = 6; ENTROPY_IDX = 7;
sourcefn set_translations(&mut self, translations: &Vector<f32>) -> Result<()>
fn set_translations(&mut self, translations: &Vector<f32>) -> Result<()>
Translations of the individual axes of the feature space.
Parameters
- translations: Values of all translations.
Note: WEIGHT_IDX = 0; X_IDX = 1; Y_IDX = 2; L_IDX = 3; A_IDX = 4; B_IDX = 5; CONTRAST_IDX = 6; ENTROPY_IDX = 7;
sourcefn set_sampling_points(
&mut self,
sampling_points: Vector<Point2f>
) -> Result<()>
fn set_sampling_points( &mut self, sampling_points: Vector<Point2f> ) -> Result<()>
Sets sampling points used to sample the input image.
Parameters
- samplingPoints: Vector of sampling points in range [0..1)
Note: Number of sampling points must be greater or equal to clusterization seed count.
sourcefn set_init_seed_indexes(
&mut self,
init_seed_indexes: Vector<i32>
) -> Result<()>
fn set_init_seed_indexes( &mut self, init_seed_indexes: Vector<i32> ) -> Result<()>
Initial seed indexes for the k-means algorithm.
sourcefn set_iteration_count(&mut self, iteration_count: i32) -> Result<()>
fn set_iteration_count(&mut self, iteration_count: i32) -> Result<()>
Number of iterations of the k-means clustering. We use fixed number of iterations, since the modified clustering is pruning clusters (not iteratively refining k clusters).
sourcefn set_max_clusters_count(&mut self, max_clusters_count: i32) -> Result<()>
fn set_max_clusters_count(&mut self, max_clusters_count: i32) -> Result<()>
Maximal number of generated clusters. If the number is exceeded, the clusters are sorted by their weights and the smallest clusters are cropped.
sourcefn set_cluster_min_size(&mut self, cluster_min_size: i32) -> Result<()>
fn set_cluster_min_size(&mut self, cluster_min_size: i32) -> Result<()>
This parameter multiplied by the index of iteration gives lower limit for cluster size. Clusters containing fewer points than specified by the limit have their centroid dismissed and points are reassigned.
sourcefn set_joining_distance(&mut self, joining_distance: f32) -> Result<()>
fn set_joining_distance(&mut self, joining_distance: f32) -> Result<()>
Threshold euclidean distance between two centroids. If two cluster centers are closer than this distance, one of the centroid is dismissed and points are reassigned.
sourcefn set_drop_threshold(&mut self, drop_threshold: f32) -> Result<()>
fn set_drop_threshold(&mut self, drop_threshold: f32) -> Result<()>
Remove centroids in k-means whose weight is lesser or equal to given threshold.
sourcefn set_distance_function(&mut self, distance_function: i32) -> Result<()>
fn set_distance_function(&mut self, distance_function: i32) -> Result<()>
Distance function selector used for measuring distance between two points in k-means. Available: L0_25, L0_5, L1, L2, L2SQUARED, L5, L_INFINITY.
Implementations§
source§impl dyn PCTSignatures + '_
impl dyn PCTSignatures + '_
sourcepub fn create(
init_sample_count: i32,
init_seed_count: i32,
point_distribution: i32
) -> Result<Ptr<dyn PCTSignatures>>
pub fn create( init_sample_count: i32, init_seed_count: i32, point_distribution: i32 ) -> Result<Ptr<dyn PCTSignatures>>
Creates PCTSignatures algorithm using sample and seed count. It generates its own sets of sampling points and clusterization seed indexes.
Parameters
- initSampleCount: Number of points used for image sampling.
- initSeedCount: Number of initial clusterization seeds. Must be lower or equal to initSampleCount
- pointDistribution: Distribution of generated points. Default: UNIFORM. Available: UNIFORM, REGULAR, NORMAL.
Returns
Created algorithm.
C++ default parameters
- init_sample_count: 2000
- init_seed_count: 400
- point_distribution: 0
sourcepub fn create_1(
init_sampling_points: &Vector<Point2f>,
init_seed_count: i32
) -> Result<Ptr<dyn PCTSignatures>>
pub fn create_1( init_sampling_points: &Vector<Point2f>, init_seed_count: i32 ) -> Result<Ptr<dyn PCTSignatures>>
Creates PCTSignatures algorithm using pre-generated sampling points and number of clusterization seeds. It uses the provided sampling points and generates its own clusterization seed indexes.
Parameters
- initSamplingPoints: Sampling points used in image sampling.
- initSeedCount: Number of initial clusterization seeds. Must be lower or equal to initSamplingPoints.size().
Returns
Created algorithm.
sourcepub fn create_2(
init_sampling_points: &Vector<Point2f>,
init_cluster_seed_indexes: &Vector<i32>
) -> Result<Ptr<dyn PCTSignatures>>
pub fn create_2( init_sampling_points: &Vector<Point2f>, init_cluster_seed_indexes: &Vector<i32> ) -> Result<Ptr<dyn PCTSignatures>>
Creates PCTSignatures algorithm using pre-generated sampling points and clusterization seeds indexes.
Parameters
- initSamplingPoints: Sampling points used in image sampling.
- initClusterSeedIndexes: Indexes of initial clusterization seeds. Its size must be lower or equal to initSamplingPoints.size().
Returns
Created algorithm.
sourcepub fn draw_signature(
source: &dyn ToInputArray,
signature: &dyn ToInputArray,
result: &mut dyn ToOutputArray,
radius_to_shorter_side_ratio: f32,
border_thickness: i32
) -> Result<()>
pub fn draw_signature( source: &dyn ToInputArray, signature: &dyn ToInputArray, result: &mut dyn ToOutputArray, radius_to_shorter_side_ratio: f32, border_thickness: i32 ) -> Result<()>
Draws signature in the source image and outputs the result. Signatures are visualized as a circle with radius based on signature weight and color based on signature color. Contrast and entropy are not visualized.
Parameters
- source: Source image.
- signature: Image signature.
- result: Output result.
- radiusToShorterSideRatio: Determines maximal radius of signature in the output image.
- borderThickness: Border thickness of the visualized signature.
C++ default parameters
- radius_to_shorter_side_ratio: 1.0/8
- border_thickness: 1
sourcepub fn generate_init_points(
init_points: &mut Vector<Point2f>,
count: i32,
point_distribution: i32
) -> Result<()>
pub fn generate_init_points( init_points: &mut Vector<Point2f>, count: i32, point_distribution: i32 ) -> Result<()>
Generates initial sampling points according to selected point distribution.
Parameters
- initPoints: Output vector where the generated points will be saved.
- count: Number of points to generate.
- pointDistribution: Point distribution selector. Available: UNIFORM, REGULAR, NORMAL.
Note: Generated coordinates are in range [0..1)