diff --git a/backend/genesys/image_pipeline.cpp b/backend/genesys/image_pipeline.cpp index c01b7f487..0f36b044e 100644 --- a/backend/genesys/image_pipeline.cpp +++ b/backend/genesys/image_pipeline.cpp @@ -666,16 +666,21 @@ bool ImagePipelineNodeExtract::get_next_row_data(std::uint8_t* out_data) ImagePipelineNodeCalibrate::ImagePipelineNodeCalibrate(ImagePipelineNode& source, const std::vector& bottom, - const std::vector& top) : + const std::vector& top, + std::size_t x_start) : source_{source} { - auto size = std::min(bottom.size(), top.size()); + std::size_t size = 0; + if (bottom.size() >= x_start && top.size() >= x_start) { + size = std::min(bottom.size() - x_start, top.size() - x_start); + } + offset_.reserve(size); multiplier_.reserve(size); for (std::size_t i = 0; i < size; ++i) { - offset_.push_back(bottom[i] / 65535.0f); - multiplier_.push_back(65535.0f / (top[i] - bottom[i])); + offset_.push_back(bottom[i + x_start] / 65535.0f); + multiplier_.push_back(65535.0f / (top[i + x_start] - bottom[i + x_start])); } } diff --git a/backend/genesys/image_pipeline.h b/backend/genesys/image_pipeline.h index 29868374d..39431ca69 100644 --- a/backend/genesys/image_pipeline.h +++ b/backend/genesys/image_pipeline.h @@ -476,7 +476,7 @@ class ImagePipelineNodeCalibrate : public ImagePipelineNode public: ImagePipelineNodeCalibrate(ImagePipelineNode& source, const std::vector& bottom, - const std::vector& top); + const std::vector& top, std::size_t x_start); std::size_t get_width() const override { return source_.get_width(); } std::size_t get_height() const override { return source_.get_height(); } diff --git a/backend/genesys/low.cpp b/backend/genesys/low.cpp index 83750e3f9..f45432029 100644 --- a/backend/genesys/low.cpp +++ b/backend/genesys/low.cpp @@ -1354,7 +1354,9 @@ void build_image_pipeline(Genesys_Device* dev, const ScanSession& session) !has_flag(session.params.flags, ScanFlag::DISABLE_SHADING)) { dev->pipeline.push_node(dev->dark_average_data, - dev->white_average_data); + dev->white_average_data, + dev->calib_session.params.startx * + dev->calib_session.params.channels); if (DBG_LEVEL >= DBG_io2) { dev->pipeline.push_node("gl_pipeline_" + diff --git a/testsuite/backend/genesys/tests_image_pipeline.cpp b/testsuite/backend/genesys/tests_image_pipeline.cpp index d4853d262..dfb61cb14 100644 --- a/testsuite/backend/genesys/tests_image_pipeline.cpp +++ b/testsuite/backend/genesys/tests_image_pipeline.cpp @@ -445,7 +445,7 @@ void test_node_calibrate_8bit() ImagePipelineStack stack; stack.push_first_node(1, 1, PixelFormat::RGB888, std::move(in_data)); - stack.push_node(bottom, top); + stack.push_node(bottom, top, 0); ASSERT_EQ(stack.get_output_width(), 1u); ASSERT_EQ(stack.get_output_height(), 1u); @@ -481,7 +481,7 @@ void test_node_calibrate_16bit() ImagePipelineStack stack; stack.push_first_node(1, 1, PixelFormat::RGB161616, std::move(in_data)); - stack.push_node(bottom, top); + stack.push_node(bottom, top, 0); ASSERT_EQ(stack.get_output_width(), 1u); ASSERT_EQ(stack.get_output_height(), 1u);