Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Turning A Circle.... How Many Pixels??
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.



Report this thread to moderator Post Follow-up to this message
Old Post
Craig Parsons
12-21-04 08:59 PM


Re: Turning A Circle.... How Many Pixels??
"Craig Parsons" <info@ycpexchange.com> wrote in
news:41c85ddb$0$37353$ed2619ec@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



Report this thread to moderator Post Follow-up to this message
Old Post
Niki Estner
12-21-04 08:59 PM


Re: Turning A Circle.... How Many Pixels??
"Craig Parsons" <info@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 th
e
circle (you may know it, or you can average all the data points) and start s
weeping
the chart, (like a clock's second hand).

At each incremental tick, find how far the data point that intersects with t
he
sweep arm is from the center, and plot that value to your chart.  To find th
e
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 dista
nce
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 i
mage,
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 fo
r
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








Report this thread to moderator Post Follow-up to this message
Old Post
Larry Serflaten
12-22-04 01:57 AM


Re: Turning A Circle.... How Many Pixels??
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" <info@ycpexchange.com> wrote in message
news:41c85ddb$0$37353$ed2619ec@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.
>



Report this thread to moderator Post Follow-up to this message
Old Post
James Hahn
12-22-04 01:57 AM


Re: Turning A Circle.... How Many Pixels??
>     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 existi
ng 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 (inter
polates between the neighbouring pixels) which results
in a higher quality output but slower (due to the extra pixel reads and blen
ding 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: EDais@mvps.org
WWW: Http://EDais.mvps.org/



Report this thread to moderator Post Follow-up to this message
Old Post
Mike D Sutton
12-22-04 01:57 AM


Re: Turning A Circle.... How Many Pixels??
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.

Report this thread to moderator Post Follow-up to this message
Old Post
C-Services Holland b.v.
12-22-04 01:59 PM


Re: Turning A Circle.... How Many Pixels??
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" <info@ycpexchange.com> wrote in message
news:41c85ddb$0$37353$ed2619ec@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.
>



Report this thread to moderator Post Follow-up to this message
Old Post
James Hahn
12-28-04 08:59 PM


Re: Turning A Circle.... How Many Pixels??
On Tue, 21 Dec 2004 17:31:05 -0000, "Craig Parsons" <info@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 calculat
e
the number of pixels of the output rect image (if you already know R and The
ta):

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 a
nd
step one column of X per loop. Now increment Theta inside the X loop, but us
e 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 ha
ving
to worry about the two getting out of sync. Just use a floating point for th
eta
and the theta-increment value.

Dave

Report this thread to moderator Post Follow-up to this message
Old Post
dju@nospam.comm
01-06-05 01:58 AM


Re: Turning A Circle.... How Many Pixels??
On Tue, 21 Dec 2004 17:31:05 -0000, "Craig Parsons" <info@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 calculat
e
the number of pixels of the output rect image (if you already know R and The
ta):

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 a
nd
step one column of X per loop. Now increment Theta inside the X loop, but us
e 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 ha
ving
to worry about the two getting out of sync. Just use a floating point for th
eta
and the theta-increment value.

Dave

Report this thread to moderator Post Follow-up to this message
Old Post
dju@nospam.comm
01-10-05 08:59 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

C# archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 08:14 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.