filtering is bugging

edited March 2017 in Questions about Code
PImage img, thresh, selective_random, random, pattern, filter_Img;
float [][] avgfilter = {{1.0/9, 1.0/9, 1.0/9}, {1.0/9, 1.0/9, 1.0/9}, {1.0/9, 1.0/9, 1.0/9}};
float [][] unsharpmask = {{0, -1, 0}, {-1, 5, -1}, {0, -1,0}};
float [][] gausian = {{1.0/16,2.0/16, 1.0/16}, {2.0/16, 4.0/16, 2.0/16}, {1.0/16, 2.0/16,1.0/16}};
void setup()
{
  img = loadImage("flower.jpg");
  img.resize(500, 400);


  filter_Img= createImage(img.width, img.height, RGB);


 // filter_Image(img, gausian,filter_Img);
  filter_Image(img, gausian);
  size(1000, 800);
}
void draw()
{
  image(img, 0, 0);
  image(filter_Img, 500, 0);

}
 void filter_Image(PImage img, float [][] filter )
{ 
  filter_Img=img.get();
  float r = 0 ; 
  float g = 0 ; 
  float b = 0 ;
  for (int i = 0; i < img.width; i++)
    for (int j=0; j < img.height; j++)
    {
      for (int m = -1; m <= 1; m++)
        for (int n =-1; n <=1; n++)
        {

          r = r +  (red(filter_Img.get(i+m, j+n)))*filter[n+1][m+1];
          g = g + (green(filter_Img.get(i+m, j+n)))*filter[n+1][m+1];
          b = b +  (blue(filter_Img.get(i+m, j+n)))*filter[n+1][m+1];
        }
      filter_Img.set(i, j, color(r, g, b));
      r=0;
      g=0;
      b=0;
    }
  filter_Img.updatePixels();
  filter_Img.save(" filter_Img.jpg");
}

   /** void filter_Image(PImage img, float [][] filter ,PImage filter_Img)
    {
      filter_Img=img.get();
      float r = 0 ; 
      float g = 0 ; 
      float b = 0 ;
      for (int i = 0; i < img.width; i++)
        for (int j=0; j < img.height; j++)
        {
          for (int m = -1; m <= 1; m++)
            for (int n =-1; n <=1; n++)
            {

          r = r +  (red(filter_Img.get(i+m, j+n)))*filter[n+1][m+1];
          g = g + (green(filter_Img.get(i+m, j+n)))*filter[n+1][m+1];
          b = b +  (blue(filter_Img.get(i+m, j+n)))*filter[n+1][m+1];
        }
      filter_Img.set(i, j, color(r, g, b));
      r=0;
      g=0;
      b=0;
    }
  filter_Img.updatePixels();
  filter_Img.save(" filter_Img.jpg");
}**/

When I write down the image as a parameter it all goesa black any help ?

Sign In or Register to comment.