图像旋转变换后边缘锯齿的处理

本文探讨了图像旋转变换后出现的边缘锯齿问题,提出了两种处理方法。一种是针对已知边缘映射的图像,直接应用高斯平滑处理边缘;另一种是未知映射方式时,利用Canny算子提取边缘并用平滑边缘替换。作者倾向于只处理四周边缘的策略,以保留图像中心的细节。
摘要由CSDN通过智能技术生成

对于图像边缘锯齿的处理想法是对图像的边缘使用高斯平滑处理去除锯齿,对于图像的其他非边缘则保持不变。

至于找图像边缘,如果知道图像边缘的映射方式,可以直接用变换公式处理;不知道映射方式的情况下,通常选用Canny算子提取边缘。

1 . 对于旋转图像时产生的边缘图像锯齿处理(知道边缘的映射方式)

void rotateImg(CvMat* src, CvMat* dst, double angle)
{
    double tempX = 0.0;
    double tempY = 0.0;
    angle = 3.14 * angle/180.0;
    for(int y = 0; y < dst->height; y++)
    {
        for(int x = 0; x < dst->width; x++)
        {
            tempY = src->height/2 + (y - src->height/2)*cos(angle) + (x - src->width/2) *sin(angle);
            tempX = src->width/2 -  (y - src->height/2)*sin(angle) + (x - src->width/2) *cos(angle);
            if(tempX >= 0 && tempX < src->width && tempY >=0 && tempY < src->height)
            {
                *(dst->data.ptr + y * dst->width + x) = saturate_cast<uchar>(cvmGet(src,tempY,tempX));
            }else
            {
                *(dst->data.ptr + y * dst->width + x) = 0;
            }
        }
    }
} // 旋转变换
void getedgeimg(IplImage *src, IplImage *dst)
{
    for(int idx = 0 ; idx < src->width;idx++)
    {
        for(int idy = 0; idy < src->height;idy++)
        {
            if(idx <= 0 || idy <= 0 || idx >= src->width -1 || idy >= src->width -1)
            {
                CV_IMAGE_ELEM(dst,uchar,idy,idx) = CV_IMAGE_ELEM(src,uchar,idy,idx);
            }
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值