pub struct WasmImageProcessor;Expand description
WASM bindings for canvas operations
Implementations§
Source§impl WasmImageProcessor
impl WasmImageProcessor
Sourcepub fn create_image_data(
data: &[u8],
width: u32,
height: u32,
) -> Result<ImageData, JsValue>
pub fn create_image_data( data: &[u8], width: u32, height: u32, ) -> Result<ImageData, JsValue>
Creates ImageData from RGBA bytes
Sourcepub fn compute_histogram(
data: &[u8],
width: u32,
height: u32,
) -> Result<String, JsValue>
pub fn compute_histogram( data: &[u8], width: u32, height: u32, ) -> Result<String, JsValue>
Computes histogram as JSON
Returns a comprehensive JSON object containing:
- Image dimensions (width, height, total_pixels)
- Per-channel histograms (red, green, blue, luminance)
- Statistics for each channel (min, max, mean, median, std_dev, count)
- Histogram bins (256 bins for 8-bit values)
§Example JSON Output
{
"width": 256,
"height": 256,
"total_pixels": 65536,
"red": {
"bins": [0, 100, 200, ...],
"min": 0,
"max": 255,
"mean": 127.5,
"median": 128,
"std_dev": 73.9,
"count": 65536
},
"green": { ... },
"blue": { ... },
"luminance": { ... }
}Sourcepub fn compute_histogram_with_bins(
data: &[u8],
width: u32,
height: u32,
bin_edges: &[f64],
) -> Result<String, JsValue>
pub fn compute_histogram_with_bins( data: &[u8], width: u32, height: u32, bin_edges: &[f64], ) -> Result<String, JsValue>
Computes histogram with custom bin ranges
This allows for non-uniform bin widths, useful for specific analysis needs such as focusing on particular value ranges or creating logarithmic bins.
§Arguments
data- RGBA image datawidth- Image widthheight- Image heightbin_edges- Array of bin edge values (n+1 edges for n bins)
§Example
// Create 5 bins: [0-50), [50-100), [100-150), [150-200), [200-256)
const binEdges = [0, 50, 100, 150, 200, 256];
const histogram = WasmImageProcessor.computeHistogramWithBins(data, width, height, binEdges);Sourcepub fn compute_stats(
data: &[u8],
width: u32,
height: u32,
) -> Result<String, JsValue>
pub fn compute_stats( data: &[u8], width: u32, height: u32, ) -> Result<String, JsValue>
Computes statistics as JSON
Trait Implementations§
Source§impl From<WasmImageProcessor> for JsValue
impl From<WasmImageProcessor> for JsValue
Source§fn from(value: WasmImageProcessor) -> Self
fn from(value: WasmImageProcessor) -> Self
Converts to this type from the input type.
Source§impl FromWasmAbi for WasmImageProcessor
impl FromWasmAbi for WasmImageProcessor
Source§impl IntoWasmAbi for WasmImageProcessor
impl IntoWasmAbi for WasmImageProcessor
Source§impl RefFromWasmAbi for WasmImageProcessor
impl RefFromWasmAbi for WasmImageProcessor
Source§type Anchor = RcRef<WasmImageProcessor>
type Anchor = RcRef<WasmImageProcessor>
The type that holds the reference to
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl TryFromJsValue for WasmImageProcessor
impl TryFromJsValue for WasmImageProcessor
Source§impl VectorFromWasmAbi for WasmImageProcessor
impl VectorFromWasmAbi for WasmImageProcessor
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[WasmImageProcessor]>
Source§impl VectorIntoWasmAbi for WasmImageProcessor
impl VectorIntoWasmAbi for WasmImageProcessor
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[WasmImageProcessor]>) -> Self::Abi
Source§impl WasmDescribeVector for WasmImageProcessor
impl WasmDescribeVector for WasmImageProcessor
impl SupportsConstructor for WasmImageProcessor
impl SupportsInstanceProperty for WasmImageProcessor
impl SupportsStaticProperty for WasmImageProcessor
Auto Trait Implementations§
impl Freeze for WasmImageProcessor
impl RefUnwindSafe for WasmImageProcessor
impl Send for WasmImageProcessor
impl Sync for WasmImageProcessor
impl Unpin for WasmImageProcessor
impl UnsafeUnpin for WasmImageProcessor
impl UnwindSafe for WasmImageProcessor
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.