473,396 Members | 2,109 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,396 software developers and data experts.

Straightening Out A Circle?

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 straight line. I can't seem to find
any controls which might be able to do this for me.

Does anyone have any ideas, or will I have to write some code to do it
pixel by pixel??

Thanks In Advance.
Craig.
Nov 21 '05 #1
11 1041
Craig Parsons wrote:
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 straight line. I can't seem to
find any controls which might be able to do this for me.

Does anyone have any ideas, or will I have to write some code to
do it pixel by pixel??

Thanks In Advance.
Craig.


I don't think there are standard classes for this, you have to write your own.

It would be something like:
- find the position / size / center of the circle
- find the start angle of the trace
- follow the trace in angle/radius coordinates
(possibly: step through the angle-range with some resolution, for a given angle
find the radius where the traceline is)
- plot in new x/y graph, x=recorded angle, y=recorded radius

Nice project. Sorry, I can't help you further with the "how" of these steps.

Hans Kesting
Nov 21 '05 #2
well, are you only doing this once? if so, wouldn't it just be easier
to flatten it out by hand?

If you need this to be dynamic however, then mr. Kesting's suggestion
holds true ... here is an article that should give you all the details
on accessing and manipulating the pixel data of an image.

http://www.codeproject.com/cs/media/...cfilters11.asp

Joel Martinez
http://www.onetug.org - Orlando .NET User Group
http://www.codecube.net - blog

Nov 21 '05 #3
well, are you only doing this once? if so, wouldn't it just be easier
to flatten it out by hand?

If you need this to be dynamic however, then mr. Kesting's suggestion
holds true ... here is an article that should give you all the details
on accessing and manipulating the pixel data of an image.

http://www.codeproject.com/cs/media/...cfilters11.asp

Joel Martinez
http://www.onetug.org - Orlando .NET User Group
http://www.codecube.net - blog

Nov 21 '05 #4
well, are you only doing this once? if so, wouldn't it just be easier
to flatten it out by hand?

If you need this to be dynamic however, then mr. Kesting's suggestion
holds true ... here is an article that should give you all the details
on accessing and manipulating the pixel data of an image.

http://www.codeproject.com/cs/media/...cfilters11.asp

Joel Martinez
http://www.onetug.org - Orlando .NET User Group
http://www.codecube.net - blog

Nov 21 '05 #5
well, are you only doing this once? if so, wouldn't it just be easier
to flatten it out by hand?

If you need this to be dynamic however, then mr. Kesting's suggestion
holds true ... here is an article that should give you all the details
on accessing and manipulating the pixel data of an image.

http://www.codeproject.com/cs/media/...cfilters11.asp

Joel Martinez
http://www.onetug.org - Orlando .NET User Group
http://www.codecube.net - blog

Nov 21 '05 #6
Well, does this have to be a dynamic process? are you only trying to
flatten this data once for display, or will this be an ongoing process?
If only once, then consider just doing it manually (ie. by hand) as
the time it would take to write this tool would probably outweigh the
time to do it by hand.

If however you really need for this to be done dynamically, then Han's
suggestion is in fact what you need to do. Here's a kick ass article
that should show you everything you need to do to access the nitty
gritty pixel data:

http://www.codeproject.com/cs/media/...cfilters11.asp

Hope that helps,
Joel Martinez
http://www.onetug.org - Orlando .NET User Group
http://www.codecube.net - blog

Nov 21 '05 #7
Well, does this have to be a dynamic process? are you only trying to
flatten this data once for display, or will this be an ongoing process?
If only once, then consider just doing it manually (ie. by hand) as
the time it would take to write this tool would probably outweigh the
time to do it by hand.

If however you really need for this to be done dynamically, then Han's
suggestion is in fact what you need to do. Here's a kick ass article
that should show you everything you need to do to access the nitty
gritty pixel data:

http://www.codeproject.com/cs/media/...cfilters11.asp

Hope that helps,
Joel Martinez
http://www.onetug.org - Orlando .NET User Group
http://www.codecube.net - blog

Nov 21 '05 #8
Thanks,

It does need to be dynamic as I will want to do it on a scanned image a
lot of times for different images, so thanks very much for the link.
Craig.
<jd********@ea.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Well, does this have to be a dynamic process? are you only trying to
flatten this data once for display, or will this be an ongoing process?
If only once, then consider just doing it manually (ie. by hand) as
the time it would take to write this tool would probably outweigh the
time to do it by hand.

If however you really need for this to be done dynamically, then Han's
suggestion is in fact what you need to do. Here's a kick ass article
that should show you everything you need to do to access the nitty
gritty pixel data:

http://www.codeproject.com/cs/media/...cfilters11.asp

