diff --git a/.idea/cotton_color.iml b/.idea/cotton_color.iml
deleted file mode 100644
index d0876a7..0000000
--- a/.idea/cotton_color.iml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
deleted file mode 100644
index 105ce2d..0000000
--- a/.idea/inspectionProfiles/profiles_settings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 060d2c5..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 876a814..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index 7bc015d..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1730791232605
-
-
- 1730791232605
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cotton_color.cpp b/cotton_color.cpp
index 713328b..b7933ed 100644
--- a/cotton_color.cpp
+++ b/cotton_color.cpp
@@ -52,33 +52,7 @@ void vibrantColorDetection(const Mat& inputImage, Mat& outputImage, const map& params) {
- // 从参数映射中获取饱和度阈值
- int green = params.at("green");
- // 将输入图像从 BGR 转换为 HSV
- Mat lab_image;
- cvtColor(inputImage, lab_image, cv::COLOR_BGR2Lab);
-
- // 定义偏绿色的Lab范围(具体值可能需要调整)
- Scalar lower_green_lab(101, 101, 95);
- Scalar upper_green_lab(135, 120, green);
-
- // 创建掩膜
- Mat mask_lab;
- inRange(lab_image, lower_green_lab, upper_green_lab, mask_lab);
-
- // 通过掩膜提取偏绿色部分
- Mat masked_image_lab;
- bitwise_and(inputImage, inputImage, masked_image_lab, mask_lab);
-
- // 显示结果
- imshow("Original Image", inputImage);
- imshow("Mask Lab", mask_lab);
- //cv::imshow("Masked Image Lab", masked_image_lab);
- waitKey(0);
- destroyAllWindows();
-}
void blackColorDetection(const Mat& inputImage, Mat& outputImage, const map& params)
{
@@ -116,7 +90,7 @@ string openFileDialog() {
}
-
+void test() {}
Mat readImage() {
// 读取输入图像
string imagePath = openFileDialog();
@@ -140,7 +114,7 @@ Mat readImage() {
int main() {
// 读取输入图像
- Mat inputImage = readImage();
+ Mat inputImage = readImage();
if (inputImage.empty()) {
cout << "Error: Could not load image." << endl;
@@ -152,10 +126,10 @@ int main() {
// 使用 map 模拟 JSON 参数传递
map params;
- params["green"] =134; // 设置饱和度阈值为100
+ params["saturationThreshold"] = 100; // 设置饱和度阈值为100
// 调用鲜艳颜色检测函数
- vibrantGreenDetection(inputImage, outputImage, params);
+ vibrantColorDetection(inputImage, outputImage, params);
// 显示原图和检测到的鲜艳区域
imshow("Original Image", inputImage);
@@ -164,5 +138,4 @@ int main() {
// 等待用户按键
waitKey(0);
return 0;
-}
-
+}
\ No newline at end of file
diff --git a/cotton_color.vcxproj b/cotton_color.vcxproj
index 2c944c3..8a13bfb 100644
--- a/cotton_color.vcxproj
+++ b/cotton_color.vcxproj
@@ -122,7 +122,6 @@
NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
E:\opencv4.10\opencv\build\include;%(AdditionalIncludeDirectories)
- ProgramDatabase
Console