Grassfire algorithm in C++
Anyone has any idea how to perform gra开发者_高级运维ssfire in c++?
I am using OpenCV library
What is the difference to the distance transform? There is a function called cv::distanceTransform, maybe that can help you.
What about the pseudocode in this link.
It goes like this:
for each row in image left to right
for each column in image top to bottom
if(pixel is in region){
set pixel to 1 + minimum value of the north east neighbours
}else{
set pixel to zero
}
}
}
for each row right to left
for each column bottom to top
if(pixel is in region){
set pixel to min(value of the pixel,1 + minimum value of the south west neighbours)
}else{
set pixel to zero
}
}
}
So this is a modified version of grassfire that I am currently using for BLOB extraction. It takes a digitized (image that has been modified such that all values are either a 1 or a 0) and returns a vector of bounding boxes with the largest first. The code is rather long but its in a public repo at https://github.com/bstadt/JHU-Robotics-compVis in the src/cvLib.cpp file. Also be aware that bounding box is a class that I wrote myself so you'll need that as well. It has its source in the src folder and a header in the include directory, so be sure to grab both of those.
精彩评论