sharpen function

Hey I have a problem with this function it supposed to sharpen an image, I also think im missing the scaling function which i do not know! image2D_Buffer is the final image, image2D is the temporary image.

void CImgProcess::simsharp()
{
      int P[559][345];
      for(int x=0;x<ROW+2;x++)
            for(int y=0;y<COL+2;y++)
                  P[x][y]=0;

      for(int x=0;x<ROW;x++)
            for(int y=0;y<COL;y++)
                  P[x+1][y+1]=(unsigned char)image2D[x][y];

      for(int x=1;x<=ROW;x++)
            for(int y=1;y<=COL;y++)
                  image2D_Buffer[x-1][y-1]=(unsigned char)5*P[x][y]-(P[x+1][y]+P[x-1][y]+P[x][y+1]+P[x][y-1]);
}
killaz4lifeAsked:
Who is Participating?
 
Infinity08Connect With a Mentor Commented:
For one, define P as :

     int P[ROW + 2][COL + 2];
0
 
killaz4lifeAuthor Commented:
sorry this is the updated simsharp

void CImgProcess::simsharp()
{
     int P[240][320];
     for(int x=0;x<ROW;x++)
          for(int y=0;y<COL;y++)
               P[x][y]=0;

     for(int x=0;x<ROW;x++)
          for(int y=0;y<COL;y++)
               P[x][y]=(unsigned char)image2D[x][y];

     for(int x=1;x<=ROW;x++)
          for(int y=1;y<=COL;y++)
               image2D_Buffer[x][y]=(unsigned char)5*P[x][y]-(P[x+1][y]+P[x-1][y]+P[x][y+1]+P[x][y-1]);
}
0
 
Infinity08Commented:
Still the same ... P needs to be 2 columns wider and 2 rows wider than the image
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.