include/cvw/algorithms/normalize.hpp
Min-max normalization algorithm. More...
Namespaces
| Name |
|---|
| cvw |
Detailed Description
Min-max normalization algorithm.
Author: Charliechen114514
Version: 1.0.0
Since: 1.0.0
Date: 2026-05-15
Normalizes a grayscale image to a 32-bit float range.
Source code
cpp
#pragma once
#include "detail.hpp"
#include <opencv2/core.hpp>
namespace cvw {
[[nodiscard]] inline expected<Image<Float1>, AlgorithmError>
normalize(Image<Gray> img, float min_val = 0.0f, float max_val = 1.0f) {
auto ec = detail::check_non_empty(img);
if (!ec) {
return unexpected(ec.error());
}
cv::Mat dst;
cv::normalize(img.mat(), dst, min_val, max_val, cv::NORM_MINMAX, CV_32FC1);
return Image<Float1>(std::move(dst));
}
} // namespace cvwUpdated on 2026-05-17 at 13:22:38 +0000