You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1.1 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /**
  2. Example of extracting and filtering the blobs of an image
  3. */
  4. // object that will contain blobs of inputImage
  5. CBlobResult blobs;
  6. // Extract the blobs using a threshold of 100 in the image
  7. blobs = CBlobResult( inputImage, NULL, 100, true );
  8. // create a file with some of the extracted features
  9. blobs.PrintBlobs( "c:\\tmp\\blobs.txt" );
  10. // discard the blobs with less area than 5000 pixels
  11. // ( the criteria to filter can be any class derived from COperadorBlob )
  12. blobs.Filter( blobs, B_INCLUDE, CBlobGetArea(), B_GREATER, 5000 );
  13. // create a file with filtered results
  14. blobs.PrintBlobs( "c:\\tmp\\filteredBlobs.txt" );
  15. // object with the blob with most perimeter in the image
  16. // ( the criteria to select can be any class derived from COperadorBlob )
  17. CBlob blobWithBiggestPerimeter, CBlob blobWithLessArea;
  18. // from the filtered blobs, get the blob with biggest perimeter
  19. blobs.GetNthBlob( CBlobGetPerimeter(), 0, blobWithBiggestPerimeter );
  20. // get the blob with less area
  21. blobs.GetNthBlob( CBlobGetArea(), blobs.GetNumBlobs() - 1, blobWithLessArea );