OpenCvSharp学习(十四):重映射

重映射 Remap

重映射是指把一个图像指定位置的像素通过映射关系转到另一个图像的指定位置
函数原型

public static void Remap(InputArray src, OutputArray dst, InputArray map1, InputArray map2, InterpolationFlags interpolation = InterpolationFlags.Linear, BorderTypes borderMode = BorderTypes.Constant, Scalar? borderValue = null);
参数说明
src数据源图像
dst目的地形象。它的大小与map1相同,类型与src相同
map1The first map of either (x,y) points or just x values having the type CV_16SC2,CV_32FC1, or CV_32FC2.
map2The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map if map1 is (x,y) points), respectively.
interpolationInterpolation method. The method INTER_AREA is not supported by this function.
borderModePixel extrapolation method. When borderMode=BORDER_TRANSPARENT, it means that the pixels in the destination image that corresponds to the “outliers” in the source image are not modified by the function.
borderValueValue used in case of a constant border. By default, it is 0.
 Mat mat = new Mat(@"I:\OpenCvSharp学习\4.jpg", ImreadModes.AnyColor);
            Window window = new Window("源图像", WindowMode.Normal, mat);
            Mat MapMat1 = new Mat(mat.Size(),MatType.CV_32FC1);
            Mat MapMat2 = new Mat(mat.Size(), MatType.CV_32FC1);
            for (int j = 0; j < mat.Rows; j++)
            {
                for (int i = 0; i < mat.Cols; i++)
                {
                    MapMat1.At<float>(j, i) = (float)(i);
                    MapMat2.At<float>(j, i) = (float)(mat.Rows - j);
                }
            }
            Mat mat2 = new Mat();
            Cv2.Remap(mat, mat2,MapMat1,MapMat2);
            Window window1 = new Window("源图像1", WindowMode.Normal, mat2);
            Cv2.WaitKey(0);

在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值