public void applyBRMeanMask(int Rad)
 {
  double cc=(2*Rad+1)*(2*Rad+1)-1;
  if (!im_done) return;
  Graphics gg=cv.getGraphics();

  for (int x=Rad;x<wi-Rad;x++)
   for (int y=Rad;y<he-Rad;y++)
  {
   gg.setColor(Color.white);
   gg.drawLine(x,y,x+1,y);

  int sumR=0,sumG=0,sumB=0;
  for (int i=-Rad;i<=Rad;i++)
  for (int j=-Rad;j<=Rad;j++)
   if (i!=0 || j!=0)
    {
      sumR+=R[(y+i)*wi+(x+j)];
      sumG+=G[(y+i)*wi+(x+j)];
      sumB+=B[(y+i)*wi+(x+j)];
    }
  short newR=(short)(sumR/cc+0.5);
  short newG=(short)(sumG/cc+0.5);
  short newB=(short)(sumB/cc+0.5);

  if ((newR+newG+newB) > (resR[y*wi+x]+resG[y*wi+x]+ resB[y*wi+x]))
  {
   resR[y*wi+x]=newR;
   resG[y*wi+x]=newG;
   resB[y*wi+x]=newB;
  }
   gg.setColor(new Color(resR[y*wi+x], resG[y*wi+x], resB[y*wi+x]));
   gg.drawLine(x,y,x,y);
  }
 }