Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40662
| Date | 2013-03-06 21:57 +0100 |
|---|---|
| From | "F.R." <anthra.norell@bluewin.ch> |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2960.1362603514.2939.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Find similar | Unroll 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