/*****中值滤波处理*********/
void MedianFilter()
{
int i,j,a,b;
Uint8 aValue[9],bTemp;
for(i=0;i<288;i++)
{
for(j=0;j<720;j++)
{
/*屏幕上奇数行进行处理*/
aValue[0] = (*(Uint8 *)(tempSrcYbuffer + (numLines/2+i-1)*numPixels + (j-1)));
aValue[1] = (*(Uint8 *)(tempSrcYbuffer + (numLines/2+i-1)*numPixels + j));
aValue[2] = (*(Uint8 *)(tempSrcYbuffer + (numLines/2+i-1)*numPixels + (j+1)));
aValue[3] = (*(Uint8 *)(tempSrcYbuffer + i*numPixels + (j-1)));
aValue[4] = (*(Uint8 *)(tempSrcYbuffer + i*numPixels + j));
aValue[5] = (*(Uint8 *)(tempSrcYbuffer + i*numPixels + (j+1)));
aValue[6] = (*(Uint8 *)(tempSrcYbuffer + (numLines/2+i)*numPixels + (j-1)));
aValue[7] = (*(Uint8 *)(tempSrcYbuffer + (numLines/2+i)*numPixels + j));
aValue[8] = (*(Uint8 *)(tempSrcYbuffer + (numLines/2+i)*numPixels + (j+1)));
//用冒泡法对数组进行排序
for(b=0;b<8;b++)
{
for(a=0;a<8-b;a++)
{
if(aValue[a]>aValue[a+1])
{
//互换
bTemp = aValue[a];
aValue[a] = aValue[a+1];
aValue[a+1] = bTemp;
}
}
}
bTemp = aValue[4];
*(Uint8 *)(tempDisYbuffer + i*numPixels + j) = bTemp;
/*屏幕上偶数行进行处理*/
aValue[0] = (*(Uint8 *)(tempSrcYbuffer + i*numPixels + (j-1)));
aValue[1] = (*(Uint8 *)(tempSrcYbuffer + i*numPixels + j));
aValue[2] = (*(Uint8 *)(tempSrcYbuffer + i*numPixels + (j+1)));
aValue[3] = (*(Uint8 *)(tempSrcYbuffer + (i+numLines/2)*numPixels + (j-1)));
aValue[4] = (*(Uint8 *)(tempSrcYbuffer + (i+numLines/2)*numPixels + j));
aValue[5] = (*(Uint8 *)(tempSrcYbuffer + (i+numLines/2)*numPixels + (j+1)));
aValue[6] = (*(Uint8 *)(tempSrcYbuffer + (i+1)*numPixels + (j-1)));
aValue[7] = (*(Uint8 *)(tempSrcYbuffer + (i+1)*numPixels + j));
aValue[8] = (*(Uint8 *)(tempSrcYbuffer + (i+1)*numPixels + (j+1)));
//用冒泡法对数组进行排序
for(b=0;b<8;b++)
{
for(a=0;a<8-b;a++)
{
if(aValue[a]>aValue[a+1])
{
//互换
bTemp = aValue[a];
aValue[a] = aValue[a+1];
aValue[a+1] = bTemp;
}
}
}
bTemp = aValue[4];
*(Uint8 *)(tempDisYbuffer + (i+numLines/2)*numPixels + j) = bTemp;
}
}
} |