[python] raw input

Questions about programming languages and debugging
Post Reply
User avatar
moudy
Technology Enthusiast
Technology Enthusiast
Posts: 688
Joined: 10 Feb 2009, 17:00
15
Location: Beirut, Lebanon

[python] raw input

Post by moudy »

I wrote this code, nothing special, it simply manipulates every pixel in a photo according to a certain algorithm.

Code: Select all

import Image
def max_num(x):
	for i in x:
		if i != max(x):
			x[x.index(i)] = 0
	return x
def min_num(x):
        for i in x:
                if i != min(x):
                        x[x.index(i)] = 0
        return x
im = Image.open('1.jpg')
width, height = im.size
pix = im.load()
for h in range(height):
    for w in range(width):
        tup_old = pix[w, h]
        L = list(tup_old)
        LN = max_num(L)
        tup_new = tuple(LN)
        pix[w, h] = tup_new
        print w, h
im.save('1.jpg')

what I want is to be able to chose a function from the top, and accordingly the code progresses, I had in mind the raw input function, but I don't know how to progress.
if I chose from the command line : min_num, then we would have LN = min_num(L)
if if max_num is chosen then LN = max_num(L)
any suggestion ?
mahmoud_shihab@hotmail.com

User avatar
moudy
Technology Enthusiast
Technology Enthusiast
Posts: 688
Joined: 10 Feb 2009, 17:00
15
Location: Beirut, Lebanon

Re: [python] raw input

Post by moudy »

Never mind, I figured it out.

Code: Select all

input([prompt]) -> value

solved my problem
mahmoud_shihab@hotmail.com

Post Reply