473,320 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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.
Nov 21 '05 #1
6 2003
"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

"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
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
> 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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Talon | last post by:
Hi all, I am new to Tk, so please bear with me. I need someone better at math than me to help me figure this out. I am drawing multiple arcs on the same circle. All arcs start at 90 and have...
7
by: Craig Parsons | last post by:
Folks, I have a scanned image which is circular, and contains a trace in the middle of it (for those of you familar with trucks it is a tachograph chart!). I want to "flatten" it out, into a...
6
by: Craig Parsons | last post by:
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...
7
by: Stefan0 | last post by:
Hi, I'd like to draw a circle on the screen using GDI+ I'm using the DrawEllipse method with width = height and I set the SmootingMode to SmoothingModeAntiAlias but the circle is "squared". Is...
9
by: Jean Pierre Daviau | last post by:
Hi gurus, I am trying to create a circle with different images. var j = 0; var degree30 = Math.PI/6; var r_angle = 0; function rotate(idy){ var x = parseInt(Math.cos(r_angle)*100);
14
by: Pythor | last post by:
I wrote the following code for a personal project. I need a function that will plot a filled circle in a two dimensional array. I found Bresenham's algorithm, and produced this code. Please tell...
0
by: CharChabil | last post by:
Hey Guys Kindly help me with the following function in vb.net 2005 I want to write a function that does the following 1. Go to pixels (x,y) 2. Draw a circle or a rectangle at the above pixels,...
9
by: saraaana | last post by:
Given the center and a point on the circle, you can use this formula to find the radius of the circle. Write a program that prompts the user to enter the center and a point on the circle. The program...
7
by: heterodon7 | last post by:
hello, can anyone give me a clue or simple code on task: for example we have in 2D an equation fo circle: (x - 3)^2 + (y - 4)^2 = 25. now the program must return for example a 40 pairs of...
13
by: mao | last post by:
Hi, if I set my body element width to be 100%, how many px value equal to this 100% width? In other words, <html> .... <body> ....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.