30 requires std::is_arithmetic_v<T>
37 std::ranges::transform(this->PointerToPixelsStart(), this->PointerToPixelsStart() + this->TotalPixels(),
39 [scale_factor](
const T& current_pixel) ->
char {
40 return (char)(((float)current_pixel)*((float)scale_factor) + 0.5f);
48 requires std::is_arithmetic_v<T>
58 std::array<float, 2> total_disp_abs_diff_no_max_w_max{0, 0};
62 for (
unsigned int i = 0; i < this->TotalPixels(); i++) {
64 const T disp_map_val = (this->pixels_.get())[i];
65 const T disp_map_compare_val = disparity_map_to_compare.
PixelAtPoint(i);
66 const T abs_diff =
std::abs(disp_map_val - disp_map_compare_val);
70 total_disp_abs_diff_no_max_w_max[0] += abs_diff;
71 total_disp_abs_diff_no_max_w_max[1] += std::min(abs_diff, evaluation_parameters.
max_diff_cap);
75 [abs_diff, &output_evaluation](
const auto threshold) {
76 if (abs_diff > threshold) {
77 output_evaluation.num_sig_diff_pixels_at_thresholds_[threshold]++;
82 output_evaluation.average_disp_abs_diff_no_max_w_max_[0] =
83 total_disp_abs_diff_no_max_w_max[0] / this->TotalPixels();
84 output_evaluation.average_disp_abs_diff_no_max_w_max_[1] =
85 total_disp_abs_diff_no_max_w_max[1] / this->TotalPixels();
88 std::ranges::transform(output_evaluation.num_sig_diff_pixels_at_thresholds_,
89 std::inserter(output_evaluation.prop_sig_diff_pixels_at_thresholds_,
90 output_evaluation.prop_sig_diff_pixels_at_thresholds_.end()),
91 [
this](
const auto& sig_diff_pixel_at_threshold) -> std::pair<float, float> {
92 const auto& [threshold, num_sig_diff_pixels_thresh] = sig_diff_pixel_at_threshold;
93 return {threshold, ((float)num_sig_diff_pixels_thresh) / ((float)(this->TotalPixels()))};
96 return output_evaluation;
Declares child class of BpImage to define disparity map image that is output from bp processing.
Class to define images that are used in bp processing.
void SaveImageAsPgm(const std::string &filename) const
T PixelAtPoint(const std::array< unsigned int, 2 > &point_xy) const
T * PointerToPixelsStart() const
Class to store disparity map evaluation results. Specifically comparison between two disparity maps s...
void InitializeWithEvalParams(const beliefprop::DisparityMapEvaluationParams &eval_params)
Initialize evaluation results with evaluation parameters.
Child class of BpImage to define disparity map image that is output from bp processing.
DisparityMapEvaluation OutputComparison(const DisparityMap &disparity_map_to_compare, const beliefprop::DisparityMapEvaluationParams &evaluation_parameters) const
void SaveDisparityMap(const std::string &disparity_map_file_path, unsigned int scale_factor=1) const
bp_single_thread_imp::image< uchar > * threshold(bp_single_thread_imp::image< T > *src, int t)
Struct to store parameters for evaluation of disparity map from stereo processing.
const std::vector< float > output_diff_thresholds
Difference thresholds for comparing disparity maps.