| Crates.io | sitk-registration-sys |
| lib.rs | sitk-registration-sys |
| version | 0.2.0 |
| created_at | 2025-03-01 18:55:18.383739+00 |
| updated_at | 2025-09-12 17:16:40.505476+00 |
| description | register and interpolate images |
| homepage | https://github.com/wimpomp/sitk-registration-sys |
| repository | https://github.com/wimpomp/sitk-registration-sys |
| max_upload_size | |
| id | 1573952 |
| size | 7,685,359 |
This crate does two things:
To do this, SimpleITK, which is written in C++, is used. An adapter library is created using autocxx to expose the required functionality in SimpleITK. Because of this, compilation of this crate requires quite some time, several GB of memory, up to 50 GB of hard disk space, as well as cmake, a C++ compiler, llvm and git. Use at your own risk!
use ndarray::Array2;
use sitk_registration_sys::registration::{AffineTransform, julia_image};
let j = julia_image(0f32, 0f32).unwrap();
let shape = j.shape();
let origin = [
((shape[1] - 1) as f64) / 2f64,
((shape[0] - 1) as f64) / 2f64,
];
let s = AffineTransform::new([1.2, 0., 0., 1., 5., 7.], origin, [shape[0], shape[1]]);
let k: Array2<_> = s.transform_image_bspline(j.view()).unwrap().into();
let t = AffineTransform::register_affine(j.view(), k.view()).unwrap().inverse().unwrap();
let d = (t.matrix() - s.matrix()).powi(2).sum();
assert!(d < 0.025, "d: {}, t: {:?}", d, t.parameters);
use ndarray::Array2;
use sitk_registration_sys::registration::{AffineTransform, julia_image};
let j = julia_image(-120f32, 10f32).unwrap();
let k = julia_image(0f32, 0f32).unwrap();
let shape = j.shape();
let origin = [
((shape[1] - 1) as f64) / 2f64,
((shape[0] - 1) as f64) / 2f64,
];
let transform = AffineTransform::new([1., 0., 0., 1., 120., -10.], origin, [shape[0], shape[1]]);
let n: Array2<_> = transform.transform_image_bspline(j.view()).unwrap().into();
let d = (k.mapv(|x| x as f64) - n.mapv(|x| x as f64)).powi(2).sum();
assert!(d <= (shape[0] * shape[1]) as f64);