-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d486cd
commit 09014a2
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# MipMap-1d | ||
|
||
This Rust crate provides a small data structure that constructs and holds your 1-dimensional mipmaps. | ||
MipMaps are just downsampled versions of your vector. | ||
Each level is only half the size of a previous level. | ||
Therefore, the entire data structure takes approximately 2x the size of initial data in memory. | ||
|
||
The downsampling is currently performed by averaging the pairs of elements (see example below). | ||
New ways might be introduced in later versions. | ||
|
||
The crate currently works with all major numeric types (thanks to `num-traits` crate). | ||
|
||
This can be used, for example, in plots. | ||
If you have a large number of points (lets say, 10M), you clearly can not draw them all on the screen at once. | ||
Also, drawing so many requires a lot of computational resources. | ||
|
||
What you can do is to use 1d MipMap: you make several downsamples, and choose which one you want to display depending on a zoom level. | ||
The more you zoom in, the 'higher resolution' data you display. | ||
|
||
## Example | ||
|
||
```rust | ||
use mipmap_1d::MipMap1D; | ||
|
||
let data = vec![2, 4, 6, 8, 9]; | ||
let mipmap = MipMap1D::new(data); | ||
assert_eq!(mipmap.num_levels(), 4); | ||
assert_eq!(*mipmap.get_level(0).unwrap(), [2, 4, 6, 8, 9]); | ||
assert_eq!(*mipmap.get_level(1).unwrap(), [3, 7, 9]); | ||
assert_eq!(*mipmap.get_level(2).unwrap(), [5, 9]); | ||
assert_eq!(*mipmap.get_level(3).unwrap(), [7]); | ||
assert_eq!(mipmap.get_level(4), None); | ||
``` | ||
|
||
## Contributing | ||
|
||
Currently, the only idea for improvement is to introduce new averaging methods that are used in signal processing. | ||
Check issue #1 for details. |