DSP: Measuring angles of edges in images

Post

Posted
Rating:
#1 (In Topic #269)
Avatar
Regular
Cedron is in the usergroup ‘Regular’
Attachment

This project is in support of my DSP StackExchange answer at:

computer vision - Auto Detection of Rotation Angle on Arbitrary Image with Orthogonal Features - Signal Processing Stack Exchange

There is a reduced size sample image included with the zip.  The original and a link to the full sized source image (52M) is at the DSP.SE post linked above.  There is a screen shot of the form towards the end of my answer.

This project allows you to measure angles in images.  The ideal case is a well defined straight edge.  

On the form, there are two rows of images.  On the top row are the source image, a close up, and an RGB channels image.  Click on the source image to capture an sample section.  Next, click either on the close up view, or the capture portion of the RGB image, to take a measurement at that spot.

The bottom row contains the result of that measurement.  Click on any of the sweep graphs (black background) to take a reading at the corresponding angle.  The selected angle is shown on the form.

The graphs show the "volatility" of the pixel color values along the trace.  The actual value is the RMS of the squiggly thing on the right.  See the link above, or the code, for more detail.  The accuracy and precision is very image and usage dependent.

The source files are:

FMain.form   
FMain.class  
SweepClass.class - Holds Sweep parameters and three channel Orient
OrientClass.class - Does the sweeps for each color channel     
SlantClass.class - The work horse, plays the role of all the diameters
ParabolicScaleClass.class - Converts zoom scroll bar value to zoom level

This is a rather unembellished program.  It does show how to do some image processing and could be a good starter program for image processing programs.

Ced

Here is how the smoother/differ works:

Code (gambas)

  1. '=============================================================================
  2. Public Sub DoSmoothing(ArgSamples As Float[], ReturnSmooth As Float[], ReturnDiffer As Float[])
  3.  
  4.         Dim n As Integer ' Index
  5.  
  6. '---- Forward
  7.  
  8.         myForward[0] = ArgSamples[0]
  9.        
  10.         For n = 1 To myMaxIndex
  11.           myForward[n] = (ArgSamples[n] + myForward[n - 1]) * 0.5
  12.         Next
  13.  
  14. '---- Backward
  15.  
  16.         myBackward[myMaxIndex] = ArgSamples[myMaxIndex]
  17.        
  18.         For n = myMaxIndex - 1 To 0 Step -1
  19.           myBackward[n] = (ArgSamples[n] + myBackward[n + 1]) * 0.5
  20.         Next
  21.  
  22. '---- Calculate Smoothed and Differed
  23.    
  24.         For n = 0 To myMaxIndex
  25.           ReturnSmooth[n] = (myBackward[n] + myForward[n]) * 0.5
  26.           ReturnDiffer[n] = (myBackward[n] - myForward[n]) * 0.5
  27.         Next
  28.  
  29. '=============================================================================
  30.  

See my blog article:  https://www.dsprelated.com/showarticle/896.php, Exponential Smoothing with a Wrinkle.

.... and carry a big stick!
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
Cedron is in the usergroup ‘Regular’
Here is a screen shot:

<IMG src="https://i.stack.imgur.com/CGmi8.jpg"> </IMG>

I've made a few small changes since and more to come.  Look for a new post in a few days to a week.

Ced

.... and carry a big stick!
Online now: No Back to the top
1 guest and 0 members have just viewed this.