Project

General

Profile

Statistics
| Branch: | Revision:

root / vision / cvblobs8.3 / testBlobs / example.txt @ b11b2b30

History | View | Annotate | Download (1.08 KB)

1
	/**
2
		Example of extracting and filtering the blobs of an image
3
	*/
4
	
5
	// object that will contain blobs of inputImage
6
	CBlobResult blobs;
7
	
8
	// Extract the blobs using a threshold of 100 in the image
9
	blobs = CBlobResult( inputImage, NULL, 100, true );
10

    
11
	// create a file with some of the extracted features
12
	blobs.PrintBlobs( "c:\\tmp\\blobs.txt" );
13

    
14
	// discard the blobs with less area than 5000 pixels
15
	// ( the criteria to filter can be any class derived from COperadorBlob )
16
	blobs.Filter( blobs, B_INCLUDE, CBlobGetArea(), B_GREATER, 5000 );
17
	// create a file with filtered results
18
	blobs.PrintBlobs( "c:\\tmp\\filteredBlobs.txt" );
19

    
20
	// object with the blob with most perimeter in the image
21
	// ( the criteria to select can be any class derived from COperadorBlob )
22
	CBlob blobWithBiggestPerimeter, CBlob blobWithLessArea;
23

    
24
	// from the filtered blobs, get the blob with biggest perimeter
25
	blobs.GetNthBlob( CBlobGetPerimeter(), 0, blobWithBiggestPerimeter );
26
	// get the blob with less area
27
	blobs.GetNthBlob( CBlobGetArea(), blobs.GetNumBlobs() - 1, blobWithLessArea );
28