Image Processing Using Sobel Operator
Image Processing Using Sobel Operator
Image Processing Using Sobel Operator
{
for(j=1; j<widthm1; j++)
{
newValue=0;
for(mr=0;mr<3;mr++)
for(mc=0;mc<3;mc++)
newValue += (MaskSobelX[mr][mc]*m_InImg[i+mr-1][j+mc-1]);
pImgSobelX[i*width+j]=newValue;
}
}
for(i=1; i<heightm1; i++)
{
for(j=1; j<widthm1; j++)
{
newValue=0;
for(mr=0;mr<3;mr++)
for(mc=0;mc<3;mc++)
newValue += (MaskSobelY[mr][mc]*m_InImg[i+mr-1][j+mc-1]);
pImgSobelY[i*width+j]=newValue;
}
}
for(i=1;i<heightm1;i++)
for(j=1;j<widthm1;j++)
{
where=i*width+j;
constVal1=pImgSobelX[where];
constVal2=pImgSobelY[where];
if(constVal1<0)
constVal1=-constVal1;
if(constVal2<0)
constVal2=-constVal2;
pImgSobelX[where]=constVal1+constVal2;
}
min=(int)10e10;
max=(int)-10e10;
for(i=1; i<heightm1; i++)
{
for(j=1; j<widthm1; j++)
{
newValue=pImgSobelX[i*width+j];
if(newValue<min)
min=newValue;
if(newValue>max)
max=newValue;
}
}
constVal1=(float)(255.0/(max-min));
constVal2=(float)(-255.0*min/(max-min));
for(i=1; i<heightm1; i++)
{