本文整理汇总了C++中Histogram1D::equalize方法的典型用法代码示例。如果您正苦于以下问题:C++ Histogram1D::equalize方法的具体用法?C++ Histogram1D::equalize怎么用?C++ Histogram1D::equalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Histogram1D
的用法示例。
在下文中一共展示了Histogram1D::equalize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: case4histogram
void case4histogram() {
cv::Mat image=cv::imread( inputImagePath4case1histogram,cv::IMREAD_GRAYSCALE );
alert_win( image );
Histogram1D h;
cv::Mat eq=h.equalize( image );
alert_win( eq );
}
示例2:
//-------------------- equalized the b&w image -------------------------------------------------
//---------------------- shows it's histogram values on a graph --------------------------------
void MainWindow::on_pushButton_6_clicked()
{
Histogram1D equa;
cv::namedWindow("equalized");
cv::namedWindow("equalized histogram");
cv::Mat equalized=equa.equalize(image);
cv::imshow("equalized",equalized);
cv::imshow("equalized histogram",equa.getHistogramImage(equalized));
}
示例3: on_btnEqualizer_clicked
void ImagePro::on_btnEqualizer_clicked()
{
cv::Mat tepImg;
std::vector<cv::Mat> tmp;
cv::split(_img,tmp);
Histogram1D HH;
for (int i=0;i<3;i++){
tmp[i]=HH.equalize(tmp[i]);
}
cv::merge(tmp,tepImg);
cv::namedWindow("histogram equalize");
cv::imshow("histogram equalize",tepImg);
}
示例4: main
int main()
{
// Read input image
cv::Mat image= cv::imread("group.jpg",0);
if (!image.data)
return 0;
// Resize by 70% for book printing
cv::resize(image, image, cv::Size(), 0.7, 0.7);
// save grayscale image
cv::imwrite("groupBW.jpg", image);
// Display the image
cv::namedWindow("Image");
cv::imshow("Image",image);
// The histogram object
Histogram1D h;
// Compute the histogram
cv::Mat histo= h.getHistogram(image);
// Loop over each bin
for (int i=0; i<256; i++)
cout << "Value " << i << " = " << histo.at<float>(i) << endl;
// Display a histogram as an image
cv::namedWindow("Histogram");
cv::imshow("Histogram",h.getHistogramImage(image));
// creating a binary image by thresholding at the valley
cv::Mat thresholded; // output binary image
cv::threshold(image,thresholded,
60, // threshold value
255, // value assigned to pixels over threshold value
cv::THRESH_BINARY); // thresholding type
// Display the thresholded image
cv::namedWindow("Binary Image");
cv::imshow("Binary Image",thresholded);
thresholded = 255 - thresholded;
cv::imwrite("binary.bmp",thresholded);
// Equalize the image
cv::Mat eq= h.equalize(image);
// Show the result
cv::namedWindow("Equalized Image");
cv::imshow("Equalized Image",eq);
// Show the new histogram
cv::namedWindow("Equalized Histogram");
cv::imshow("Equalized Histogram",h.getHistogramImage(eq));
// Stretch the image, setting the 1% of pixels at black and 1% at white
cv::Mat str= h.stretch(image,0.01f);
// Show the result
cv::namedWindow("Stretched Image");
cv::imshow("Stretched Image",str);
// Show the new histogram
cv::namedWindow("Stretched Histogram");
cv::imshow("Stretched Histogram",h.getHistogramImage(str));
// Create an image inversion table
int dim(256);
cv::Mat lut(1, // 1 dimension
&dim, // 256 entries
CV_8U); // uchar
// or cv::Mat lut(256,1,CV_8U);
for (int i=0; i<256; i++) {
lut.at<uchar>(i)= 255-i;
}
// Apply lookup and display negative image
cv::namedWindow("Negative image");
cv::imshow("Negative image",h.applyLookUp(image,lut));
cv::waitKey();
return 0;
}
示例5: main_his
int main_his()
{
// Read input image
cv::Mat image= cv::imread("Koala.jpg",0);
if (!image.data)
return 0;
// Display the image
cv::namedWindow("Image");
cv::imshow("Image",image);
// The histogram object
Histogram1D h;
// Compute the histogram
cv::MatND histo= h.getHistogram(image);
// Loop over each bin
for (int i=0; i<256; i++)
cout << "Value " << i << " = " << histo.at<float>(i) << endl;
// Display a histogram as an image
cv::namedWindow("Histogram");
cv::imshow("Histogram",h.getHistogramImage(image));
// creating a binary image by thresholding at the valley
cv::Mat thresholded;
cv::threshold(image,thresholded,60,255,cv::THRESH_BINARY);
// Display the thresholded image
cv::namedWindow("Binary Image");
cv::imshow("Binary Image",thresholded);
cv::imwrite("binary.bmp",thresholded);
// Equalize the image
cv::Mat eq= h.equalize(image);
// Show the result
cv::namedWindow("Equalized Image");
cv::imshow("Equalized Image",eq);
// Show the new histogram
cv::namedWindow("Equalized Histogram");
cv::imshow("Equalized Histogram",h.getHistogramImage(eq));
// Stretch the image ignoring bins with less than 5 pixels
cv::Mat str= h.stretch(image,5);
// Show the result
cv::namedWindow("Stretched Image");
cv::imshow("Stretched Image",str);
// Show the new histogram
cv::namedWindow("Stretched Histogram");
cv::imshow("Stretched Histogram",h.getHistogramImage(str));
// Create an image inversion table
//uchar lookup[256];
// Create lookup table
int dims[1]={256};
cv::MatND lookup(1,dims,CV_8U);
for (int i=0; i<256; i++) {
lookup.at<uchar>(i)=255-i;
}
// Apply lookup and display negative image
cv::namedWindow("Negative image");
cv::imshow("Negative image",h.applyLookUp(image,lookup));
cv::waitKey();
return 0;
}