当前位置: 首页>>代码示例>>C++>>正文


C++ Segmentation::fuzzy方法代码示例

本文整理汇总了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;
}
开发者ID:Elima85,项目名称:LatticeLibrary,代码行数:101,代码来源:mrisegmentationhighres.cpp


注:本文中的Segmentation::fuzzy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。