# Image Analysis

Page 1 of 1

## 0 Replies - 519 Views - Last Post: 20 November 2017 - 12:36 PMRate Topic: 2 Votes //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=407737&amp;s=407ab217860fd1eaf27f97ba913605b1&md5check=' + ipb.vars['secure_hash'], cur_rating: 3, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 KhaosFury

Reputation: 0
• Posts: 19
• Joined: 24-November 14

# Image Analysis

Posted 20 November 2017 - 12:36 PM

Hello!

I have an interesting problem. I've got an application which generates a sort of Heightmap based on an image as such:
https://imgur.com/a/hRcvc

I have been trying, for awhile now, to think of a way I could create an algorithm to analyze the shape of the anything above a certain Z-Axis level.
My ultimate goal is to determine how irregular the shape is by comparing the image to a rectangle and returning an integer (From 0-1) based on how similar the white object is to a rectangular box. Or I suppose, from the algorithm's point of view, how many straight edges are present in the image.

Currently, I generate the heightmap to get X, Y, and Z as such:
```Private zData(,) As Single
For y As Integer = 0 To bmp.Height - 1
For x As Integer = 0 To bmp.Width - 1
zData(x, y) = bmp.GetPixel(x, y).GetBrightness
Next
Next

```

And for Z:
```
For y As Integer = 0 To data.GetUpperBound(1)
For x As Integer = 0 To data.GetUpperBound(0)
minZ = Math.Min(zData(x, y), minZ)
maxZ = Math.Max(zData(x, y), maxZ)
Next
Next

```

So far, I'm thinking I'd linearly parse the entire image (or array of values) along the Y-Axis, and determine how many points along the Y-Axis contain a value of Z >= 0.5 (or whatever value I am wanting to find). However many hits it gives me in a row will contribute to how linear the image is along that axis, and then again along the X axis?
Problem with that idea is 2 things:
I can't wrap my head around if that would be accurate enough
I am not sure how I can write a loop which can do this

Any ideas, or guidance would be extremely appreciated!

Is This A Good Question/Topic? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }