#include <iostream>
#include "vigra/stdimage.hxx"
#include "vigra/stdimagefunctions.hxx"
#include "vigra/localminmax.hxx"
#include "vigra/labelimage.hxx"
#include "vigra/seededregiongrowing.hxx"
using namespace vigra;
struct GradientSquaredMagnitudeFunctor
{
float operator()(float const & g1, float const & g2) const
{
return g1 * g1 + g2 * g2;
}
{
return g1 + g2;
}
};
template <class InImage, class OutImage>
void watershedSegmentation(InImage & in, OutImage & out, double scale)
{
typedef typename vigra::NumericTraits<typename InImage::value_type>::RealPromote
TmpType;
int w = in.width();
int h = in.height();
destImage(gradientmag), GradientSquaredMagnitudeFunctor());
labels = 0;
int max_region_label =
false, 0);
gradstat(max_region_label);
destImage(labels), gradstat);
averages(max_region_label);
vigra::NumericTraits<typename OutImage::value_type>::zero());
}
int main(int argc, char ** argv)
{
if(argc != 3)
{
std::cout << "Usage: " << argv[0] << " infile outfile" << std::endl;
return 1;
}
try
{
double scale = 1.0;
std::cout << "Scale for gradient calculation ? ";
std::cin >> scale;
if(info.isGrayscale())
{
int w = info.width();
int h = info.height();
watershedSegmentation(in, out, scale);
std::cout << "Writing " << argv[2] << std::endl;
}
else
{
int w = info.width();
int h = info.height();
watershedSegmentation(in, out, scale);
std::cout << "Writing " << argv[2] << std::endl;
}
}
catch (vigra::StdException & e)
{
std::cout << e.what() << std::endl;
return 1;
}
return 0;
}