⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 visionapi.cpp

📁 good luck to everyone!
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	
	/* clean up */
	frcDispose(__FUNCTION__, pRoi, pMask, NULL); 
	
	return pHr;
}

/**
* @brief Calculates the histogram, or pixel distribution, of a color image. 
* Supports IMAQ_IMAGE_RGB, IMAQ_IMAGE_HSL.
*            
* @param image Image whose histogram the function calculates.
* @param numClasses The number of classes into which the function separates the pixels. 
* Determines the number of elements in the histogram array returned
* @param mode The color space in which to perform the histogram. Possible values include IMAQ_RGB and IMAQ_HSL. 
* @param mask An optional mask image. This image must be an IMAQ_IMAGE_U8 image. 
* The function calculates the histogram using only those pixels in the image whose 
* corresponding pixels in the mask are non-zero. Set this parameter to NULL to calculate 
* the histogram of the entire image, or use the simplified call.
* 
* @return On success, this function returns a report describing the classification  
* of each plane in a HistogramReport. 
* When you are finished with the report, dispose of it by calling frcDispose(). 
* On failure, this function returns NULL.  
* To get extended error information, call imaqGetLastError(). 
*/
ColorHistogramReport* frcColorHistogram(const Image* image, int numClasses, ColorMode mode)
{	
	return frcColorHistogram(image, numClasses, mode, NULL);
}

ColorHistogramReport* frcColorHistogram(const Image* image, int numClasses, ColorMode mode, Image* mask)
{
	return imaqColorHistogram2((Image*)image, numClasses, mode, NULL, mask);
}


/**
* @brief Measures the pixel intensities in a rectangle of an image. 
* Outputs intensity based statistics about an image such as Max, Min, Mean and Std Dev of pixel value. 
* Supports IMAQ_IMAGE_U8 (grayscale) IMAQ_IMAGE_RGB (color) IMAQ_IMAGE_HSL (color-HSL).
* 
* @param image The image whose pixel value the function queries
* @param pixel The coordinates of the pixel that the function queries
* @param value On return, the value of the specified image pixel. This parameter cannot be NULL.
* This data structure contains either grayscale, RGB, HSL, Complex or RGBU64Value depending on the type of image.
* @return On success: 1. On failure: 0. To get extended error information, call GetLastError().
*/
int frcGetPixelValue(const Image* image, Point pixel, PixelValue* value)
{	
	return imaqGetPixel(image, pixel, value);
}


/*   Particle Analysis functions */

/**
* @brief Filters particles out of an image based on their measurements. 
* Supports IMAQ_IMAGE_U8, IMAQ_IMAGE_I16, IMAQ_IMAGE_SGL.
* 
* @param dest The destination image. If dest is used, it must be the same size as the Source image. It will contain only the filtered particles.
* @param source The image containing the particles to filter. 
* @param criteria An array of criteria to apply to the particles in the source image. This array cannot be NULL.
* See the NIVisionCVI.chm help file for definitions of criteria. 
* @param criteriaCount The number of elements in the criteria array.
* @param options Binary filter options, including rejectMatches, rejectBorder, and connectivity8.
* @param rect Area of image to filter. If omitted, the default is entire image.
* @param numParticles On return, the number of particles left in the image
* @return On success: 1. On failure: 0. To get extended error information, call GetLastError().
*/
int frcParticleFilter(Image* dest, Image* source, const ParticleFilterCriteria2* criteria, 
		int criteriaCount, const ParticleFilterOptions* options, int* numParticles)
{
	Rect rect = IMAQ_NO_RECT;
	return frcParticleFilter(dest, source, criteria, criteriaCount, options, rect, numParticles);
}

int frcParticleFilter(Image* dest, Image* source, const ParticleFilterCriteria2* criteria, 
		int criteriaCount, const ParticleFilterOptions* options, Rect rect, int* numParticles)
{
	ROI* roi = imaqCreateROI();
	imaqAddRectContour(roi, rect);
	return imaqParticleFilter3(dest, source, criteria, criteriaCount, options, roi, numParticles);
}


/**
* @brief Performs morphological transformations on binary images. 
* Supports IMAQ_IMAGE_U8. 
*
* @param dest The destination image. The border size of the destination image is not important.
* @param source The image on which the function performs the morphological operations. The calculation 
* modifies the border of the source image. The border must be at least half as large as the larger 
* dimension  of the structuring element.  The connected source image for a morphological transformation 
* must have been created with a border capable of supporting the size of the structuring element. 
* A 3 by 3 structuring element requires a minimal border of 1, a 5 by 5 structuring element requires a minimal border of 2, and so on.
* @param method The morphological transform to apply. 
* @param structuringElement The structuring element used in the operation. Omit this parameter if you do not want a custom structuring element. 
* @return On success: 1. On failure: 0. To get extended error information, call GetLastError(). 
*/
int frcMorphology(Image* dest, Image* source, MorphologyMethod method)
{	
	return imaqMorphology(dest, source, method, NULL);
}

int frcMorphology(Image* dest, Image* source, MorphologyMethod method, const StructuringElement* structuringElement)
{	
	return imaqMorphology(dest, source, method, structuringElement); 
}

