pub struct PatchExtractor { /* private fields */ }Expand description
Patch Extractor with Builder Pattern
A configurable patch extractor that provides a clean interface for patch extraction with various sampling strategies and optimization options.
§Builder Pattern
The extractor uses the builder pattern for clean configuration:
- Chainable method calls for easy setup
- Sensible defaults for quick usage
- Comprehensive validation of parameters
§Configuration Options
- Patch Size: Dimensions of extracted patches
- Max Patches: Limit on number of patches to extract
- Random State: Seed for reproducible random sampling
- Sampling Strategy: How to select patch positions
§Examples
use sklears_feature_extraction::image::patch_extraction::PatchExtractor;
use scirs2_core::ndarray::Array2;
let image = Array2::from_shape_vec((10, 10), (0..100).map(|x| x as f64).collect()).expect("shape and data length match");
let extractor = PatchExtractor::new()
.patch_size((3, 3))
.max_patches(Some(10))
.random_state(Some(42));
let patches = extractor.extract(&image.view()).expect("valid image and extractor config produce patches");Implementations§
Source§impl PatchExtractor
impl PatchExtractor
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new PatchExtractor with default settings
Default configuration:
- Patch size: 8x8 pixels
- Max patches: None (extract all)
- Random state: None (non-deterministic)
- Sampling: UniformGrid
Sourcepub fn patch_size(self, patch_size: (usize, usize)) -> Self
pub fn patch_size(self, patch_size: (usize, usize)) -> Self
Sourcepub fn max_patches(self, max_patches: Option<usize>) -> Self
pub fn max_patches(self, max_patches: Option<usize>) -> Self
Set the maximum number of patches to extract
§Parameters
max_patches- Maximum patches (None for all possible)
Sourcepub fn random_state(self, random_state: Option<u64>) -> Self
pub fn random_state(self, random_state: Option<u64>) -> Self
Set the random state for reproducible sampling
§Parameters
random_state- Random seed (None for non-deterministic)
Sourcepub fn sampling_strategy(self, strategy: SamplingStrategy) -> Self
pub fn sampling_strategy(self, strategy: SamplingStrategy) -> Self
Trait Implementations§
Source§impl Clone for PatchExtractor
impl Clone for PatchExtractor
Source§impl Debug for PatchExtractor
impl Debug for PatchExtractor
Auto Trait Implementations§
impl Freeze for PatchExtractor
impl RefUnwindSafe for PatchExtractor
impl Send for PatchExtractor
impl Sync for PatchExtractor
impl Unpin for PatchExtractor
impl UnsafeUnpin for PatchExtractor
impl UnwindSafe for PatchExtractor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more