添加拖延

This commit is contained in:
zjc-zjc-123 2024-12-08 19:38:53 +08:00
parent 0415123f59
commit f9609dbd34
2 changed files with 10 additions and 7 deletions

View File

@ -55,15 +55,18 @@ std::vector<std::vector<uint8_t>> generateMaskFromImage(const MIL_ID& inputImage
// 遍历每一列处理规则当某列出现第一个1时将其后rowRange行全部置为255
for (int j = 0; j < widthBlocks; ++j) {
bool marked = false; // 标记当前列是否已经处理过第一个1
for (int i = 0; i < heightBlocks; ++i) {
if (mask[i][j] == 1&& !marked) {
int i = 0;
while (i < heightBlocks) {
if (mask[i][j] == 1) {
// 找到第一个1处理后面rowRange行
for (int k = i; k < std::min(i + rowRange, heightBlocks); ++k) {
mask[k][j] = 1;
}
marked = true; // 标记为已处理后续连续的1不再处理
// 跳过已经设置为255的后rowRange行
i += rowRange;
} else {
// 如果当前位置为0则继续检测下一行
++i;
}
}
}

View File

@ -9,7 +9,7 @@
#include"Matrox/mask.h"
#include"mil.h"
#define Image_PATH3 MIL_TEXT("C:\\Users\\zjc\\Desktop\\mask_1.png")
#define Image_PATH3 MIL_TEXT("C:\\Users\\zjc\\Desktop\\mask_5.png")
MIL_ID MilApplication, MilSystem, MilDisplay;
int main() {
@ -30,7 +30,7 @@ int main() {
int widthBlocks = 24;
int heightBlocks = 1024;
int threshold = 20;
int rowRange = 50; // 后续50行设置为1
int rowRange = 50; // 后续50行设置为
// 生成掩膜
std::vector<std::vector<uint8_t>> mask = generateMaskFromImage(MilImage, widthBlocks, heightBlocks, threshold, rowRange);