Opencv2 learns 7th-day RGB image histograms & grayscale image histograms

Source: Internet
Author: User
#include <opencv2/highgui/highgui.hpp>#include <opencv2/core/core.hpp>#include <vector>#include <iostream>#include <opencv2/imgproc/imgproc.hpp>using namespace cv;using namespace std;//class Histgram1D//{//public://Histgram1D()//{//histsize[0] = 256;//hranges[0] = 0.0;//hranges[1] = 255.0;//ranges[0] = hranges;//channels[0] = 0;//by default,we look at channel 0//}//// Computes the 1D histogram//cv::MatND gethistogram(const Mat & image)//{//MatND hist;////compute histogram//calcHist(&image,//1,//histogram from 1 image only//channels,//the channel used//Mat(),//no mask is used//hist,//the resulting histogram//1,//it is a 1D histogram//histsize,//number of bins//ranges//pixel value range//);//return hist;//}////computes the 1D histogram and returns an image of it//Mat getHistogramImage(const Mat &image)//{//MatND hist = gethistogram(image);//compute histogram first//double maxVal = 0;//double minVal = 0;//minMaxLoc(hist,&minVal,&maxVal,0,0);//Mat histimg(histsize[0],histsize[0],CV_8U,Scalar(255));//image on which to display histogram//int hpt = static_cast<int>(0.9*histsize[0]);////draw a vertical line foe each bin//for (int h=0;h

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.