BUG: ConvertColorToGrayScale writes all inputs to the first output array

已关闭 适合新手
#1,759 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

@imikejackson 已经在做这个了。

开始于 2026年10月31日。

  • #1900 来自 @imikejackson —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
88/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cpp
领域
data, testing

调研方向

从 src/simplnx/Utilities/ImageProcessing/ColorToGrayScale.cpp 中 588-599 行附近的 Execute 循环开始,然后检查 ConvertColorToGrayScaleTest.cpp。运行现有测试以确定其行为,使用至少两个值不同的输入数组添加覆盖,并验证每个对应的 Gray_ 输出都包含正确的灰度值,且不会覆盖其他输出。

由索引模型根据 Issue 内容生成。

描述

bug

Description

ConvertColorToGrayScaleFilter writes every converted input array to the first output array when the user selects more than one input array.

Preflight makes one output array for each selected input array (<prefix><input name>). Execute does not move to the next output path. outputPathIter is set to begin() and the loop never increments it:

https://github.com/BlueQuartzSoftware/simplnx/blob/282a16cc97430840b9fa1c47956cacefb7931683/src/simplnx/Utilities/ImageProcessing/ColorToGrayScale.cpp#L588-L599

// Current behavior reuses the first output path for every selected input path.
auto outputPathIter = m_InputValues->OutputDataArrayPaths.begin();
for(const auto& arrayPath : m_InputValues->InputDataArrayPaths)
{
  ...
  auto& outputGrayArray = m_DataStructure.getDataRefAs<UInt8Array>(*outputPathIter);
  ...
}

The defect has been in the code since the filter was ported in e135e9de0 (#388). #1568 added the comment above but kept the behavior. #1752 moved the file to src/simplnx/Utilities/ImageProcessing/.

Steps to Reproduce

  1. Create three uint8 color arrays A, B, and C with 3 components and different values.
  2. Run ConvertColorToGrayScaleFilter with all three arrays selected and the prefix Gray_.

Expected: Gray_A, Gray_B, and Gray_C contain the gray-scale values of A, B, and C.

Actual: Gray_A contains the gray-scale values of C, because each pass overwrites the previous one. The filter does not write to Gray_B and Gray_C; they keep their initial values. The filter does not show an error or a warning.

Test Coverage

ConvertColorToGrayScaleTest.cpp selects only one input array, so the tests do not find this defect. A fix must increment outputPathIter after each input array, remove the comment, and add a test that selects two or more input arrays with different values.

主要语言
C++
星标
18
派生
15
平均合并
3 天 35 分钟
30 天内合并 PR
25

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

BlueQuartzSoftware/simplnx 的其他 Issue

查看 BlueQuartzSoftware/simplnx 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。