pub struct ShapeEncoding {
pub seq: Vec<BitVec>,
}Fields§
§seq: Vec<BitVec>Implementations§
Source§impl ShapeEncoding
impl ShapeEncoding
pub fn encode_as_shape_encoding(sampler: &impl Sampler) -> ShapeEncoding
pub fn encode_binary_image(image: &BinaryImage) -> ShapeEncodingString
pub fn encode_binary_image_as_hex_encoding( image: &BinaryImage, ) -> (ShapeEncodingString, usize)
pub fn encode_binary_image_as_shape_encoding( image: &BinaryImage, ) -> (ShapeEncoding, usize)
Sourcepub fn encode_grayscale_image_as_shape_encoding_and_size(
image: &ColorImage,
) -> (ShapeEncoding, usize)
pub fn encode_grayscale_image_as_shape_encoding_and_size( image: &ColorImage, ) -> (ShapeEncoding, usize)
Encode a ColorImage using the red channel as grayscale.
Assume shape is black-on-white, and uses the full u8 value range. So black (r=0) means 100% occupancy a pixel.
Sourcepub fn decode_from(shape_string: &ShapeEncodingString) -> Shape
pub fn decode_from(shape_string: &ShapeEncodingString) -> Shape
decode shape from hexstring
pub fn bits_to_binary_image(bits: &BitVec) -> BinaryImage
pub fn bits_to_binary_image_with_limit( bits: &BitVec, limit: usize, ) -> BinaryImage
pub fn bits(&self) -> BitVec
pub fn bitstring(&self) -> ShapeEncodingString
pub fn hexstring(&self) -> ShapeEncodingString
Sourcepub fn hexstring_trim(&self) -> ShapeEncodingString
pub fn hexstring_trim(&self) -> ShapeEncodingString
because hexstring may contain trailing 0s, trimming the last 4 bits would yield better prefix match
pub fn hexstring_to_bits(string: &str) -> BitVec
pub fn hexstring_to_bits_length(hexstring_len: usize) -> usize
pub fn bitstring_to_bits(string: &str) -> BitVec
pub fn bits_to_bitstring(bits: &BitVec) -> String
pub fn bits_to_hexstring(bits: &BitVec) -> String
pub fn pow_of_two(n: usize) -> usize
pub fn pow_of_four(n: usize) -> usize
pub fn is_pow_of_four(n: usize) -> bool
pub fn next_pow_of_four(n: usize) -> usize
pub fn layer_from_area(n: usize) -> usize
pub fn length_from_area(n: usize) -> usize
pub fn length_from_size(n: usize) -> usize
pub fn area_from_length(length: usize) -> usize
pub fn size_from_length(length: usize) -> usize
Sourcepub fn length(&self) -> usize
pub fn length(&self) -> usize
length of the shape encoding guaranteed to be smaller than (not equal to) 2*size^2
pub fn shape_encoding_diff( me: &ShapeEncodingString, other: &ShapeEncodingString, ) -> u64
Sourcepub fn shape_encoding_diff_bits(a: &BitVec, b: &BitVec) -> u64
pub fn shape_encoding_diff_bits(a: &BitVec, b: &BitVec) -> u64
Almost like humming distance between the two bit strings, but more significant bits have higher weights
Sourcepub fn shape_encoding_diff_layer(a: &BitVec, b: &BitVec, layer: usize) -> u64
pub fn shape_encoding_diff_layer(a: &BitVec, b: &BitVec, layer: usize) -> u64
Returns the weighted diff contribution of a single layer.
layer is 0-indexed: 0 = coarsest (1 bit), 1 = 4 bits, 2 = 16 bits, …
Summing all layers equals shape_encoding_diff_bits.
Sourcepub fn layer_shift(l: usize) -> u32
pub fn layer_shift(l: usize) -> u32
The bit-shift weight for the layer whose area is l (must be a power of 4).
Sourcepub fn num_layers(encoder_size: usize) -> usize
pub fn num_layers(encoder_size: usize) -> usize
Number of encoding layers for the given encoder size (power-of-4 area).
Trait Implementations§
Source§impl Default for ShapeEncoding
impl Default for ShapeEncoding
Source§fn default() -> ShapeEncoding
fn default() -> ShapeEncoding
Auto Trait Implementations§
impl Freeze for ShapeEncoding
impl RefUnwindSafe for ShapeEncoding
impl Send for ShapeEncoding
impl Sync for ShapeEncoding
impl Unpin for ShapeEncoding
impl UnsafeUnpin for ShapeEncoding
impl UnwindSafe for ShapeEncoding
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
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> ⓘ
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> ⓘ
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