本文整理汇总了C++中Segmentation::fuzzy方法的典型用法代码示例。如果您正苦于以下问题:C++ Segmentation::fuzzy方法的具体用法?C++ Segmentation::fuzzy怎么用?C++ Segmentation::fuzzy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Segmentation
的用法示例。
在下文中一共展示了Segmentation::fuzzy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
if (fabs(seedImage(elementIndex, label) - 1) < EPSILONT) {
tmp.push_back(Seed(Seed(elementIndex, label)));
}
}
seedPoints.push_back(tmp);
}
//std::cout << "Extracted seedpoints:" << std::endl;
//std::cout << "\tlabel 1: " << seedPoints[0].size() << std::endl;
//std::cout << "\tlabel 2: " << seedPoints[1].size() << std::endl;
//std::cout << "\tlabel 3: " << seedPoints[2].size() << std::endl;
//std::cout << "\tlabel 4: " << seedPoints[3].size() << std::endl;
//std::cout << "\tlabel 5: " << seedPoints[4].size() << std::endl;
// distance measure
Norm<double> *norm;
switch (normType) {
case 'm':
norm = new MaximumNorm<double>;
break;
case 'p':
norm = new PNorm<double>(2);
break;
case '*':
norm = new ProductNorm<double>;
break;
default:
exit(1);
}
SeededDistanceMeasure<double> *distanceMeasure;
switch (distanceMeasureType) {
case 'a':
distanceMeasure = new ApproximateMinimumBarrierDistance<double>(*norm);
break;
case 'c':
distanceMeasure = new FuzzyConnectedness<double>(*norm);
break;
case 'f':
distanceMeasure = new FuzzyDistance<double>(*norm);
break;
case 'g':
distanceMeasure = new GeodesicDistance<double>;
break;
case 'm':
distanceMeasure = new MinimumBarrierDistance<double>;
break;
default:
exit(1);
}
// distance transform
double *distanceTransformData = new double[nElements];
Image<double> distanceImage(distanceTransformData, lattice, 1);
int *rootData = new int[nElements];
Image<int> rootImage(rootData, lattice, 1);
SeededDistanceTransform seededDistanceTransform;
seededDistanceTransform.applySingleLayer(inputImage, seedPoints, *distanceMeasure, neighborhoodSize, distanceImage, rootImage);
writeVolume("distancetransform.bin", distanceTransformData, nElements);
// segmentation
Segmentation segmentation;
double *fuzzySegmentationData = new double[nElements * nLabels];
//double *fuzzySegmentationData = readVolume(segmentationFilename, nElements * nLabels);
Image<double> fuzzySegmentationImage(fuzzySegmentationData, *lattice, nLabels);
IntensityWorkset<double> fuzzySegmentation(fuzzySegmentationImage, 0, 1);
// save segmentation
segmentation.fuzzy(distanceImage, neighborhoodSize, fuzzySegmentation);
writeVolume(segmentationFilename, fuzzySegmentationData, nElements * nLabels);
ObjectSurfaceAreaFromVoronoiCellIntersection<double> surfaceAreaComputer;
double area;
area = surfaceAreaComputer.compute(fuzzySegmentation, 4);
cout << "small tomato surface area: " << area << endl;
area = surfaceAreaComputer.compute(fuzzySegmentation, 3);
cout << "large tomato surface area: " << area << endl;
area = surfaceAreaComputer.compute(fuzzySegmentation, 2);
cout << "avocado surface area: " << area << endl;
area = surfaceAreaComputer.compute(fuzzySegmentation, 1);
cout << "margarine surface area: " << area << endl;
ObjectVolumeFromCoverage<double> volumeComputer;
double volume;
volume = volumeComputer.compute(fuzzySegmentation, 4);
cout << "small tomato volume: " << volume << endl;
volume = volumeComputer.compute(fuzzySegmentation, 3);
cout << "large tomato volume: " << volume << endl;
volume = volumeComputer.compute(fuzzySegmentation, 2);
cout << "avocado volume: " << volume << endl;
volume = volumeComputer.compute(fuzzySegmentation, 1);
cout << "margarine volume: " << volume << endl;
delete seedData;
delete volumeData;
delete rootData;
delete distanceTransformData;
delete fuzzySegmentationData;
delete norm;
delete distanceMeasure;
return 0;
}