Beispiel #1
0
int CVICALLBACK Thresholding (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	int threshold = 0;
	int histogram[256] = {0};
	HistogramReport *report = NULL;
	
	switch (event)
	{
		case EVENT_COMMIT:
			
			GetCtrlVal (mypanel, MYPANEL_THRESHOLD_SLIDE, &threshold);
			
			imaqThreshold (destimage, sourimage, threshold, 255, TRUE, 255);
			imaqSetWindowTitle (1, "Picture after binaryzation");
			
			imaqMoveWindow (1, imaqMakePoint (150, 260));
			imaqDisplayImage (destimage, 1, TRUE);
			
			report = imaqHistogram (destimage, 256, 0, 255, IMAQ_IMAGE_U8);
			DeleteGraphPlot (mypanel, MYPANEL_MYGRAPH, -1, VAL_IMMEDIATE_DRAW);
			
			PlotY (mypanel, MYPANEL_MYGRAPH, (*report).histogram, 256, VAL_UNSIGNED_INTEGER,
				VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
			break;
	}
	return 0;
}
Beispiel #2
0
HistogramReport* frcHistogram(const Image* image, int numClasses, float min, float max, Rect rect)
{
	int success; 
	int fillValue = 1;
	
	/* create the region of interest */
	ROI* pRoi = imaqCreateROI();
	success = imaqAddRectContour(pRoi, rect); 
	if ( !success )	{ GetLastVisionError(); return NULL; }	

	/* make a mask from the ROI */
	Image* pMask = frcCreateImage(IMAQ_IMAGE_U8);
	success = imaqROIToMask(pMask, pRoi, fillValue, NULL, NULL);
	if ( !success )	{ 
		GetLastVisionError(); 
		frcDispose(__FUNCTION__, pRoi, NULL); 
		return NULL; 
	}	
	
	/* get a histogram report */
	HistogramReport* pHr = NULL;
	pHr = imaqHistogram(image, numClasses, min, max, pMask); 
	
	/* clean up */
	frcDispose(__FUNCTION__, pRoi, pMask, NULL); 
	
	return pHr;
}
Beispiel #3
0
int CVICALLBACK Load_Picture (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	char picname[512] = {'\0'};
	int ret = 0;
	HistogramReport *report = NULL;
	
	switch (event)
	{
		case EVENT_COMMIT:

			ret = FileSelectPopup ("", "*.*", "", "Load; select an image file",
				VAL_LOAD_BUTTON, 0, 0, 1, 0, picname);
			
			if (ret == 1)
			{
				imaqReadFile (sourimage, picname, NULL, NULL);
				imaqMoveWindow (0, imaqMakePoint (50, 260));
				imaqDisplayImage (sourimage, 0, TRUE);
				
				report = imaqHistogram (sourimage, 256, 0, 255, IMAQ_IMAGE_U8);
				DeleteGraphPlot (mypanel, MYPANEL_MYGRAPH, -1, VAL_IMMEDIATE_DRAW);
				
				PlotY (mypanel, MYPANEL_MYGRAPH, (*report).histogram, 256, 
					VAL_UNSIGNED_INTEGER, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
			}
			
			break;
	}
	return 0;
}