DSP: Measuring angles of edges in images

Post your Gambas programming questions here.
Post Reply
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

DSP: Measuring angles of edges in images

Post by Cedron »

OrienationOfImage.zip
(114.06 KiB) Downloaded 381 times
This project is in support of my DSP StackExchange answer at:

https://dsp.stackexchange.com/questions ... 8234#58234

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:
'=============================================================================
Public Sub DoSmoothing(ArgSamples As Float[], ReturnSmooth As Float[], ReturnDiffer As Float[])

        Dim n As Integer ' Index

'---- Forward

        myForward[0] = ArgSamples[0]
        
        For n = 1 To myMaxIndex
          myForward[n] = (ArgSamples[n] + myForward[n - 1]) * 0.5
        Next

'---- Backward

        myBackward[myMaxIndex] = ArgSamples[myMaxIndex]
        
        For n = myMaxIndex - 1 To 0 Step -1
          myBackward[n] = (ArgSamples[n] + myBackward[n + 1]) * 0.5
        Next

'---- Calculate Smoothed and Differed
    
        For n = 0 To myMaxIndex
          ReturnSmooth[n] = (myBackward[n] + myForward[n]) * 0.5
          ReturnDiffer[n] = (myBackward[n] - myForward[n]) * 0.5
        Next

End
'=============================================================================
See my blog article: https://www.dsprelated.com/showarticle/896.php, Exponential Smoothing with a Wrinkle.
.... and carry a big stick!
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: DSP: Measuring angles of edges in images

Post by Cedron »

Here is a screen shot:

Image

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!
Post Reply