Example #1
0
    // input: one imgPtr (float32)
    // returns an IntegralImage< IntegralImagePixelType = float > image
    DLL_EXPORT 
    void computeIntegralImage( IntegralImagePixelType *rawImgPtr,
                               int width, int height, int depth,
                               IntegralImagePixelType *integralImagePtr)
    {

        Matrix3D<IntegralImagePixelType> integralMatrix;
        integralMatrix.fromSharedData( integralImagePtr, width, height, depth );

        Matrix3D<IntegralImagePixelType> rawImageMatrix;
        rawImageMatrix.fromSharedData( rawImgPtr, width, height, depth );

        IntegralImage<IntegralImagePixelType>::staticCompute( integralMatrix, rawImageMatrix );

    }
Example #2
0
    // Prediction
    //  Accepts a single integral image/channel, thus only to be used for testing
    //  Assumes that predPtr is already allocated, of same size as imgPtr
    DLL_EXPORT
    void predictWithChannel( void *modelPtr, ImagePixelType *imgPtr,
                              IntegralImagePixelType *chImgPtr,
                              int width, int height, int depth,
                              PredictionPixelType *predPtr )
    {
        Matrix3D<PredictionPixelType> predMatrix;
        predMatrix.fromSharedData( predPtr, width, height, depth );

        // create roi for image, no GT available
        ROIData roi;
        roi.init( imgPtr, 0, 0, 0, width, height, depth );

        // get the precomputed integral images
        ROIData::IntegralImageType ii;
        ii.fromSharedData(chImgPtr, width, height, depth);
        roi.addII( ii.internalImage().data() );

        MultipleROIData allROIs;
        allROIs.add( shared_ptr_nodelete(ROIData, &roi) );

        Booster adaboost;
        adaboost.setModel( *((BoosterModel *) modelPtr) );

        adaboost.predict<false>( allROIs, &predMatrix );
    }
Example #3
0
    // Prediction for a single ROI
    //  Accepts an arbitrary number of integral images/channels.
    //  Assumes that predPtr is already allocated, of same size as imgPtr
    //  Returns 0 if ok
    DLL_EXPORT
    int predictWithChannels( void *modelPtr, ImagePixelType *imgPtr,
                              void *eigVecImgPtr,
                              int width, int height, int depth,
                              IntegralImagePixelType **chImgPtr,
                              int numChannels, double zAnisotropyFactor,
                              int useEarlyStopping,
                              int useROI, int x1, int y1, int z1, int x2, int y2, int z2, // used only if useROI != 0
                              PredictionPixelType *predPtr )
    {
        Matrix3D<PredictionPixelType> predMatrix;
        predMatrix.fromSharedData( predPtr, width, height, depth );

        // create roi for image, no GT available
        ROIData roi;
        roi.init( imgPtr, 0, 0, 0, width, height, depth, zAnisotropyFactor, 0.0, (const ROIData::RotationMatrixType *) eigVecImgPtr );
        std::unique_ptr<ROIData::IntegralImageType[]> ii(new ROIData::IntegralImageType[numChannels]);  // TODO: remove

        for (int ch=0; ch < numChannels; ch++)
        {
           ii[ch].fromSharedData(chImgPtr[ch], width, height, depth);

           roi.addII( ii[ch].internalImage().data() );
        }

        MultipleROIData allROIs;
        allROIs.add( shared_ptr_nodelete(ROIData, &roi) );

        try
        {
            Booster adaboost;
            adaboost.setModel( *((BoosterModel *) modelPtr) );
            if(useEarlyStopping != 0)
            {
                if (useROI)
                {
                    ROICoordinates subROI;
                    subROI.x1 = x1; subROI.y1 = y1; subROI.z1 = z1;
                    subROI.x2 = x2; subROI.y2 = y2; subROI.z2 = z2;
                    
                    adaboost.predictWithFeatureOrdering<true>( allROIs, &predMatrix, 0, IIBOOST_NUM_THREADS, &subROI );
                }
                else
                    adaboost.predictWithFeatureOrdering<true>( allROIs, &predMatrix );
            }
            else
                adaboost.predictWithFeatureOrdering<false>( allROIs, &predMatrix );
        }
        catch( std::exception &e )
        {
            printf("Error in prediction: %s\n", e.what());
            return -1;
        }

        return 0;
    }
Example #4
0
    /*** Eigenvectors of Image wrappers ****/
    DLL_EXPORT
    void *computeEigenVectorsOfHessianImage( ImagePixelType *imgPtr, 
                                      int width, int height, int depth,
                                      double zAnisotropyFactor,
                                      double sigma )
    {
        Matrix3D<ImagePixelType> rawImg;
        rawImg.fromSharedData( imgPtr, width, height, depth );

        // compute eigen stuff
        ROIData::ItkEigenVectorImageType::Pointer rotImg = 
                AllEigenVectorsOfHessian::allEigenVectorsOfHessian<ImagePixelType>( 
                    sigma, zAnisotropyFactor, rawImg.asItkImage(), 
                    AllEigenVectorsOfHessian::EByMagnitude );

        rotImg->GetPixelContainer()->SetContainerManageMemory(false);

        return rotImg->GetPixelContainer()->GetImportPointer();
    }