From aa7ab9c429c3daa4d4e2f6d1924d252ccecebca2 Mon Sep 17 00:00:00 2001 From: biss Date: Mon, 16 Mar 2026 20:36:25 +0800 Subject: [PATCH] Format Code --- basic/readpixel.cpp | 8 ++++---- basic/roi.cpp | 8 ++++---- basic/splitmerge.cpp | 10 +++++----- basic/zoom.cpp | 6 ++++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/basic/readpixel.cpp b/basic/readpixel.cpp index 0c6815d..a2130fc 100644 --- a/basic/readpixel.cpp +++ b/basic/readpixel.cpp @@ -1,6 +1,6 @@ // 读取像素 -#include -#include +#include +#include using namespace std; using namespace cv; @@ -10,7 +10,8 @@ int main() string image_path = "../img/1.png"; Mat image = imread(image_path); - if (image.empty()) { + if (image.empty()) + { cout << "错误:无法加载图像,请检查路径是否正确。" << endl; return -1; } @@ -20,5 +21,4 @@ int main() cout << "B: " << (int)pixel_value[0] << " " << "G: " << (int)pixel_value[1] << " " << "R: " << (int)pixel_value[2] << endl; - } \ No newline at end of file diff --git a/basic/roi.cpp b/basic/roi.cpp index 146681e..f7858d1 100644 --- a/basic/roi.cpp +++ b/basic/roi.cpp @@ -1,6 +1,6 @@ // 修改像素 -#include -#include +#include +#include using namespace std; using namespace cv; @@ -11,7 +11,8 @@ int main() Mat image = imread(image_path); Mat result = image.clone(); - if (image.empty()) { + if (image.empty()) + { cout << "错误:无法加载图像,请检查路径是否正确。" << endl; return -1; } @@ -24,5 +25,4 @@ int main() waitKey(0); return 0; - } \ No newline at end of file diff --git a/basic/splitmerge.cpp b/basic/splitmerge.cpp index e718447..13c1496 100644 --- a/basic/splitmerge.cpp +++ b/basic/splitmerge.cpp @@ -1,6 +1,6 @@ // 图像通道分离与合并 -#include -#include +#include +#include using namespace std; using namespace cv; @@ -13,7 +13,7 @@ int main() // 定义向量数组接收通道 vector channels; // 拆分 - split(result,channels); + split(result, channels); Mat b = channels[0]; Mat g = channels[1]; @@ -31,9 +31,9 @@ int main() channels_to_merge.push_back(r); merge(channels_to_merge, merged_img); - imshow("merged",merged_img); + imshow("merged", merged_img); waitKey(0); - return(0); + return (0); } \ No newline at end of file diff --git a/basic/zoom.cpp b/basic/zoom.cpp index db0d5fd..6e6270c 100644 --- a/basic/zoom.cpp +++ b/basic/zoom.cpp @@ -1,10 +1,12 @@ #include #include -int main() { +int main() +{ // 读取图像 cv::Mat img = cv::imread("../img/1.png"); - if (img.empty()) { + if (img.empty()) + { std::cout << "无法读取图像" << std::endl; return -1; }