Posted by
Joachim Wesner on
Dec 28, 2009; 7:02am
URL: http://imagej.273.s1.nabble.com/Nelp-needed-tp3689904p3689909.html
Hi Dilip,
Rob is right on the basic idea, however, in many cases, an integer-only
method is used for efficiency which does not require any interpolation and
hence floating point calculations.
(I did not yet check what ImageJ does when creating ROIs)
Look up "Bresenham algorithm" and "line drawing algorithm"
Cheers
Robert Dougherty
<
[hidden email]>
Gesendet von: An
ImageJ Interest
[hidden email]
Group Kopie
<
[hidden email].
GOV> Thema
Re: Nelp needed
28.12.2009 05:55
Bitte antworten
an
ImageJ Interest
Group
<
[hidden email].
GOV>
Dilip,
Here is my understanding. I'm sure it will be corrected if necessary.
Suppose you want to draw a line from (x1,y2) to (x2,y2). First determine
which is larger, deltaX = |x2-x1| or deltaY = |y2 - y1|. If deltaX is
larger, then our line is going to have deltaX+1 pixels, with x running from
x1 to x2. For each x value on the line (segment), the corresponding value
of y is computed by interpolating:
y = (int)( y1(x2 - x)/(x2 - x1) + y2(x - x1)/(x2 - x1) + 0.5)
If deltaY is larger, then y runs from y1 to y2, and each x is computed to
by a formula analogous to the above with x and y interchanged. If deltaX =
deltaY, then do it either way. If the largest delta is 0, then just draw
one pixel.
In ImageJ programming, you should not have to do this computation if all
you want to do is draw a line. There are ImageJ and AWT methods to handle
it.
Bob
On Dec 27, 2009, at 8:16 PM, Dilip Baluguri wrote:
> I just want to know how a line is drawn between two points. What is I
need
> is how the intermediate pixels are choosen while drawing a line. Given
two
> poins A(10,20) and B(40,200) how intermediate pixels are choosen.Any help
is
-
> "If God had wanted man to play soccer, he wouldn't have given us arms."
Robert Dougherty, Ph.D.
President, OptiNav, Inc.
4176 148th Ave. NE
Redmond, WA 98052
(425)891-4883
FAX (425)467-1119
www.optinav.com
[hidden email]
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit
http://www.messagelabs.com/email
______________________________________________________________________