# Get information from a graph image

Page 1 of 1

## 6 Replies - 264 Views - Last Post: 11 July 2012 - 11:11 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=285503&amp;s=9e6c6398d285857c24db7cd5016720e4&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 blogchama

• New D.I.C Head

Reputation: -1
• Posts: 15
• Joined: 04-October 10

# Get information from a graph image

Posted 11 July 2012 - 09:43 AM

In this image black colour graph is in the white background. I want to get the pixel length between the two peak waves in the graph and the average height of the peak wave.(pixel count between top position and lowest position of the graph)

I'm stuck with the logic to implement this code.can anyone help me to implement this.

```public void black(Bitmap bmp)
{
Color col;
for (int i = 0; i < bmp.Height; i++)
{
for (int j = 0; j < bmp.Width; j++)
{
col = bmp.GetPixel(j, i);
if (col.R == 0) //check whether black pixel
{
y = i;  //assign black pixel x,y positions to a variable
x = j;
}

}
}
}
```

what is the best method to store these x,y coordination of each black pixels?( 2D arrays or array lists)
what is the logic we can apply to do this?

Is This A Good Question/Topic? 0

## Replies To: Get information from a graph image

### #2 tlhIn`toq

• Closing in on 5,000

Reputation: 4926
• Posts: 10,461
• Joined: 02-June 10

## Re: Get information from a graph image

Posted 11 July 2012 - 10:04 AM

I would use a Point. You already have the location as i and j

well, its the inverse of the location since upper left is 0,0 of a bitmap and lower left is 0,0 of a conventional graph.

So you have to compute the hight from the bottom.

If you have a bitmap of 500 rows and you find the peak on the 10 row from the top that would be the 490th row from the bottom.

And your check isn't testing for black. Its testing for red. You need to see if all three values are 0 for it to be true black: RG&B

### #3 tlhIn`toq

• Closing in on 5,000

Reputation: 4926
• Posts: 10,461
• Joined: 02-June 10

## Re: Get information from a graph image

Posted 11 July 2012 - 10:13 AM

You also need to stop typing and do some planning.

I don't think you've done any thinking about various possibilities.

There is no second 'peak' but there is a plateau. So what point do you want to use? The lead of the plateau... the midpoint or the end before it drops off?

And which point of the first hump do you want to compare against? It sort of has a peak but then a very gradual slope down to another point before dropping sharply.

Or what if the graph has background gridlines to help the reader judge values? Most/many grids have these. I don't see too many that are just bland black on white with no references.

### #4 blogchama

• New D.I.C Head

Reputation: -1
• Posts: 15
• Joined: 04-October 10

## Re: Get information from a graph image

Posted 11 July 2012 - 10:40 AM

i use a grey scale image.(after applying a threshold )So R value is enough to separate the black pixels.
yep.i have to change the for loops to change the pixel reading direction.agree with you.

This post has been edited by tlhIn`toq: 11 July 2012 - 11:03 AM

### #5 blogchama

• New D.I.C Head

Reputation: -1
• Posts: 15
• Joined: 04-October 10

## Re: Get information from a graph image

Posted 11 July 2012 - 10:46 AM

i'm using a pixel value levels to separate peaks from other small plateus.
If wave > vales ->peak
else -> not a peak

This is a ECG image processing task.I totally removed the background grid and other noises before getting this output.
calculations totally depend of scanned image DPI values.

can you suggest a best way to store these values? waht is the most suitable method? 2D arrays or lists?

This post has been edited by tlhIn`toq: 11 July 2012 - 11:03 AM

### #6 tlhIn`toq

• Closing in on 5,000

Reputation: 4926
• Posts: 10,461
• Joined: 02-June 10

## Re: Get information from a graph image

Posted 11 July 2012 - 11:03 AM

Personally I prefer a List<> over an Array[] because it is more powerful and friendlier to use.

### #7 Skydiver

• Code herder

Reputation: 1896
• Posts: 5,687
• Joined: 05-May 12

## Re: Get information from a graph image

Posted 11 July 2012 - 11:11 AM

I suggest a list of y-values if the x-values increase monotonically.

If the values are going into long term storage (which is likely with ECG's), and you know that the graph is continuous, then you can save a lot of space by also just storing the deltas between the y-values instead of absolute y-values. Basically how music used to to be digitally compressed until wavelet compression came along.

This post has been edited by Skydiver: 11 July 2012 - 11:12 AM