Hope that helps,
Joel Martinez
http://www.onetug.org - Orlando .NET User Group
http://www.codecube.net - blog

Nov 21 '05 #9
Thanks,

It does need to be dynamic as I will want to do it on a scanned image a
lot of times for different images, so thanks very much for the link.
Craig.
<jd********@ea.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Well, does this have to be a dynamic process? are you only trying to
flatten this data once for display, or will this be an ongoing process?
If only once, then consider just doing it manually (ie. by hand) as
the time it would take to write this tool would probably outweigh the
time to do it by hand.

If however you really need for this to be done dynamically, then Han's
suggestion is in fact what you need to do. Here's a kick ass article
that should show you everything you need to do to access the nitty
gritty pixel data:

http://www.codeproject.com/cs/media/...cfilters11.asp

Hope that helps,
Joel Martinez
http://www.onetug.org - Orlando .NET User Group
http://www.codecube.net - blog

Nov 21 '05 #10
I think the best way for this might be to produced a clever transformation
matrix to warp the picture straight using GDI+ in the System.Drawing
namespace. I wouldn't know where to start personally but try reading a bit
about it at www.bobpowell.net/faqmain.htm

Sorry I cant be more help

Ciaran
"Craig Parsons" <cr***********@hicpx.com> wrote in message
news:41**********************@ptn-nntp-reader02.plus.net...
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 straight line. I can't seem to find
any controls which might be able to do this for me.

Does anyone have any ideas, or will I have to write some code to do it
pixel by pixel??

Thanks In Advance.
Craig.

Nov 21 '05 #11
"Craig Parsons" <cr***********@hicpx.com> wrote in message
news:41**********************@ptn-nntp-reader02.plus.net...
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 straight line. I can't seem to find any controls which might be able to do this for me.

Does anyone have any ideas, or will I have to write some code to do it
pixel by pixel??


Yup, pixel by pixel. I couldn't help myself and quickly wrote it.
If I feed this a bitmap with a circle at the center, it returns a bitmap
with
a straight line so I guess it works. (No guarantees though !) :

public static Bitmap UnCircularWarp(Bitmap cb) 'cb stands for circular
bitmap
{
int width = Math.Min(cb.Width, cb.Height);
Bitmap bTemp = new Bitmap((width << 1) + 1, (width >> 1) + 1,
cb.PixelFormat);
double r = width / 2.0f;
for (int x = 0; x < bTemp.Width; ++x)
{

// as X goes from 0 to bTemp.width, alpha goes from PI to -PI
double alpha = Math.PI - Math.PI * 2.0d * (double)x / (double)bTemp.Width;

double cosA = Math.Cos(alpha);
double sinA = Math.Sin(alpha);
for (int y = bTemp.Height - 1; y >= 0; y--)
{
bTemp.SetPixel(
x,
y,
cb.GetPixel(
(int)(Math.Floor(r + (double)y * cosA)), ' circular transform to
determine pos. in circular bitmap
(int)(Math.Floor(r - (double)y * sinA)) ' circular transform to
determine pos. in circular bitmap
)
);
}
}
return bTemp;
}

Basically this creates a bitmap, half the height of the original bitmap (and
twice the width to make
sure that we have enough pixels to show the result.) Then it walks across
the destination (i.e.
unwarped bitmap) and calculates which position this corresponds to in the
cirular (i.e. original)
bitmap. The formula for the inverse image coordinate transform is simply a
circular mapping (i.e.
x = centerX + radius*cos(alhpa)
y = centerY + radius*sin(alpha)
adapted for screen coordinates (where 0,0 lies at the top left instead of
the bottom left)

Keep in mind that this is *hugely* inefficient. SetPixel is not really a
great way to do image warping.
Ideally you'd want to write this in C(++) for speed.

Have fun.

L2
Nov 21 '05 #12

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...
8
by: Stub | last post by:
In statement: Circle c1=c2; Is the assignment operator= of Circle called? In statement Circle c1(c2); Is the copy constructor called?
1
by: rdeaton | last post by:
I need to design and code a Java program that calculates and prints the (D) diameter, the (C) circumference, or the (A) area of a circle, given the radius. The program inputs two data items: the...
0
by: Chua Wen Ching | last post by:
Hi.. just wonder i draw a circle in the picturebox1 1) and i want to store the circle in memory (only circle) when i store into bmp... i want to see the circle with transparent...
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...
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: Carl Gilbert | last post by:
Hi I am trying to plot a series of shapes in a circular fashion. All shapes are evenly spaced with lines going between each shape. At present, all shapes are the same size so I can easily plot...
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...
14
by: DeadSilent | last post by:
I have this code and for some reason I keep getting an error where it says "exporting non-public type through public api ".. I'm not sure why this keeps happening but it does so for getCircleInfo /...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.