Beispiel #1
0
/*************************************************************************
* @函数名称:
*	calGradSim()
* @输入:
*   const IplImage* image1           - 输入图像1
*   const IplImage* image2           - 输入图像2
* @返回值:
*   double g			             - 梯度相似性
* @说明:
*   计算图像梯度相似性
*************************************************************************/
double calGradSim(const IplImage* image1, const IplImage* image2)
{
	double c4 = 0;   
	double g = 0;

	IplImage* g1;
	IplImage* g2;
	IplImage* tmp;

	g1=gradientImage(image1);
	g2=gradientImage(image2);
	tmp = cvCloneImage(g1);

	cvMul(g1, g2, tmp);
	cvMul(g1, g1, g1);
	cvMul(g2, g2, g2);

	CvScalar s1 = cvSum(tmp);
	CvScalar s2 = cvSum(g1);
	CvScalar s3 = cvSum(g2);

	c4 = (0.03 * 255) * (0.03 * 255);
	g = (2 * s1.val[0] + c4) / (s2.val[0] +s3.val[0] + c4);

	cvReleaseImage(&g1);
	cvReleaseImage(&g2);
	cvReleaseImage(&tmp);

	return g;
}
Beispiel #2
0
void FeatureEval::sobel_erode(){
    boost::shared_ptr<PointCloud> cloud = core_->cl_->active_;
    if(cloud == nullptr)
        return;
    int h = cloud->scan_width();
    int w = cloud->scan_height();

    // Create distance map
    boost::shared_ptr<std::vector<float>> distmap = makeDistmap(cloud);

    boost::shared_ptr<std::vector<float> > grad_image = gradientImage(distmap, w, h);
    boost::shared_ptr<std::vector<float> > smooth_grad_image = convolve(grad_image, w, h, gaussian, 5);

    // Threshold && Erode

    const int strct[] = {
        0, 1, 0,
        1, 0, 1,
        0, 1, 0,
    };

    boost::shared_ptr<std::vector<float> > dilated_image =  morphology(
            smooth_grad_image,
            w, h, strct, 3, Morphology::ERODE,
            grad_image); // <-- reuse

    drawFloats(dilated_image, cloud);
}
Beispiel #3
0
int main( int argc, char** argv )
{
    osg::ArgumentParser arguments( &argc, argv );
    
    osg::ref_ptr<osg::MatrixTransform> scene = new osg::MatrixTransform;
    scene->addChild( createImageQuad(gradientImage(), osg::Vec3()) );
    scene->addChild( createImageQuad(textImage(), osg::Vec3(1.1f, 0.0f, 0.0f)) );
    
    osgViewer::Viewer viewer;
    viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
    viewer.addEventHandler( new osgViewer::StatsHandler );
    viewer.addEventHandler( new osgViewer::WindowSizeHandler );
    viewer.setSceneData( scene.get() );
    return viewer.run();
}
Beispiel #4
0
void FeatureEval::sobel_blur(){
    boost::shared_ptr<PointCloud> cloud = core_->cl_->active_;
    if(cloud == nullptr)
        return;
    int h = cloud->scan_width();
    int w = cloud->scan_height();

    // Create distance map
    boost::shared_ptr<std::vector<float>> distmap = makeDistmap(cloud);

    boost::shared_ptr<std::vector<float> > smooth_grad_image = gradientImage(distmap, w, h);
    int blurs = 0;
    for(int i = 0; i < blurs; i++)
        smooth_grad_image = convolve(smooth_grad_image, w, h, gaussian, 5);

    drawFloats(smooth_grad_image, cloud);
}