OpenCV图像大小比较到matlab [英] OpenCV image resize comparison to matlab

查看:333
本文介绍了OpenCV图像大小比较到matlab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是我的函数

  int * Utilities :: MatlabImresize(int * channel,int width,int height,double scale )
{
cv :: Mat src(width,height,CV_32F);
for(int i = 0; i {
src.at< float>(i)= channel [i]
}
cv :: Mat dst;
cv :: resize(src,dst,cv :: Size(),0.5,0.5,cv :: INTER_CUBIC);
ofstream myfile;
myfile.open(C:\\Users\\gdarmon\\Desktop\\OpenCV_CR.txt);
myfile<< dst;
myfile.close();

return NULL;
}

正如我上一个问题 imresize - 试图理解双三次插值
我已经重新编译openCV与 - 0.5f 而不是 -0.75f



输入是相同的,我想我使用resize()函数错误...可以帮助吗?



matlab代码只是

  Gr = imresize(Gr,0,5); 


解决方案

更改为OpenCV只会使插值内核公式匹配。它不启用抗锯齿。这里的结果将与

匹配

  imresize(A,scale,'bicubic','AntiAliasing',false)



要匹配默认值,您需要进一步修改内核,使其更宽。


here is my function

int* Utilities::MatlabImresize(int* channel,int width, int height, double scale)
{
    cv::Mat src(width, height, CV_32F);
    for (int i = 0; i < width * height; ++i)
    {
        src.at<float>(i) = channel[i];      
    }
    cv::Mat dst;
    cv::resize(src, dst, cv::Size(), 0.5, 0.5,cv::INTER_CUBIC);
    ofstream myfile;
    myfile.open("C:\\Users\\gdarmon\\Desktop\\OpenCV_CR.txt");
    myfile << dst;
    myfile.close();

    return NULL;
}

As discussed in my previous question imresize - trying to understand the bicubic interpolation I have recompiled openCV with -0.5f instead of -0.75f

however I still get different results although the input is the same, I guess i'm using resize() function wrong... can you please help?

the matlab code is just

Gr = imresize(Gr, 0,5);

解决方案

That change to OpenCV only makes the interpolation kernels' formulas match. It does not enable anti-aliasing. The result here will match with

imresize(A,scale,'bicubic','AntiAliasing',false)

To match the default, you'd need to further modify the kernel, making it broader.

这篇关于OpenCV图像大小比较到matlab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