'''
Created on Mar 15, 2011

@author: alexandrudutu
'''

import Image

def remove_blue(pixel):
    '''
    this filter function takes a pixel and removes the blue component (sets it to 0)
    '''
    return (0, 0, 0, 0)

def remove_green(pixel):
    '''
    this filter function takes a pixel and removes the green component (sets it to 0)
    '''
    return (0, 0, 0, 0)

if __name__ == '__main__':
    input_file = "noise.png"
    output_file = "image_reconstructed.png"
    
    im = Image.open(input_file)       # open the file that stores the image
    
    if im == None:
        print "Specified input file " + input_file + " cannot be opened."
    
    pixel_list = im.getdata()      # retrieves a list of pixels
    print "Total number of pixels: ", len(pixel_list)
    
    pixel_list_trans = []
    for pixel in pixel_list:
        pixel_list_trans.append((0, 0, 0, pixel[3]))

    im.putdata(pixel_list_trans)
    im.save(output_file)