• 大小: 7.95MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-08-23
  • 语言: 其他
  • 标签: OpenCV  Criminisi  

资源简介

该算法为Criminisi算法,采取OpenCV库进行编写,适用于初学者使用

资源截图

代码片段和文件信息

/*
 * Author Rahul Verma
 * Date   26-04-2013
 */

#include “gradientcalculator.h“


GradientCalculator::GradientCalculator()
{

}

cv::Mat GradientCalculator::getGradX(){
    return this->gradX;
}

cv::Mat GradientCalculator::getGradY(){
    return this->gradY;
}


void GradientCalculator::calculateGradient(cv::Mat &src){
    this->gradX=cv::Mat(src.rowssrc.colsCV_32Fcv::Scalar::all(0));
    this->gradY=gradX.clone();

    cv::Vec3b pixel1;
    cv::Vec3b pixel0;
    cv::Vec3f pixelDiff;


    int xy;
    if(src.rows>1){

        for( x=0 ; x < src.cols ; x++ ){
            pixel1=src.at(1x);
            pixel0=src.at(0x);
            pixelDiff=pixel1-pixel0;
            gradX.at(0x)=-(pixelDiff[0]+pixelDiff[1]+pixelDiff[2])/(3*255.0);

            pixel1=src.at(src.rows-1x);
            pixel0=src.at(src.rows-2x);
            pixelDiff=pixel1-pixel0;
            gradX.at(src.rows-1x)=-(pixelDiff[0]+pixelDiff[1]+pixelDiff[2])/(3*255.0);


        }

    }

    if(src.rows>2){
        for(y=1 ; y < src.rows-1; y++){
             for(x=0 ; x < src.cols ; x++){
                 pixel1=src.at(y+1x);
                 pixel0=src.at(y-1x);
                 pixelDiff=pixel1-pixel0;
                 gradX.at(yx)=-(pixelDiff[0]+pixelDiff[1]+pixelDiff[2])/(3*255.0);

             }
        }

    }

    if(src.cols>1){

        for( y=0 ; y < src.rows ; y++ ){
            pixel1=src.at(y1);
            pixel0=src.at(y0);
            pixelDiff=pixel1-pixel0;
            gradY.at(y0)=-(pixelDiff[0]+pixelDiff[1]+pixelDiff[2])/(3*255.0);

            pixel1=src.at(ysrc.cols-1);
            pixel0=src.at(ysrc.cols-2);
            pixelDiff=pixel1-pixel0;
            gradY.at(ysrc.cols-1)=-(pixelDiff[0]+pixelDiff[1]+pixelDiff[2])/(3*255.0);


        }

    }

    if(src.cols>2){
        for(x=1 ; x < src.cols-1; x++){
             for(y=0 ; y < src.rows ; y++){
                 pixel1=src.at(yx+1);
                 pixel0=src.at(yx-1);
                 pixelDiff=pixel1-pixel0;
                 gradY.at(yx)=-(pixelDiff[0]+pixelDiff[1]+pixelDiff[2])/(3*255.0);

             }
        }

    }


}






 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        483  2013-07-27 15:49  图像修复-V2\.gitattributes

     文件       2643  2013-07-27 15:49  图像修复-V2\.gitignore

     文件       7811  2016-07-07 13:59  图像修复-V2\Cri-inpainting\Cri-inpainting.vcxproj

     文件       1387  2016-07-07 13:59  图像修复-V2\Cri-inpainting\Cri-inpainting.vcxproj.filters

     文件        754  2016-06-30 21:24  图像修复-V2\Cri-inpainting\Cri-inpainting.vcxproj.user

     文件       1030  2016-06-30 21:22  图像修复-V2\Cri-inpainting\Debug\Cri-inpainting.Build.CppClean.log

     文件       4016  2016-06-30 21:22  图像修复-V2\Cri-inpainting\Debug\Cri-inpainting.log

     文件       2172  2016-06-30 21:22  图像修复-V2\Cri-inpainting\Debug\Cri-inpainting.tlog\cl.command.1.tlog

     文件      65368  2016-06-30 21:22  图像修复-V2\Cri-inpainting\Debug\Cri-inpainting.tlog\CL.read.1.tlog

     文件       1782  2016-06-30 21:22  图像修复-V2\Cri-inpainting\Debug\Cri-inpainting.tlog\CL.write.1.tlog

     文件        163  2016-06-30 21:22  图像修复-V2\Cri-inpainting\Debug\Cri-inpainting.tlog\Cri-inpainting.lastbuildstate

     文件       2306  2016-06-30 21:22  图像修复-V2\Cri-inpainting\Debug\Cri-inpainting.tlog\link.command.1.tlog

     文件       5834  2016-06-30 21:22  图像修复-V2\Cri-inpainting\Debug\Cri-inpainting.tlog\link.read.1.tlog

     文件        644  2016-06-30 21:22  图像修复-V2\Cri-inpainting\Debug\Cri-inpainting.tlog\link.write.1.tlog

     文件     388710  2016-06-30 21:22  图像修复-V2\Cri-inpainting\Debug\gradientcalculator.obj

     文件     569695  2016-06-30 21:22  图像修复-V2\Cri-inpainting\Debug\inpainter.obj

     文件     488962  2016-06-30 21:22  图像修复-V2\Cri-inpainting\Debug\main.obj

     文件     855040  2016-06-30 21:22  图像修复-V2\Cri-inpainting\Debug\vc120.idb

     文件    1314816  2016-06-30 21:22  图像修复-V2\Cri-inpainting\Debug\vc120.pdb

     文件       4078  2016-06-30 09:55  图像修复-V2\Cri-inpainting\Release\Cri-inpainting.log

     文件       2232  2016-06-30 09:55  图像修复-V2\Cri-inpainting\Release\Cri-inpainting.tlog\cl.command.1.tlog

     文件      65368  2016-06-30 09:55  图像修复-V2\Cri-inpainting\Release\Cri-inpainting.tlog\cl.read.1.tlog

     文件       1702  2016-06-30 09:55  图像修复-V2\Cri-inpainting\Release\Cri-inpainting.tlog\cl.write.1.tlog

     文件        165  2016-06-30 09:55  图像修复-V2\Cri-inpainting\Release\Cri-inpainting.tlog\Cri-inpainting.lastbuildstate

     文件          2  2016-06-30 09:55  图像修复-V2\Cri-inpainting\Release\Cri-inpainting.tlog\link.command.1.tlog

     文件          2  2016-06-30 09:55  图像修复-V2\Cri-inpainting\Release\Cri-inpainting.tlog\link.read.1.tlog

     文件          2  2016-06-30 09:55  图像修复-V2\Cri-inpainting\Release\Cri-inpainting.tlog\link.write.1.tlog

     文件          0  2016-06-30 09:55  图像修复-V2\Cri-inpainting\Release\Cri-inpainting.tlog\unsuccessfulbuild

     文件    2000318  2016-06-30 09:55  图像修复-V2\Cri-inpainting\Release\gradientcalculator.obj

     文件    2087006  2016-06-30 09:55  图像修复-V2\Cri-inpainting\Release\inpainter.obj

............此处省略70个文件信息

评论

共有 条评论