Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40652 > unrolled thread

draw a line if the color of points of beginning and end are différent from white

Started byolsr.kamal@gmail.com
First post2013-03-06 09:46 -0800
Last post2013-03-06 21:57 +0100
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  draw a line if the color of points of beginning and end are différent from white olsr.kamal@gmail.com - 2013-03-06 09:46 -0800
    Re: draw a line if the color of points of beginning and end are différent from white Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-03-06 19:32 +0000
    Re: draw a line if the color of points of beginning and end are différent from white "F.R." <anthra.norell@bluewin.ch> - 2013-03-06 21:57 +0100

#40652 — draw a line if the color of points of beginning and end are différent from white

Fromolsr.kamal@gmail.com
Date2013-03-06 09:46 -0800
Subjectdraw a line if the color of points of beginning and end are différent from white
Message-ID<181dcc9d-eedf-429e-9307-a49303e9f7c9@googlegroups.com>
how can i draw a line if the point of the begining and the end if those points  are différent from the white
in other exepretion how can i get the color of two points of the begining and the end?????
please help me!!!!

[toc] | [next] | [standalone]


#40659

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2013-03-06 19:32 +0000
Message-ID<mailman.2958.1362598286.2939.python-list@python.org>
In reply to#40652
On 06/03/2013 17:46, olsr.kamal@gmail.com wrote:
> how can i draw a line if the point of the begining and the end if those points  are différent from the white
> in other exepretion how can i get the color of two points of the begining and the end?????
> please help me!!!!
>

Please tell us what package, Python version and OS, plus give us a code 
sample, what you expect to see and what actually happens.

-- 
Cheers.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#40662

From"F.R." <anthra.norell@bluewin.ch>
Date2013-03-06 21:57 +0100
Message-ID<mailman.2960.1362603514.2939.python-list@python.org>
In reply to#40652
On 03/06/2013 06:46 PM, olsr.kamal@gmail.com wrote:
> how can i draw a line if the point of the begining and the end if those points  are différent from the white
> in other exepretion how can i get the color of two points of the begining and the end?????
> please help me!!!!

This should get you going. If it doesn't work it will
still direct you to the relevant chapters in the tutorial.

Frederic


def draw_line (image):

     # image is a PIL Image ( <class Image.Image at ...> )

     # Define your colors
     WHITE = ~0  # Probably white for all modes.
     LINE_COLOR = 0  # define

     # Find end points
     points = []
     pixels = image.load () # Fast pixel access
     for y in range (image.size [1]):
         for x in range (image.size [0]):
             if pixels [x, y] != WHITE
                 points.append ((x, y))

     # Join end points
     draw = ImageDraw.Draw (image)
     draw.line (points, fill = LINE_COLOR)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web