opencv用过函数回忆

Gaussian pyramid(高斯金字塔)
Laplacian pyramid(拉普拉斯金字塔)

pyrup(image1,image1,Size(),borderType)
pyrdown(image1,image1,Size(),borderType)

注:Size()要与原图大小遵循一定关系,否则会崩溃,尽量用默认,即放大一倍或缩小一倍。

这里写图片描述

这里是效果….
这里为倒金字塔,金字塔向下时,即图像变小,此时会丢失一些信息。当金字塔向上时,图像变大,用原来学习预测变大后图片信息(与与指定滤波器卷积)。因此在将图像变小,再变大后,图片会出现模糊。

resize( InputArray src, OutputArray dst,
                          Size dsize, double fx=0, double fy=0,
                          int interpolation=INTER_LINEAR );

size为图片大小,可以这样用Size(cols*k,rows*k)
而fx和fy是与原来图片来比的缩放尺度。
这里两者选其一就可以。

    CV_INTER_NN        =0,
    CV_INTER_LINEAR    =1,
    CV_INTER_CUBIC     =2,
    CV_INTER_AREA      =3,
    CV_INTER_LANCZOS4  =4

这里有几种插值方式,一般放大用CV_INTER_AREA,缩小用 CV_INTER_LINEAR


**漫水填充**
floodFill( InputOutputArray image,Point seedPoint, Scalar newVal, CV_OUT Rect* rect=0, Scalar loDiff=Scalar(), Scalar upDiff=Scalar(), int flags=4 );

seedPoint开始的点
newVal填充颜色
rect 粉刷域的最小边界
loDiff Maximal lower brightness/color difference between the currently observed pixel and one of its neighbors belonging to the component, or a seed pixel being added to the component.(即临近点与最低亮度的可取范围)
upDiff Maximal upper brightness/color difference between the currently observed pixel and one of its neighbors belonging to the component, or a seed pixel being added to the component.(同理,默认为零)
flags :Operation flags. The first 8 bits contain a connectivity value. The default value of 4 means that only the four nearest neighbor pixels (those that share an edge) are considered. A connectivity value of 8 means that the eight nearest neighbor pixels (those that share a corner) will be considered. The next 8 bits (8-16) contain a value between 1 and 255 with which to fill the mask (the default value is 1). For example, 4 | ( 255 << 8 ) will consider 4 nearest neighbours and fill the mask with a value of 255. The following additional options occupy higher bits and therefore may be further combined with the connectivity and mask fill values using bit-wise or (|):(四邻域和八邻域,分别为4,8,其余能懂再更新)

效果
这里写图片描述

用指针访问Mat像素

for (int i = 0; i < image1.rows; i++)
    {
        uchar* data = image1.ptr<uchar>(i);
        for (int j = 0; j < image1.cols*image1.channels(); j++)
        {
            data[j] = 100;
        }
    }

注意多通道图片

remap使用
remap( InputArray src, OutputArray dst,InputArray map1, InputArray map2,int interpolation, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar());


其中map1是水平放置信息,map2为竖直放置信息,interpolation为插值方式,有
CV_INTER_NN        =0,
CV_INTER_LINEAR    =1,
CV_INTER_CUBIC     =2,
CV_INTER_AREA      =3,
CV_INTER_LANCZOS4  =4


使用例子

for (int i = 0; i < image1.rows; i++)
{
for (int j = 0; j < image1.cols; j++)
{
map_1.at(i, j) = image1.cols-j;
map_2.at(i, j) = i;
}
}

remap(image1, image2, map_1, map_2, INTER_AREA);
“`

这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值