Skip to content

Commit 6c97356

Browse files
committed
Adaptive SSAA
1 parent 7ad853c commit 6c97356

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl App {
3737
let volume = utils::brain_volume::BrainVolume::from_nifti(file_path).unwrap();
3838
let intensity_range = volume.intensity_range;
3939
let middle_slice = volume.world_bounds.center().into_iter().collect();
40-
let increment = volume.world_bounds.size().minmax2().0 / 24.0;
40+
let increment = volume.world_bounds.size().minmax2().0 / 32.0;
4141
let metadata = utils::metadata::make_metadata_key_value_list(&volume.header);
4242
let duration = start.elapsed();
4343

src/widgets/slice_widget.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,25 @@ impl tui::widgets::Widget for SliceWidget<'_> {
125125
),
126126
_ => (0.0, 0.0, 0.0, 0.0),
127127
};
128+
let world_h = world_h_max - world_h_min;
129+
let world_v = world_v_max - world_v_min;
128130

129131
let screen_width: usize = text_area.width as usize;
130132
let screen_height: usize = text_area.height as usize * 2;
131133

132134
let (sampling_width, sampling_height) = fit_relative(
133-
world_h_max - world_h_min,
134-
world_v_max - world_v_min,
135+
world_h,
136+
world_v,
135137
screen_width as f64,
136138
screen_height as f64
137139
);
138140

139141
let (index, x_index, y_index) = self.slice.position_2d(self.axis);
140142

141-
let ssaa_factor = 2;
143+
let sampling_max = std::cmp::min(sampling_width as usize, sampling_height as usize);
144+
let data_max = std::cmp::max(self.volume.local_bounds.xd as usize, self.volume.local_bounds.yd as usize);
145+
let downscale_factor = (data_max as f64 / sampling_max as f64).ceil() as usize;
146+
let ssaa_factor = std::cmp::min(std::cmp::max(1, downscale_factor), 16);
142147

143148
let sample = utils::slice_cache::CachableSlicerParams::new(
144149
utils::sampling::SliceAxis::from_index(self.axis),

0 commit comments

Comments
 (0)