提交 38d2e8d6 编写于 作者: L linshuliang 提交者: wuzewu

Fix the problem of image normalizaiton (#546)

上级 43f1c770
...@@ -272,7 +272,7 @@ ImageReader::ImageRecord ImageReader::record(int offset, int index) { ...@@ -272,7 +272,7 @@ ImageReader::ImageRecord ImageReader::record(int offset, int index) {
std::transform(brcd.data.begin(), std::transform(brcd.data.begin(),
brcd.data.end(), brcd.data.end(),
std::back_inserter(res.data), std::back_inserter(res.data),
[](byte_t i) { return (int)(i); }); [](byte_t i) { return (uint8_t)(i); });
res.shape = entry.GetMulti<shape_t>(); res.shape = entry.GetMulti<shape_t>();
res.step_id = record.id(); res.step_id = record.id();
return res; return res;
......
...@@ -78,6 +78,7 @@ static void NormalizeImage(Uint8Image* image, ...@@ -78,6 +78,7 @@ static void NormalizeImage(Uint8Image* image,
if (image_min < 0) { if (image_min < 0) {
float max_val = std::max(std::abs(image_min), image_max); float max_val = std::max(std::abs(image_min), image_max);
scale = (max_val < kZeroThreshold ? 0.0f : 127.0f) / max_val; scale = (max_val < kZeroThreshold ? 0.0f : 127.0f) / max_val;
offset = 127.0f;
} else { } else {
scale = (image_max < kZeroThreshold ? 0.0f : 255.0f) / image_max; scale = (image_max < kZeroThreshold ? 0.0f : 255.0f) / image_max;
offset = 0.0f; offset = 0.0f;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册