#include <iostream>
#include <string>
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "HougnRoundCheck.h"
using namespace cv;
using namespace std;
// 直方图均衡化
Mat equalize_img(Mat& src_img)
{
Mat result;
equalizeHist(src_img, result);
return result;
}
Mat show_img_histogram(Mat& src_img)
{
//create 256 subinterval
//the number of possibles values
int numbins = 256;
//set the range for BGR(0-256)
float range[] = {
0, 256 };
const float* histRange = {
range };
Mat gray_hist;
calcHist(&src_img, 1, 0, Mat(), gray_hist, 1, &numbins, &histRange);
//draw histogram
//draw lines for each channels
int width = 512;
int height = 300;
// Create image with gray base
Mat histImage(height, width, CV_8UC3, Scalar(20, 20, 20));
// Normalize the histograms to height of image
normalize(gray_hist, gray_hist, 0, height, NORM_MINMAX);
int binStep = cvRound((float)width / (float)numbins);
for (int i = 1; i < numbins; i++) {
line(
histImage,
Point(binStep * (i - 1), height - cvRound(gray_hist.at<float>(i - 1))),
Point(binStep * (i), height - cvRound(gray_hist.at<float>(i))),
Scalar(255, 0, 0)
);
}
return histImage;
}
Mat display(Mat img)
{
// Load image to process
Mat srcGray;
cv::cvtColor
利用OPENCV实现透视变换
最新推荐文章于 2024-08-04 18:15:35 发布