in rustface/src/feat/surf_mlp_featmap.rs [541:597]
fn create(&mut self) {
let mut feature_vecs = Vec::new();
if self.sample_height - self.patch_min_height <= self.sample_width - self.patch_min_width {
for format in &self.patch_formats {
for h in Seq::new(self.patch_min_height, |x| x + self.patch_size_inc_step)
.take_while(|x| *x <= self.sample_height)
{
if h % format.num_cell_per_col != 0 || h % format.height != 0 {
continue;
}
let w = h / format.height * format.width;
if w % format.num_cell_per_row != 0
|| w < self.patch_min_width
|| w > self.sample_width
{
continue;
}
self.collect_features(
w,
h,
format.num_cell_per_row,
format.num_cell_per_col,
&mut feature_vecs,
);
}
}
} else {
for format in &self.patch_formats {
// original condition was <= self.patch_min_width,
// but it would not make sense to have a loop in such case
for w in Seq::new(self.patch_min_width, |x| x + self.patch_size_inc_step)
.take_while(|x| *x <= self.sample_width)
{
if w % format.num_cell_per_row != 0 || w % format.width != 0 {
continue;
}
let h = w / format.width * format.height;
if h % format.num_cell_per_col != 0
|| h < self.patch_min_height
|| h > self.sample_height
{
continue;
}
self.collect_features(
w,
h,
format.num_cell_per_row,
format.num_cell_per_col,
&mut feature_vecs,
);
}
}
}
self.features.append(&mut feature_vecs);
}