简体   繁体   English

CImg库中的get_convolve()函数正在使用哪个过滤器

[英]which filter is being use by get_convolve() function in CImg library

Which kind of filter is being used by CImg library's get_convolve() function(written in C)? CImg库的get_convolve()函数使用哪种过滤器(用C编写)? Median or Gaussian or bilateral or some other? 中位或高斯或双边或其他? I tried to understand the function so that I can use the similar functionality in PIL openCV. 我试图了解该功能,以便我可以在PIL openCV中使用类似的功能。 In the header file CImg.h of the library, it says: 在库的头文件CImg.h中,它说:

/**
   Compute the convolution of the image by a mask.
   The result \p res of the convolution of an image \p img by a mask \p mask is defined to be :

   res(x,y,z) = sum_{i,j,k} img(x-i,y-j,z-k)*mask(i,j,k)

   param mask = the correlation kernel.
   param cond = the border condition type (0=zero, 1=dirichlet)
   param weighted_convol = enable local normalization.
**/

Declaration is like this: 声明是这样的:

 template<typename t> CImg<typename cimg::superset2<T,t,float>::type>
  get_convolve(const CImg<t>& mask, const unsigned int cond=1, const bool weighted_convol=false) const {}

Here is a code sniplet: 这是一个代码片段:

                for (int z = mz1; z<mze; ++z) 
                for (int y = my1; y<mye; ++y) 
                for (int x = mx1; x<mxe; ++x) {// For each pixel
                  Ttfloat val = 0;
                  for (int zm = -mz1; zm<=mz2; ++zm) 
                  for (int ym = -my1; ym<=my2; ++ym) 
                      for (int xm = -mx1; xm<=mx2; ++xm)
                            val+=(*this)(x+xm,y+ym,z+zm,v)*mask(mx1+xm,my1+ym,mz1+zm);
                  dest(x,y,z,v) = (Ttfloat)val;
                }
                if (cond)
                  cimg_forYZV(*this,y,z,v)
                    for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
                      Ttfloat val = 0;
                      for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm)
                        val+=at3(x+xm,y+ym,z+zm,v)*mask(mx1+xm,my1+ym,mz1+zm);
                      dest(x,y,z,v) = (Ttfloat)val;
                 }else
                    cimg_forYZV(*this,y,z,v)

I am using the mask of 7 x 7 and each of the values inside it is '1'. 我使用7 x 7的掩码,其中的每个值都是'1'。 What I got from the function was that for each pixel, it is taking a 7 by 7 window around it, with the pixel at center and then multiplying with he Identity matrix. 我从函数得到的是,对于每个像素,它围绕着一个7乘7的窗口,像素位于中心,然后乘以身份矩阵。 It feels like some kind of smoothing filter but which one is it? 感觉就像某种平滑过滤器,但它是哪一个? Which equivalent filter can I use in openCV? 我可以在openCV中使用哪种等效过滤器?

I can post the whole function, but its too long and I don't see the point. 我可以发布整个功能,但它太长了,我没有看到这一点。 I would be really thankful for your help. 我真的很感谢你的帮助。

So, I found the answer in the thesis of the person who implemented pHash . 所以,我在实施pHash的人的论文中找到了答案。 It said: During the process of calculating pHash, a mean filter is applied to the image. 它说:在计算pHash的过程中,对图像应用平均滤波器。 A ker- nel with dimension 7x7 is used. 使用尺寸为7x7的内核。 To apply this kernel, the get_convolve() function of the CImg library is used. 要应用此内核,请使用CImg库的get_convolve()函数。 It is then highlighted as: 然后突出显示为:

For an image I and a mask M it is: R(x,y,z) = SIGMA(i,j,k) I(x − i, y − j, z − k)M (i, j, k) 对于图像I和掩模M,它是:R(x,y,z)= SIGMA(i,j,k)I(x-i,y-j,z-k)M(i,j,k)

Then when I looked at the type of filtering functions offered by openCV here , it matched with the box filter function. 然后当我在这里查看 openCV提供的过滤功能类型时,它与盒式过滤器功能相匹配。

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

相关问题 在opecv中,如何实现CImg的get_gradientXY - In opecv, how to implement get_gradientXY of CImg OpenCV GPU卷积功能和缺少的边框 - OpenCV GPU convolve function and the missing border 如何计算SVD使用CIMG(或可能的OpenCV或征库)? - How to compute SVD using Cimg (or maybe openCV or eigen library)? convolve2d 和 filter2D 之间的区别。 为什么 output 形状有差异? - Difference between convolve2d and filter2D. Why is there a difference in output shapes? 如何在 Python 中将 3 维数组(在本例中为滤波器组)与 2 维图像(单色)进行卷积? - How to convolve a 3 dimensional array (in this case a filter bank) with a 2 dimensional image (monochrome) in Python? 如何使用 OpenVINS 库获取 Position - How to use OpenVINS Library To Get Position 我应该使用哪个库进行人脸跟踪以捕获图像? - Which library should i use for face Tracking for captured image? Cimg FFT 显示噪声图像。如何获得正确的 FFT 图像? - Cimg FFt is showing noise image.How to get the proper FFT Image? 使用功能名称已在另一个使用的库中定义的库 - Using library which has a function name already defined in another used library 我可以在opencv中使用哪个函数作为matlab中的max() - Which function can I use in opencv as max() in matlab
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM