By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,813 Members | 2,269 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,813 IT Pros & Developers. It's quick & easy.

Turning A Circle.... How Many Pixels??

P: n/a
Folks,

I have an image of a circle, which I am trying to straighten out into a
flat line. I am essentially wanting to look at the image, and read a
straight line from the centre, and then plot this on a graph. Then I want
to rotate the image 1 degree and read the next line down, if you see what I
mean.

My question is, how do I determine how many pixels wide I should read,
in order not to miss anything out? IE: If I rotate it 1 degree, how many
pixels is this going to be? I am guessing it is dependent on the image
itself?

I am trying to do this with C# and GDI+, although any comments, and
source in any language, would be very gratefully appreciated.
Craig.
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Craig Parsons" <in**@ycpexchange.com> wrote in
news:41***********************@ptn-nntp-reader01.plus.net...
Folks,

I have an image of a circle, which I am trying to straighten out into a
flat line. I am essentially wanting to look at the image, and read a
straight line from the centre, and then plot this on a graph. Then I want
to rotate the image 1 degree and read the next line down, if you see what
I mean.

My question is, how do I determine how many pixels wide I should read,
in order not to miss anything out? IE: If I rotate it 1 degree, how many
pixels is this going to be? I am guessing it is dependent on the image
itself?


IIRC the circumference of a circle equals 2*r*pi. That's 360 degrees.

Not sure if I got your question right...

Niki
Nov 21 '05 #2

P: n/a

"Craig Parsons" <in**@ycpexchange.com> wrote
Folks,

I have an image of a circle, which I am trying to straighten out into a
flat line. I am essentially wanting to look at the image, and read a
straight line from the centre, and then plot this on a graph. Then I want
to rotate the image 1 degree and read the next line down, if you see what I
mean.


I've seen this same post for several days now, have you made no progress?

If I had to do it, and assuming the data points are distinguishable from the
background chart (ex. differnt color) I would simply locate the center of the
circle (you may know it, or you can average all the data points) and start sweeping
the chart, (like a clock's second hand).

At each incremental tick, find how far the data point that intersects with the
sweep arm is from the center, and plot that value to your chart. To find the
data point, start at the center and test the pixels stretching outward from the
center point along the sweep arm. When you find a data pixel, use its distance
from the center point as input to your chart.

With one radius of the circle done, increment the sweep arm some small
amount and again test the pixels along the length of the sweep arm to find
the data point. When you sweep the entire circle, you're done....

(Imagine a weather radar updating its display; the sweep arm rotates around
in a circle, updating the image as it goes. Instead of adding data to the image,
you want to find what is already out there.)

You could add a few optimizations depending on the data you expect to find,
like start with larger increment values for one pass and do a second pass for
the middle of only those adjacent points where the difference is above a
certain value. And, again, depending on the data you expect, if you know
the distance of a data point on one increment, you can assume the distance
for the next sweep increment will be within a certain range, avoiding tests
for the entire length of the sweep arm. (etc...)

HTH
LFS



Nov 21 '05 #3

P: n/a
I am not sure I completely understand what you are trying to do, but perhaps
you should consider doing it backwards. Examine each pixel within the
circle, and then determine which radial line, and at what radius, the pixel
falls. In practice, you would probably examine each pixel in the rectangle
that encloses the circle. I.e., iterate through the pixels in the rectangle,
ignoring pixels where the distance from the centre is greater than the
radius.
--
"Craig Parsons" <in**@ycpexchange.com> wrote in message
news:41***********************@ptn-nntp-reader01.plus.net...
Folks,

I have an image of a circle, which I am trying to straighten out into a
flat line. I am essentially wanting to look at the image, and read a
straight line from the centre, and then plot this on a graph. Then I want
to rotate the image 1 degree and read the next line down, if you see what
I mean.

My question is, how do I determine how many pixels wide I should read,
in order not to miss anything out? IE: If I rotate it 1 degree, how many
pixels is this going to be? I am guessing it is dependent on the image
itself?

I am trying to do this with C# and GDI+, although any comments, and
source in any language, would be very gratefully appreciated.
Craig.

Nov 21 '05 #4

P: n/a
> I have an image of a circle, which I am trying to straighten out into a
flat line. I am essentially wanting to look at the image, and read a
straight line from the centre, and then plot this on a graph. Then I want
to rotate the image 1 degree and read the next line down, if you see what I
mean.

My question is, how do I determine how many pixels wide I should read,
in order not to miss anything out? IE: If I rotate it 1 degree, how many
pixels is this going to be? I am guessing it is dependent on the image
itself?

I am trying to do this with C# and GDI+, although any comments, and
source in any language, would be very gratefully appreciated.


I would suggest going the other way round and rather than mapping the existing pixels to where they need to go (and more than likely
ending up with lots of gaps or over-plotting since the pixels positions don't map up exactly), simply perform the reverse
transformation and for each required pixel of the result image map that back to a pixel on the source. Here's a quick example of
the output (sorry it was written very quickly simply to illustrate the point, it uses a very slow method of reading/writing pixels
but you get the idea..)
Http://EDais.mvps.org/TempFiles/PolarSample.exe
The multi-sample method reads a pixel using a floating point position (interpolates between the neighbouring pixels) which results
in a higher quality output but slower (due to the extra pixel reads and blending mathematics) and a little fuzzy - running a simple
sharpening filter kernel over the image should clean this up though.
Hope this helps,

Mike
- Microsoft Visual Basic MVP -
E-Mail: ED***@mvps.org
WWW: Http://EDais.mvps.org/
Nov 21 '05 #5

P: n/a
Craig Parsons wrote:
Folks,

I have an image of a circle, which I am trying to straighten out into a
flat line.


I don't quite understand what you mean by this. Are you trying to
determine the circumference? If so, simple algebra should do the trick.
So if you know the diameter (d) of the circle (in pixels) just multiply
by PI and you have it's circumference (c) in pixels (c=d*PI).

--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #6

P: n/a
dju
On Tue, 21 Dec 2004 17:31:05 -0000, "Craig Parsons" <in**@ycpexchange.com>
wrote:
Folks,

I have an image of a circle, which I am trying to straighten out into a
flat line. I am essentially wanting to look at the image, and read a
straight line from the centre, and then plot this on a graph. Then I want
to rotate the image 1 degree and read the next line down, if you see what I
mean.

My question is, how do I determine how many pixels wide I should read,
in order not to miss anything out? IE: If I rotate it 1 degree, how many
pixels is this going to be? I am guessing it is dependent on the image
itself?

I am trying to do this with C# and GDI+, although any comments, and
source in any language, would be very gratefully appreciated.
Craig.


If you're trying to convert a polar image into a rectangle, you can calculate
the number of pixels of the output rect image (if you already know R and Theta):

Width = 2 * PI * R.
X Increment = 360 / (2 * PI * R)

So you'll end up with a fractional value to increment X with.....or....

Instead of looping on theta for each degree, try using X as the loop count and
step one column of X per loop. Now increment Theta inside the X loop, but use a
pre-calculated fractional theta-step value to keep theta in step with X:

Theta-Increment = 360 / Width (for degrees)

Theta-Increment = (2 * PI) / Width (for radians)

Using one loop to increment the two counters (X and Theta), you can avoid having
to worry about the two getting out of sync. Just use a floating point for theta
and the theta-increment value.

Dave
Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.