/**
* @brief Eliminates particles that touch the border of the image. 
* Supports IMAQ_IMAGE_U8.
*
* @param dest The destination image.
* @param source The source image. If the image has a border, the function sets all border pixel values to 0.
* @param connectivity8 specifies the type of connectivity used by the algorithm for particle detection. 
* The connectivity mode directly determines whether an adjacent pixel belongs to the same particle or a 
* different particle. Set to TRUE to use connectivity-8 to determine whether particles are touching 
* Set to FALSE to use connectivity-4 to determine whether particles are touching. 
* The default setting for the simplified call is TRUE
* @return On success: 1. On failure: 0. To get extended error information, call GetLastError().
*/
int frcRejectBorder(Image* dest, Image* source)
{	return imaqRejectBorder(dest, source, TRUE); }

int frcRejectBorder(Image* dest, Image* source, int connectivity8)
{	
	return imaqRejectBorder(dest, source, connectivity8);
}


/**
* @brief Counts the number of particles in a binary image. 
* Supports IMAQ_IMAGE_U8, IMAQ_IMAGE_I16, IMAQ_IMAGE_SGL.
* @param image binary (thresholded) image 	
* @param numParticles On return, the number of particles.
* @return On success: 1. On failure: 0. To get extended error information, call GetLastError().    
*/
int frcCountParticles(Image* image, int* numParticles)				
{	
	return imaqCountParticles(image, 1, numParticles);
}


/**
* @brief Conduct measurements for a single particle in an images. 
* Supports IMAQ_IMAGE_U8, IMAQ_IMAGE_I16, IMAQ_IMAGE_SGL.
* 
* @param image image with the particle to analyze. This function modifies the source image. 
* If you need the original image, create a copy of the image using frcCopy() before using this function.
* @param particleNumber The number of the particle to get information on
* @param par on return, a particle analysis report containing information about the particle. This structure must be created by the caller.
* @return On success: 1. On failure: 0. To get extended error information, call GetLastError().
*/
int frcParticleAnalysis(Image* image, int particleNumber, ParticleAnalysisReport* par)				
{
	int success = 0;

	/* image information */
	int height, width;
	if ( ! imaqGetImageSize(image, &width, &height) ) 	{ return success; }	
	par->imageWidth = width;	
	par->imageHeight = height;	
	par->particleIndex = particleNumber;		

	/* center of mass point of the largest particle	*/
	double returnDouble;
	success = imaqMeasureParticle(image, particleNumber, 0, IMAQ_MT_CENTER_OF_MASS_X, &returnDouble);
	if ( !success )	{ return success; }
	par->center_mass_x = (int)returnDouble;						// pixel	

	success = imaqMeasureParticle(image, particleNumber, 0, IMAQ_MT_CENTER_OF_MASS_Y, &returnDouble);	
	if ( !success )	{ return success; }
	par->center_mass_y = (int)returnDouble;						// pixel		
	
	/* particle size statistics */ 
	success = imaqMeasureParticle(image, particleNumber, 0, IMAQ_MT_AREA, &returnDouble);	
	if ( !success )	{ return success; }
	par->particleArea = returnDouble;	
	
	success = imaqMeasureParticle(image, particleNumber, 0, IMAQ_MT_BOUNDING_RECT_TOP, &returnDouble);	
	if ( !success )	{ return success; }
	par->boundingRect.top = (int)returnDouble;
	
	success = imaqMeasureParticle(image, particleNumber, 0, IMAQ_MT_BOUNDING_RECT_LEFT, &returnDouble);	
	if ( !success )	{ return success; }
	par->boundingRect.left = (int)returnDouble;
	
	success = imaqMeasureParticle(image, particleNumber, 0, IMAQ_MT_BOUNDING_RECT_HEIGHT, &returnDouble);	
	if ( !success )	{ return success; }
	par->boundingRect.height = (int)returnDouble;	

	success = imaqMeasureParticle(image, particleNumber, 0, IMAQ_MT_BOUNDING_RECT_WIDTH, &returnDouble);	
	if ( !success )	{ return success; }
	par->boundingRect.width = (int)returnDouble;	
	
	/* particle quality statistics */ 
	success = imaqMeasureParticle(image, particleNumber, 0, IMAQ_MT_AREA_BY_IMAGE_AREA, &returnDouble);	
	if ( !success )	{ return success; }
	par->particleToImagePercent = returnDouble;

	success = imaqMeasureParticle(image, particleNumber, 0, IMAQ_MT_AREA_BY_PARTICLE_AND_HOLES_AREA, &returnDouble);	
	if ( !success )	{ return success; }
	par->particleQuality = returnDouble;
		
	/* normalized position (-1 to 1) */
	par->center_mass_x_normalized = RangeToNormalized(par->center_mass_x, width);
	par->center_mass_y_normalized = RangeToNormalized(par->center_mass_y, height);	
	
	return success;
}


/*   Image Enhancement functions */

/**
* @brief Improves contrast on a grayscale image. 
* Supports IMAQ_IMAGE_U8, IMAQ_IMAGE_I16.
* @param dest The destination image.
* @param source The image to equalize 
* @param min the smallest value used for processing. After processing, all pixel values that are less than or equal to the Minimum in the original image are set to 0 for an 8-bit image. In 16-bit and floating-point images, these pixel values are set to the smallest pixel value found in the original image. 
* @param max the largest value used for processing. After processing, all pixel values that are greater than or equal to the Maximum in the original image are set to 255 for an 8-bit image. In 16-bit and floating-point images, these pixel values are set to the largest pixel value found in the original image. 
* @param mask an 8-bit image that specifies the region of the small image that will be copied. Only those pixels in the Image Src (Small) image that correspond to an equivalent non-zero pixel in the mask image are copied. All other pixels keep their original values. The entire image is processed if Image Mask is NULL or this parameter is omitted.
* @return On success: 1. On failure: 0. To get extended error information, call GetLastError().
*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -