Which kind of filter is being used by CImg library's get_convolve() function(written in 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. In the header file CImg.h of the library, it says:

/**
   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'. 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. It feels like some kind of smoothing filter but which one is it? Which equivalent filter can I use in 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. It said: During the process of calculating pHash, a mean filter is applied to the image. A ker- nel with dimension 7x7 is used. To apply this kernel, the get_convolve() function of the CImg library is used. 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)

Then when I looked at the type of filtering functions offered by openCV here, it matched with the box filter function.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top