简体   繁体   English

使用cvfilter2d的opencv。 我的图像越来越黑

[英]opencv with cvfilter2d. I'm getting black image

I'm trying to aplicate an image filter with cvfilter2d 我正在尝试使用cvfilter2d复制图像过滤器

    cvmSet(kernel,0,0,5);
    cvmSet(kernel,0,1,5);
    cvmSet(kernel,0,2,5);   
    cvmSet(kernel,1,0,-3);
    cvmSet(kernel,1,1,0);
    cvmSet(kernel,1,2,-3);
    cvmSet(kernel,2,0,-3);
    cvmSet(kernel,2,1,-3);
    cvmSet(kernel,2,2,-3);

and then I aplicate this 然后我重复这个

cvFilter2D(imgMedia,imgRestitucion , kernel, cvPoint(-1,-1) );

but my result is a black image...what can I do? 但是我的结果是黑色图像...我该怎么办? there's some alternative? 还有其他选择吗?

Thanks in advance. 提前致谢。

Finally I've found the solution about this. 终于,我找到了解决方案。

All you have to do is initialize the kernel with a cvRealScalar number. 您要做的就是使用cvRealScalar数字初始化内核。

for(int y=0;y<9;y++) {
    for(int x=0; x<9; x++) {
        cvSet2D(kernel,x,y,cvRealScalar(-0.00132704 ));
    }
}

Then you can applicate the image filter to the ker and when you use cvFilter2D you won't get black image. 然后,您可以将图像过滤器应用于内核,并且在使用cvFilter2D时不会得到黑色图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM