当前位置: 首页>>代码示例>>C++>>正文


C++ Histogram1D::getHistogramImage方法代码示例

本文整理汇总了C++中Histogram1D::getHistogramImage方法的典型用法代码示例。如果您正苦于以下问题:C++ Histogram1D::getHistogramImage方法的具体用法?C++ Histogram1D::getHistogramImage怎么用?C++ Histogram1D::getHistogramImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Histogram1D的用法示例。


在下文中一共展示了Histogram1D::getHistogramImage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: on_pushButton_clicked

//------------------ shows histogram values on the graphic----------------------------------
void MainWindow::on_pushButton_clicked()
{
    Histogram1D graph;

    cv::namedWindow("histogram graph");
    cv::imshow("histogram graph", graph.getHistogramImage(image));
}
开发者ID:ekimcak,项目名称:Ekim-Vision-test-code,代码行数:8,代码来源:mainwindow.cpp

示例2: case2histogram

void case2histogram() {
    cv::Mat image=cv::imread( inputImagePath4case1histogram,cv::IMREAD_GRAYSCALE );//open in b&w
    alert_win( image );

    Histogram1D h;
    cv::Mat re= h.getHistogramImage(image);
    alert_win( re );

}
开发者ID:Letractively,项目名称:cplusplus4java,代码行数:9,代码来源:chp04.cpp

示例3:

//-------------------- 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));

}
开发者ID:ekimcak,项目名称:Ekim-Vision-test-code,代码行数:14,代码来源:mainwindow.cpp

示例4: main

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    Mat image = imread("D:\\workspace\\pictures\\771413900_m.jpg",0);
    Mat thresholded, result;

    Histogram1D h;

    MatND histo = h.getHistogram(image);

    for (int i=0;i<256;i++)
        cout << "Value" << i << "=" << histo.at<float>(i) << endl;

    imshow("Orginal", image);

    imshow("Histogram",h.getHistogramImage(image));

    //threshold(image, thresholded,128,255,THRESH_BINARY);

    //imshow("Threshold",thresholded);

    equalizeHist(image,result);

    //Mat stretched = h.stretch(image,100);

    //imshow("Stretched",stretched);

    imshow("Equalize",result);

    imshow("After Equalize Histogram",h.getHistogramImage(result));


    waitKey(50000);

    return a.exec();
}
开发者ID:vmebus,项目名称:workspace,代码行数:37,代码来源:main.cpp

示例5: dim

//-------------------- tranforms the image to negative---------------------------------------
//-------------------- shows it's histogram values on graphic--------------------------------
void MainWindow::on_pushButton_4_clicked()
{
    Histogram1D negative;
    //build look up
    int dim(256);
    cv::Mat lut(1, &dim, CV_8U); // lut is a matrix which is in 1D
    for(int i=0; i<256; i++)
    {
        lut.at<uchar>(i)=255-i; //takes all the values and reverses it
    }
    cv::Mat negativeResult;
    negativeResult=negative.applyLookUp(image,lut);
    cv::namedWindow("negative");
    cv::imshow("negative",negativeResult);

    //negative image histogram
    cv::imshow("negative histogram",negative.getHistogramImage(negativeResult));

}
开发者ID:ekimcak,项目名称:Ekim-Vision-test-code,代码行数:21,代码来源:mainwindow.cpp

示例6: main

int main()
{
  Mat src;
  src = imread("box.png");
 if( !src.data )
    { 
  cout<<"error";
  }

  namedWindow("image", CV_WINDOW_AUTOSIZE );
  imshow("image", src );
  waitKey(0);

  // The histogram object
Histogram1D h;
namedWindow("Histogram");
imshow("Histogram",h.getHistogramImage(src));
waitKey(0);

  return 1;

}
开发者ID:07hk-mani,项目名称:opencv3,代码行数:22,代码来源:Source.cpp

示例7: main

int main()
{
	// Read input image
    cv::Mat image= cv::imread("waves.jpg",0);
	if (!image.data)
		return 0; 

	// define image ROI
	cv::Mat imageROI;
	imageROI= image(cv::Rect(216,33,24,30)); // Cloud region

	// Display reference patch
	cv::namedWindow("Reference");
	cv::imshow("Reference",imageROI);

	// Find histogram of reference
	Histogram1D h;
	cv::Mat hist= h.getHistogram(imageROI);
	cv::namedWindow("Reference Hist");
	cv::imshow("Reference Hist",h.getHistogramImage(imageROI));

	// Create the content finder
	ContentFinder finder;

	// set histogram to be back-projected
	finder.setHistogram(hist);
	finder.setThreshold(-1.0f);

	// Get back-projection
	cv::Mat result1;
	result1= finder.find(image);

	// Create negative image and display result
	cv::Mat tmp;
	result1.convertTo(tmp,CV_8U,-1.0,255.0);
	cv::namedWindow("Backprojection result");
	cv::imshow("Backprojection result",tmp);

	// Get binary back-projection
	finder.setThreshold(0.12f);
	result1= finder.find(image);

	// Draw a rectangle around the reference area
	cv::rectangle(image, cv::Rect(216, 33, 24, 30), cv::Scalar(0, 0, 0));

	// Display image
	cv::namedWindow("Image");
	cv::imshow("Image",image);

	// Display result
	cv::namedWindow("Detection Result");
	cv::imshow("Detection Result",result1);

	// Load color image
	ColorHistogram hc;
    cv::Mat color= cv::imread("waves.jpg");

	// extract region of interest
	imageROI= color(cv::Rect(0,0,100,45)); // blue sky area

	// Get 3D colour histogram (8 bins per channel)
	hc.setSize(8); // 8x8x8
	cv::Mat shist= hc.getHistogram(imageROI);

	// set histogram to be back-projected
	finder.setHistogram(shist);
	finder.setThreshold(0.05f);

	// Get back-projection of color histogram
	result1= finder.find(color);

	cv::namedWindow("Color Detection Result");
	cv::imshow("Color Detection Result",result1);

	// Second color image
	cv::Mat color2= cv::imread("dog.jpg");

	cv::namedWindow("Second Image");
	cv::imshow("Second Image",color2);

	// Get back-projection of color histogram
	cv::Mat result2= finder.find(color2);

	cv::namedWindow("Result color (2)");
	cv::imshow("Result color (2)",result2);

	// Get ab color histogram
	hc.setSize(256); // 256x256
	cv::Mat colorhist= hc.getabHistogram(imageROI);

	// display 2D histogram
	colorhist.convertTo(tmp,CV_8U,-1.0,255.0);
	cv::namedWindow("ab histogram");
	cv::imshow("ab histogram",tmp);

	// set histogram to be back-projected
	finder.setHistogram(colorhist);
	finder.setThreshold(0.05f);

	// Convert to Lab space
//.........这里部分代码省略.........
开发者ID:laganiere,项目名称:OpenCV3Cookbook,代码行数:101,代码来源:contentFinder.cpp

示例8: getHistogram

cv::Mat ImageProcessor::getHistogram(cv::Mat &origImage) {
	Histogram1D h;
	return h.getHistogramImage(origImage);
}
开发者ID:tmramalho,项目名称:bigCellBrotherGUI,代码行数:4,代码来源:ImageProcessor.cpp

示例9: 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;
}
开发者ID:3ClassMrWang,项目名称:OpenCV2Cookbook2ndEd,代码行数:84,代码来源:histograms.cpp

示例10: 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;
}
开发者ID:anwarparvez,项目名称:OpenCvTestproject,代码行数:74,代码来源:histogram.cpp


注:本文中的Histogram1D::getHistogramImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。