mirror of
https://github.com/Karllzy/cotton_color.git
synced 2025-11-08 18:53:53 +00:00
parent
c557f506ea
commit
2590c25e2c
8
.idea/cotton_color.iml
generated
8
.idea/cotton_color.iml
generated
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
6
.idea/inspectionProfiles/profiles_settings.xml
generated
6
.idea/inspectionProfiles/profiles_settings.xml
generated
@ -1,6 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
4
.idea/misc.xml
generated
4
.idea/misc.xml
generated
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/cotton_color.iml" filepath="$PROJECT_DIR$/.idea/cotton_color.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
66
.idea/workspace.xml
generated
66
.idea/workspace.xml
generated
@ -1,66 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c3b8d940-6023-48e1-81e6-9219102d17e0" name="更改" comment="" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||
<map>
|
||||
<entry key="$PROJECT_DIR$" value="8e7a4252223b9795b1c1387bc2ec3ae4b0840da1" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectColorInfo"><![CDATA[{
|
||||
"associatedIndex": 6
|
||||
}]]></component>
|
||||
<component name="ProjectId" id="2oQA4E5QdM3JN1nY4yVA0bMXYAI" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"git-widget-placeholder": "Template__Develop",
|
||||
"last_opened_file_path": "C:/Users/zjc/source/repos/cotton_color",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
<set>
|
||||
<option value="bundled-js-predefined-d6986cc7102b-5c90d61e3bab-JavaScript-PY-242.23339.19" />
|
||||
<option value="bundled-python-sdk-0029f7779945-399fe30bd8c1-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-242.23339.19" />
|
||||
</set>
|
||||
</attachedChunks>
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="应用程序级" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="默认任务">
|
||||
<changelist id="c3b8d940-6023-48e1-81e6-9219102d17e0" name="更改" comment="" />
|
||||
<created>1730791232605</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1730791232605</updated>
|
||||
<workItem from="1730791233700" duration="108000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
<option name="TAB_STATES">
|
||||
<map>
|
||||
<entry key="MAIN">
|
||||
<value>
|
||||
<State />
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@ -52,33 +52,7 @@ void vibrantColorDetection(const Mat& inputImage, Mat& outputImage, const map<st
|
||||
// 对饱和度图像应用阈值处理
|
||||
threshold(saturation, outputImage, saturationThreshold, 255, THRESH_BINARY);
|
||||
}
|
||||
void vibrantGreenDetection(const Mat& inputImage, Mat& outputImage, const map<string, int>& 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<string, int>& 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<string, int> 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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -122,7 +122,6 @@
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>E:\opencv4.10\opencv\build\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user