Skip to content

apennisi/regionprops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Regionprops

Regionprops is a C++ version of regionprops provided by Matlab.

Requirements

Regionprops requires the following packeges to build:

  • OpenCV (< 3.0)

How to use

Once you compile your own project, you can use Regionprops as follows:

cv::Mat img; //input image
cv::Mat gray; //grayscale version of the input image
cv::Mat bin; //binary version of the grayscale image

//Find contours
std::vector< std::vector<cv::Point> > contours;
std::vector<cv::Vec4i> hierarchy;
cv::findContours(bin, contours, hierarchy, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);

//select the contours that you want, for example the contour with the biggest area
std::vector<cv::Point> contour = biggest(contours); //biggest is an invented function

RegionProps regionProps(contour, gray);
Region r = regionProps.getRegion(); //r will contain all the information about the contour

Python wrapper based on cython

You need cython installed. See src/python folder. To build the python extension cd into src/python folder, edit include folders in setup.py and type following:

python setup.py build_ext --inplace

And, run test.py in src/python

An example output: alt text