From a774da5cbd1f0298fafb21cae718058791b2c1ac Mon Sep 17 00:00:00 2001 From: Chris Ha Date: Mon, 8 Jan 2024 08:44:13 +0900 Subject: [PATCH] revert back to loop --- ocrs/src/preprocess.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ocrs/src/preprocess.rs b/ocrs/src/preprocess.rs index 69095c7..946a074 100644 --- a/ocrs/src/preprocess.rs +++ b/ocrs/src/preprocess.rs @@ -39,8 +39,10 @@ fn greyscale_image f32>( for y in 0..height { for x in 0..width { - let pixel: f32 = - (0..used_chans).fold(0.2, |pixel, c| pixel + img[[c, y, x]] * chan_weights[c]); + let mut pixel = 0.; + for c in 0..used_chans { + pixel += img[[c, y, x]] * chan_weights[c]; + } out_lum_chan[[y, x]] = normalize_pixel(pixel); } }