- change to MIT license

- change XY to YX in python tiffwrite.tiffwrite
This commit is contained in:
Wim Pomp
2025-02-19 20:41:28 +01:00
parent 8f4a506d45
commit 9ee8fc1029
7 changed files with 97 additions and 717 deletions

View File

@@ -391,10 +391,6 @@ impl CompressedFrame {
}
}
let mut a = Vec::new();
for i in 0..24 {
a.push(i);
}
let bytes: Vec<_> = if slices.len() > 4 {
slices
.into_par_iter()
@@ -923,3 +919,50 @@ impl IJTiffFile {
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
use ndarray::Array2;
#[test]
/// An example of generating julia fractals.
fn julia_test() -> Result<()> {
let imgx = 800;
let imgy = 600;
let scalex = 3.0 / imgx as f32;
let scaley = 3.0 / imgy as f32;
let mut im_r = Array2::<u8>::zeros((imgy, imgx));
let mut im_g = Array2::<u8>::zeros((imgy, imgx));
let mut im_b = Array2::<u8>::zeros((imgy, imgx));
for x in 0..imgx {
for y in 0..imgy {
im_r[[y, x]] = (0.3 * x as f32) as u8;
im_b[[y, x]] = (0.3 * y as f32) as u8;
let cx = y as f32 * scalex - 1.5;
let cy = x as f32 * scaley - 1.5;
let c = Complex::new(-0.4, 0.6);
let mut z = Complex::new(cx, cy);
let mut i = 0;
while i < 255 && z.norm() <= 2.0 {
z = z * z + c;
i += 1;
}
im_g[[y, x]] = i as u8;
}
}
let mut f = IJTiffFile::new("julia.tif")?;
f.save(&im_r, 0, 0, 0)?;
f.save(&im_g, 1, 0, 0)?;
f.save(&im_b, 2, 0, 0)?;
Ok(())
}
}

View File

@@ -1,23 +0,0 @@
use anyhow::Result;
use ndarray::{s, Array2};
use tiffwrite::IJTiffFile;
fn main() -> Result<()> {
println!("Hello World!");
let mut f = IJTiffFile::new("foo.tif")?;
f.compression_level = 10;
let mut arr = Array2::<u16>::zeros((100, 100));
for i in 0..arr.shape()[0] {
for j in 0..arr.shape()[1] {
arr[[i, j]] = i as u16;
}
}
f.save(arr.view(), 0, 0, 0)?;
let mut arr = Array2::<u16>::zeros((100, 100));
arr.slice_mut(s![64.., ..64]).fill(1);
arr.slice_mut(s![..64, 64..]).fill(2);
arr.slice_mut(s![64.., 64..]).fill(3);
f.save(&arr, 1, 0, 0)?;
Ok(())
}