您好,登錄后才能下訂單哦!
OpenCV(開源計算機視覺庫)是一個用于處理實時圖像和視頻的開源庫
#include <opencv2/opencv.hpp>
#include<iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv) {
Mat image = imread("input.jpg", IMREAD_GRAYSCALE);
Mat equalizedImage;
equalizeHist(image, equalizedImage);
imshow("Original Image", image);
imshow("Equalized Image", equalizedImage);
waitKey(0);
return 0;
}
#include <opencv2/opencv.hpp>
#include<iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv) {
Mat image = imread("input.jpg", IMREAD_COLOR);
Mat stretchedImage;
double minVal, maxVal;
minMaxLoc(image, &minVal, &maxVal);
for (int i = 0; i< image.rows; i++) {
for (int j = 0; j< image.cols; j++) {
Vec3b pixel = image.at<Vec3b>(i, j);
for (int k = 0; k < 3; k++) {
pixel[k] = saturate_cast<uchar>(255 * (pixel[k] - minVal) / (maxVal - minVal));
}
stretchedImage.at<Vec3b>(i, j) = pixel;
}
}
imshow("Original Image", image);
imshow("Stretched Image", stretchedImage);
waitKey(0);
return 0;
}
#include <opencv2/opencv.hpp>
#include<iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv) {
Mat image = imread("input.jpg", IMREAD_COLOR);
Mat denoisedImage;
GaussianBlur(image, denoisedImage, Size(5, 5), 0);
imshow("Original Image", image);
imshow("Denoised Image", denoisedImage);
waitKey(0);
return 0;
}
#include <opencv2/opencv.hpp>
#include<iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv) {
Mat image = imread("input.jpg", IMREAD_COLOR);
Mat filteredImage;
medianBlur(image, filteredImage, 5);
imshow("Original Image", image);
imshow("Filtered Image", filteredImage);
waitKey(0);
return 0;
}
這些示例展示了如何使用OpenCV在C++中進行基本的圖像增強。你可以根據需要調整參數以獲得更好的效果。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。