当前位置:网站首页>25. histogram comparison
25. histogram comparison
2022-06-26 01:36:00 【Nightmare satiety】





#include <opencv4/opencv2/opencv.hpp>
#include <iostream>
#include <math.h>
std::string convertToString(double d);
int main(int argc, char** argv){
cv::Mat src1 = cv::imread("../../source/lena.png");
cv::Mat src2 = cv::imread("../../source/matlab.jpeg");
if(src1.empty() && src2.empty()){
std::cout << "could not load image ...." << std::endl;
return -1;
}
cv::cvtColor(src1, src1, cv::COLOR_BGR2HSV);
cv::cvtColor(src2, src2, cv::COLOR_BGR2HSV);
int h_bins = 50;
int s_bins = 60;
int histSize[] = {
h_bins, s_bins};
// hue varies from 0 to 179, saturation from 0 to 255
float h_ranges[] = {
0, 180};
float s_ranges[] = {
0, 256};
const float* ranges[] = {
h_ranges, s_ranges};
// Use the o-th and 1-st channels
int channels[] = {
0, 1};
cv::MatND hist_src1, hist_src2;
cv::calcHist(&src1, 1, channels, cv::Mat(), hist_src1, 2, histSize, ranges, true, false);
cv::normalize(hist_src1, hist_src1, 0, 1, cv::NORM_MINMAX);
cv::calcHist(&src2, 1, channels, cv::Mat(), hist_src2, 2, histSize, ranges, true, false);
cv::normalize(hist_src2, hist_src2, 0, 1, cv::NORM_MINMAX);
double base = cv::compareHist(hist_src1, hist_src1, cv::HISTCMP_CORREL);
double base1 = cv::compareHist(hist_src1, hist_src2, cv::HISTCMP_CORREL);
cv::putText(src1, convertToString(base), cv::Point(30, 30), cv::FONT_HERSHEY_COMPLEX, 1, cv::Scalar(0, 255, 255));
cv::putText(src2, convertToString(base1), cv::Point(30, 30), cv::FONT_HERSHEY_COMPLEX, 1, cv::Scalar(0, 255, 255));
cv::imshow("src1", src1);
cv::imshow("src2", src2);
cv::waitKey();
}
std::string convertToString(double d){
std::ostringstream os;
if(os << d){
return os.str();
}
return "invalid conversion";
}

边栏推荐
- Oracle database startup backup preparation
- Xinku online | cnopendata text data of IPO declaration and issuance of A-share listed companies
- 2021-1-15 摸鱼做的笔记Ctrl+c /v来的
- Maze walking
- Using redis database as cache in Django
- Qt Cmake 纯C 代码调用系统控制台输入scanf 及 中文输出乱码
- Embedded C first learning notes
- QT cmake pure C code calls the system console to input scanf and Chinese output garbled code
- 如何有效地推廣產品
- Is it safe to log in the stock account on the flush? How to open a stock account in the flush
猜你喜欢

Oracle database startup backup preparation

【花雕体验】11 上手ESP32C3

Qt Cmake 纯C 代码调用系统控制台输入scanf 及 中文输出乱码

Remote incremental synchronization artifact Rsync

Web信息收集,互联网上的裸奔者

多接口调用,使用Promise.all、Promise.race和Promise.any

QT cmake pure C code calls the system console to input scanf and Chinese output garbled code

FIFO code implemented in C language

From query database performance optimization to redis cache - talk about cache penetration, avalanche and breakdown

STM32GPIO
随机推荐
信息收集的利器,Google骇客语法
Shengxin weekly issue 33
Discrete Mathematics - 01 mathematical logic
RT thread project engineering construction and configuration - (Env kconfig)
黑盒测试 — 测试用例 之 判定表法看这一篇就够了
数组中的第K个最大元素
Comment promouvoir efficacement les produits
Native DOM vs. virtual DOM
2022 explosion proof electrical operation certificate examination question bank and simulation examination
集合集合!!快来复习--mysql增删改查,内、左右连接 复习笔记
MySQL图书借阅系统项目数据库建库表语句(组合主键、外键设置)
Quickly generate 1~20 natural numbers and easily copy
The cache page stores the initial parameters after the route jump under the react + router framework
MySQL book borrowing system project database creation TABLE statement (combined primary key and foreign key settings)
Enlightenment Q & A
JSON introduction
Xinku online | cnopendata text data of IPO declaration and issuance of A-share listed companies
Oracle database complete uninstallation steps (no screenshot)
剑指 Offer II 096. 字符串交织
Laravel basic course routing and MVC - controller