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

O

olsr.kamal

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!!!!
 
M

Mark Lawrence

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.
 
F

F.R.

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top