• Status: Solved
• Priority: Medium
• Security: Public
• Views: 201

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]);
}
0
killaz4life
• 2
1 Solution

Commented:
For one, define P as :

int P[ROW + 2][COL + 2];
0

Author 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

Commented:
Still the same ... P needs to be 2 columns wider and 2 rows wider than the image
0

Featured Post

• 2
Tackle projects and never again get stuck behind a technical roadblock.