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


Groups > comp.lang.python > #40662

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

Path csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <anthra.norell@bluewin.ch>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.107
X-Spam-Level *
X-Spam-Evidence '*H*': 0.79; '*S*': 0.00; 'pil': 0.07; 'pixel': 0.07; 'pixels': 0.09; 'def': 0.10; 'received:195.186': 0.16; 'received:bluewin.ch': 0.16; 'wrote:': 0.17; 'define': 0.20; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; "doesn't": 0.28; 'subject:end': 0.29; 'points': 0.29; 'probably': 0.29; 'point': 0.31; 'to:addr:python-list': 0.33; 'pm,': 0.35; 'should': 0.36; 'two': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'help': 0.40; 'end': 0.40; 'your': 0.60; 'range': 0.60; 'email addr:gmail.com': 0.63; 'subject:\xe9': 0.65; 'subjectcharset:iso-8859-1': 0.67; 'received:ch': 0.69; 'color': 0.69; 'direct': 0.69; 'subject:color': 0.84; 'chapters': 0.93
Date Wed, 06 Mar 2013 21:57:24 +0100
From "F.R." <anthra.norell@bluewin.ch>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130221 Thunderbird/17.0.3
MIME-Version 1.0
To python-list@python.org
Subject Re: draw a line if the color of points of beginning and end are différent from white
References <181dcc9d-eedf-429e-9307-a49303e9f7c9@googlegroups.com>
In-Reply-To <181dcc9d-eedf-429e-9307-a49303e9f7c9@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 8bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2960.1362603514.2939.python-list@python.org> (permalink)
Lines 31
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362603514 news.xs4all.nl 6881 [2001:888:2000:d::a6]:34126
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40662

Show key headers only | View raw


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)

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

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

csiph-web