#include <iostream>
#include <vigra/multi_array.hxx>
#include <vigra/stdimagefunctions.hxx>
#include <vigra/multi_convolution.hxx>
#include <vigra/multi_watersheds.hxx>
template <class InImage, class OutImage>
void watershedSegmentation(InImage & in, OutImage & out, double scale)
{
MultiArray<2, float> gradient(in.shape());
MultiArray<2, unsigned int> labeling(in.shape());
unsigned int max_region_label =
WatershedOptions().seedOptions(SeedOptions().minima()));
typedef typename NumericTraits<typename InImage::value_type>::RealPromote
TmpType;
ArrayOfRegionStatistics<FindAverage<TmpType> > averages(max_region_label);
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
{
ImageImportInfo info(argv[1]);
double scale = 1.0;
std::cout << "Scale for gradient calculation ? ";
std::cin >> scale;
if(info.isGrayscale())
{
int w = info.width();
int h = info.height();
MultiArray<2, UInt8> in(w, h), out(w, h);
watershedSegmentation(in, out, scale);
std::cout << "Writing " << argv[2] << std::endl;
}
else
{
int w = info.width();
int h = info.height();
MultiArray<2, RGBValue<UInt8> > in(w, h), out(w, h);
watershedSegmentation(in, out, scale);
std::cout << "Writing " << argv[2] << std::endl;
}
}
catch (std::exception & e)
{
std::cout << e.what() << std::endl;
return 1;
}
return 0;
}
void importImage(...)
Read an image from a file.
void exportImage(...)
Write an image to a file.
image import and export functions
std::string impexListFormats()
List the image formats VIGRA can read and write.
Label watershedsMultiArray(...)
Watershed segmentation of an arbitrary-dimensional array.
void regionImageToEdgeImage(...)
Transform a labeled image into an edge image.
@ DirectNeighborhood
use only direct neighbors
Definition: multi_fwd.hxx:187
void gaussianGradientMagnitude(...)
Calculate the gradient magnitude by means of a 1st derivatives of Gaussian filter.
void inspectTwoImages(...)
Apply read-only functor to every pixel of both images.