Skip to main content

scale_to_u8_range

Function scale_to_u8_range 

Source
fn scale_to_u8_range(image: &[f64]) -> Vec<f32>
Expand description

niimath’s voxelIntensityScale (FastSurfer getscale + scalecrop) to [0, 255], with f_low = 0 and f_high = 0.98.

The robust maximum is read from a 1000-bin histogram: the first bin whose cumulative count reaches all voxels but 2 % of the non-zero ones. The minimum is the image minimum (or 0, if fewer than 2 % of voxels are negative). niimath works in f32, and so does this.