Usenet.com

www.Usenet.com

Group Index

Sci Thread Archive from Usenet.com

<-- __Chronological__ --> <-- __Thread__ -->

Re: Smoothing?



[EMAIL PROTECTED] (DaveWilson) wrote:
> int Smooth()
> {
>  double Result;
>  int i, j, x, y, Value;
>  int Sum, NeighX, NeighY;
> 
> 
>  int smooth[][3] = {{1, 3, 1}, {3, 16, 3}, {1, 3, 1}};
>  
> 
>  // allocate working array
>  double* pWork = new double [my_image.width * my_image.length];
> 
>  // apply over whole image
>  for (y = 0; y < my_image.length; y++)
>  {
>   for (x = 0; x < my_image.width; x++)
>   {
>    // apply filter at this xy
>    Sum = 0; 
>    for (i = -1; i <= 1; i++)
>    {
>     for (j = -1; j <= 1; j++)
>     {
>      // get neighbour
>      NeighX = x + i;
>      NeighY = y + j;
> 
>      // "extend" image at extremeties
>      if (NeighX < 0) 
>        {
>                NeighX = 0;
>        }
>      if (NeighX >= my_image.width)
>        {
>                NeighX = my_image.width - 1;
>        }
>      if (NeighY < 0)
>        {
>                NeighY = 0;
>        }
>      if (NeighY >= my_image.length)
>        {
>                NeighY = my_image.length - 1;
>        }
>       
>      // accumulate
>      Value = my_image.raw_image[(NeighY * my_image.width) + NeighX];
>      Sum = Sum + (Value * smooth[j + 1][i + 1]);
>      
> 
etc., etc. ...



This reminds me of why I moved to MATLAB, hee hee!

all in good fun,
Will



<-- __Chronological__ --> <-- __Thread__ -->


Usenet.com



Please check out one of the premium Usenet Newsgroup Service Providers below for access to Usenet.