Usenet.com

www.Usenet.com

Group Index

Sci Thread Archive from Usenet.com

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

Re: Edge Detection in C++



Brilliant!!

Thanks again for your help with this


"Roger Rowland" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> "DaveWilson" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Well that got it working :) thankyou for the help. but your right I
> > would like to understand this a little better. I now understand the
> > need for a second buffer. But am still a little in the dark about the
> > actual operation and how it aplies to the code?
> > Most of the code i undrstood but was a little unclear on the following
> > sections:
> >
> 
> Just taking these in a different order from your message. The following
> loop -
> 
> >      // apply filter at this xy
> >      nXSum = nYSum = 0;
> >      for (i = -1; i <= 1; i++)
> >      {
> >       for (j = -1; j <= 1; j++)
> >       {
> >        ........
> 
> is looking at the 3x3 pixels around the current (x,y) - so the variable "i"
> scans over the x dimension from one column left to one column right, and the
> variable "j" scans over the y dimension from one row up to one row down.
> Within these loops, nNeighX and nNeighY contain the coordinates of each of
> the 3x3 pixels in turn -
> 
> >      nValue = my_image.raw_image[(nNeighY * my_image.width) +
> > nNeighX];
> 
> Then the sobel operator is applied by taking the matching coefficient from
> the static arrays nSobelX and nSobelY, which contain the h1 and h3 masks.
> These are both 3x3 arrays and are accessed by zero-based index (like C
> always does), so I add 1 to "i" and "j" (which range from -1 to +1) to get
> the correct entry (in the range 0 to 2) and then accumulate the result for
> both x and y -
> 
> >      nXSum += nValue * nSobelX[j + 1][i + 1];
> >      nYSum += nValue * nSobelY[j + 1][i + 1];
> >
> 
> After applying the masks over the whole 3x3 area, nXSum and nYSum will hold
> the (approximated) gradient in the x and y directions respectively. So the
> magnitude of this gradient vector is used to derive the edge strength -
> 
> >      dResult = (double)((nXSum * nXSum) + (nYSum * nYSum));
> >      if (dResult > 0.0) dResult = sqrt(dResult);
> 
> The edge strength is scaled and stored in my work buffer before proceeding
> to the next (x,y) -
> 
> >      pWork[(y * my_image.width) + x] = dResult / dScale;
> 
> Does this make it any clearer?
> 
> Regards,
> Roger
> 
> ----------------------------------------------------------------------------
> -----------
> EMail: roger dot rowland at rmrsystems dot co dot uk



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


Usenet.com



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