mirror of
https://github.com/Karllzy/cotton_color.git
synced 2025-11-09 11:13:54 +00:00
添加拖延
This commit is contained in:
parent
0415123f59
commit
f9609dbd34
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user