Prev: line integrals
Next: Electron’s puzzles.
From: Tom on 23 Apr 2010 15:10 The overall problem I am solving is that I have numerous data sheets with graphs with different scales, log or linear and different ranges and I want to overlay them. I have written code (Python) to read in a BMP file format and extract the data points for the graphs. And I can easily convert linear coordinates. The problem I am having now is when the original graph has a log based axis I am uncertain as to how to convert the coordinate to that form as the coordinate from the image would be linear. The graph could cover more than one decade and could also not start at a '1', ie .2, 3, 10, 500 could be starting points. The max of the graph may not end on a decade either, ex for the points above could be 30, 100, 200, 5000. If it is simpler to have it always start and end on a decade I could crop the image to do that. The closest for approximation I have come to is the following: newValue = ( base ^ ( (value-loPixel)/(hiPixel-loPixel) ) )*minValue Each decade would have different values in the formula. For example, base is log base (normally 10), loPixel would be the pixel coordinate of 1, hiPixel would be the pixel coordinate of 10, value is the pixel coordinate to convert, and minValue would be 1 in this case. I'm wondering if there is a formula that wouldn't require knowing which decade you are in or finding each decade location. Thanks, Tom
From: James Waldby on 23 Apr 2010 23:52 On Fri, 23 Apr 2010 19:10:20 -0400, Tom wrote: [re graphs in bitmapped files, having various scales and ranges, and how to scale log data after extracting pixel position data] > [...] when the original graph has a log based axis I am uncertain > as to how to convert the coordinate > [...] The graph could cover more than one decade and could > also not start at a '1', ie .2, 3, 10, 500 could be starting points. The > max of the graph may not end on a decade either, ex for the points above > could be 30, 100, 200, 5000. If it is simpler to have it always start > and end on a decade I could crop the image to do that. The closest for > approximation I have come to is the following: > > newValue = ( base ^ ( (value-loPixel)/(hiPixel-loPixel) ) )*minValue > > Each decade would have different values in the formula. For example, > base is log base (normally 10), loPixel would be the pixel coordinate of > 1, hiPixel would be the pixel coordinate of 10, value is the pixel > coordinate to convert, and minValue would be 1 in this case. > > I'm wondering if there is a formula that wouldn't require knowing which > decade you are in or finding each decade location. It's but a small step further to such a formula. This will be obvious if you write things out more clearly and with less-cumbersome notation: Let m = minValue and p = loPixel = pixel column number it occurs at; let n = maxValue and q = hiPixel = pixel column number it occurs at. Let b = log base = "decade" multiplier. If the graph has d decades [where d need not be an integer], then n = m * b^d. Hence d = ((ln n)-(ln m))/(ln b). Let r = (q-p)/d = pixels per decade. Then the graph-coordinate value at pixel x is m * b^((x-m)/r). -- jiw
From: Tom on 23 Apr 2010 21:03 > It's but a small step further to such a formula. > This will be obvious > if you write things out more clearly and with > less-cumbersome notation: > Let m = minValue and p = loPixel = pixel column > number it occurs at; > let n = maxValue and q = hiPixel = pixel column > number it occurs at. > Let b = log base = "decade" multiplier. > > If the graph has d decades [where d need not be an > integer], > then n = m * b^d. Hence d = ((ln n)-(ln m))/(ln b). > > > Let r = (q-p)/d = pixels per decade. Then the > graph-coordinate > value at pixel x is m * b^((x-m)/r). > > -- > jiw Thank you, However, I did find one flaw with the final formula. It should be: (note the second 'm' is a 'p') value at pixel x is m * b^((x-p)/r). Thanks again! -Tom
|
Pages: 1 Prev: line integrals Next: Electron’s puzzles. |