@@ -0,0 +1,1864 @@
+from PIL import Image%0A%0Adef grayscale(image):%0A    new = Image.new(%22RGB%22,(image.size%5B0%5D,image.size%5B1%5D),(0,0,0))%0A    for i in range(image.size%5B0%5D):%0A        for j in range(image.size%5B1%5D):%0A            p = image.getpixel((i,j))%0A            media = int((p%5B0%5D+p%5B1%5D+p%5B2%5D)/3)%0A            new.putpixel((i,j),(media,media,media))%0A    return new%0A%0A%0Adef histogram(image):%0A    histogram = %5B%5D%0A    for i in range(256):%0A        histogram.append(0)%0A    for i in range(image.size%5B0%5D):%0A        for j in range(image.size%5B1%5D):%0A            p = image.getpixel((i,j))%0A            ind = int((p%5B0%5D+p%5B1%5D+p%5B2%5D)/3)%0A            quant = histogram%5Bind%5D%0A            quant = quant + 1%0A            histogram%5B ind %5D = quant%0A    return histogram%0A%0Adef normalization(image,hist):%0A    norma = %5B%5D%0A    n = image.size%5B0%5D*image.size%5B1%5D%0A    for i in range(256):%0A        norma.append(0)%0A    for i in range(256):%0A        temp = hist%5Bi%5D / n%0A        norma%5Bi%5D = temp%0A    return norma%0A%0Adef eq(norm):%0A    freq = %5B%5D%0A    for i in range(256):%0A        freq.append(0)%0A    for i in range(256):%0A        if i == 0:%0A            freq%5Bi%5D = 256*norm%5Bi%5D%0A        else:%0A            freq%5Bi%5D = 256*norm%5Bi%5D + freq%5Bi-1%5D%0A    return freq%0A%0Adef around(eq):%0A    r = %5B%5D%0A    for i in range(256):%0A        r.append(0)%0A    for i in range(256):%0A        temp = int(eq%5Bi%5D)%0A        r%5Bi%5D = temp%0A    return r%0A%0Adef returnToImage(image,rounded):%0A    new = Image.new(%22RGB%22,(image.size%5B0%5D,image.size%5B1%5D),(0,0,0))%0A    for i in range(image.size%5B0%5D):%0A        for j in range(image.size%5B1%5D):%0A            p = image.getpixel((i,j))%0A            ind = int( (p%5B0%5D+p%5B1%5D+p%5B2%5D)/3 )%0A            new.putpixel((i,j),(rounded%5Bind%5D,rounded%5Bind%5D,rounded%5Bind%5D))%0A    return new%0A%0Adef histogram_equalization(image):%0A    hist = histogram(image)%0A    nor = normalization(image,hist)%0A    equa = eq(nor)%0A    rounded = around(equa)%0A    new = returnToImage(image,rounded)%0A    return new%0A%0A

add histogram equalization for python