Usenet.com

www.Usenet.com

Group Index

Sci Thread Archive from Usenet.com

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

Re: Smoothing?



Ooops, just re-read your code. You'll need to adjust that result to average
over your mask, so for the mask you specified, I guess it would be -

pWork[(y * my_image.width) + x] = (int)(Sum / 32.0f);

(if I haven't messed upagain!)

I was looking at my Gaussian smooth in which I generate a normalised mask
beforehand.......

Sorry for any confusion!

------------------------------------------------------
EMail: roger dot rowland at rmrsystems dot co dot uk
"Roger Rowland" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi Dave,
>
> Thanks for the "thanks"! You're very welcome.....
>
> Anyway, I think you just need to remove the sqrt() from the Sobel routine
to
> use it with your smoothing mask. It was only there to get the magnitude of
> the edge from the combined x and y directions. So something like -
>
> pWork[(y * my_image.width) + x] = Sum;
>
> in your loop, instead of -
>
> >    // calculate result
> >    Result = Sum;
> >    if (Result > 0)
> >    {
> >    Result = sqrt(Result);
> >    }
> >    pWork[(y * my_image.width) + x] = Result;
> >   }
>
> should work fine.
>
> Best regards,
> Roger
>
>
> ------------------------------------------------------
> EMail: roger dot rowland at rmrsystems dot co dot uk
> "DaveWilson" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Thanks for the great help provided by this group and in particular
> > Roger Rowland.
> >
> > I've nearly got all functionality i require for my image processing
> > package and i thought that by manipulating an edge detection function
> > that had been provided i would easily be able to apply other templates
> > such as smoothing and blurring. however i'm not getting the desired
> > results cou;ld some one please have a look over this code?
> >
> > 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]);
> >
> >     }
> >    }
> >
> >    // calculate result
> >    Result = Sum;
> >    if (Result > 0)
> >    {
> >    Result = sqrt(Result);
> >    }
> >    pWork[(y * my_image.width) + x] = Result;
> >   }
> >  }
> >
> >  // copy result back into source array
> >  for (i = 0; i < my_image.width * my_image.length; i++)
> >  {
> >   // clamp to 255
> >   if (pWork[i] > 255)
> >    my_image.raw_image[i] = 255;
> >   else
> >    my_image.raw_image[i] = (unsigned char)pWork[i];
> >  }
> >
> > return 0;
> > }
> >
> > Thanks for any help
> >
> >
> > //code supplied by Roger Rowland (butchered by me :p)
>
>





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


Usenet.com



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