Monday 15 March 2010

computer vision - Making image brightened in python using putdata -



computer vision - Making image brightened in python using putdata -

this question:

write programme in python opens file 'pixerror.png', removes s&p noise , right brightness of image, save processed photo under name. have pixel pixel , cannot utilize blurb functions.

my fist task image brighter.

i used this question code, cannot solve error have. error:

_

ruisclasse.py 41 putdata exceptions.systemerror: new style getargs format argument not tuple

_

and code.

_

from __future__ import partition #for floating number pil import image import cv2 filename='pixerror.png' action = 'lighten' extent = 10 #load original image list original_image = image.open(filename, 'r') pixels = original_image.getdata() #initialise new image new_image = image.new('rgb', original_image.size) new_image_list = [] brightness_multiplier = 1.1 if action == 'lighten': brightness_multiplier += (extent/100) else: brightness_multiplier -= (extent/100) #for each pixel, append brightened or darkened version new image list pixel in pixels: new_pixel = (int(pixel[0] * brightness_multiplier), int(pixel[1] * brightness_multiplier), int(pixel[2] * brightness_multiplier)) #check new pixel values within rgb range new_pixel= [max(min(channel, 255), 0) channel in new_pixel] new_image_list.append(new_pixel) #save new image new_image.putdata(new_image_list) new_image.save('colour_brightness.jpg') cv2.waitkey(0) cv2.destroyallwindows()

new_pixel= [max(min(channel, 255), 0) channel in new_pixel] new_image_list.append(new_pixel)

you're appending lists new_image_list, should appending tuples.

new_pixel= [max(min(channel, 255), 0) channel in new_pixel] new_image_list.append(tuple(new_pixel))

python computer-vision python-imaging-library

No comments:

Post a Comment