Skip to content

Commit f5673f2

Browse files
committed
Updates
1 parent 97268ab commit f5673f2

13 files changed

+431
-434
lines changed

BitonalAlgo.py

+46-46
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
# Author Sri Vennela Vaishnapu
2-
3-
# bi toning algorithm
4-
#if (pixelBuffer[k] + pixelBuffer[k + 1] +
5-
# pixelBuffer[k + 2] <= threshold)
6-
# {
7-
# pixelBuffer[k] = darkColor.B;
8-
# pixelBuffer[k + 1] = darkColor.G;
9-
# pixelBuffer[k + 2] = darkColor.R;
10-
# }
11-
# else
12-
# {
13-
# pixelBuffer[k] = lightColor.B;
14-
# pixelBuffer[k + 1] = lightColor.G;
15-
# pixelBuffer[k + 2] = lightColor.R;
16-
# }
17-
from PIL import Image
18-
import random
19-
lightcolor_red=0
20-
lightcolor_blue=139
21-
lightcolor_green=0
22-
darkcolor_red=179
23-
darkcolor_blue=222
24-
darkcolor_green=196
25-
i = Image.open("input.png")
26-
#pixel data is stored in pixels in form of two dimensional array
27-
pixels = i.load()
28-
width, height = i.size
29-
j=Image.new(i.mode,i.size)
30-
threshold = 374
31-
for x in range(width):
32-
for y in range(height):
33-
cpixel = pixels[x, y]
34-
#cpixel[0] contains red value cpixel[1] contains green value
35-
#cpixel[2] contains blue value cpixel[3] contains alpha value
36-
if(int(cpixel[0] + cpixel[1] +cpixel[2]) > int(threshold)):
37-
red = lightcolor_red
38-
green = lightcolor_green
39-
blue = lightcolor_blue
40-
j.putpixel((x,y),(red,green,blue))
41-
else:
42-
red = darkcolor_red
43-
green = darkcolor_green
44-
blue = darkcolor_blue
45-
j.putpixel((x,y),(red,green,blue))
46-
j.save('output.png')
1+
# Author Sri Vennela Vaishnapu
2+
3+
# bi toning algorithm
4+
#if (pixelBuffer[k] + pixelBuffer[k + 1] +
5+
# pixelBuffer[k + 2] <= threshold)
6+
# {
7+
# pixelBuffer[k] = darkColor.B;
8+
# pixelBuffer[k + 1] = darkColor.G;
9+
# pixelBuffer[k + 2] = darkColor.R;
10+
# }
11+
# else
12+
# {
13+
# pixelBuffer[k] = lightColor.B;
14+
# pixelBuffer[k + 1] = lightColor.G;
15+
# pixelBuffer[k + 2] = lightColor.R;
16+
# }
17+
from PIL import Image
18+
import random
19+
lightcolor_red=0
20+
lightcolor_blue=139
21+
lightcolor_green=0
22+
darkcolor_red=179
23+
darkcolor_blue=222
24+
darkcolor_green=196
25+
i = Image.open("input.png")
26+
#pixel data is stored in pixels in form of two dimensional array
27+
pixels = i.load()
28+
width, height = i.size
29+
j=Image.new(i.mode,i.size)
30+
threshold = 374
31+
for x in range(width):
32+
for y in range(height):
33+
cpixel = pixels[x, y]
34+
#cpixel[0] contains red value cpixel[1] contains green value
35+
#cpixel[2] contains blue value cpixel[3] contains alpha value
36+
if(int(cpixel[0] + cpixel[1] +cpixel[2]) > int(threshold)):
37+
red = lightcolor_red
38+
green = lightcolor_green
39+
blue = lightcolor_blue
40+
j.putpixel((x,y),(red,green,blue))
41+
else:
42+
red = darkcolor_red
43+
green = darkcolor_green
44+
blue = darkcolor_blue
45+
j.putpixel((x,y),(red,green,blue))
46+
j.save('output.png')

ColorTintAlgo.py

+39-39
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
# Author Sri Vennela Vaishnapu
2-
3-
# ColourTint algorithm
4-
#blue = pixelBuffer[k] + (255 - pixelBuffer[k]) * blueTint;
5-
# green = pixelBuffer[k + 1] + (255 - pixelBuffer[k + 1]) * greenTint;
6-
# red = pixelBuffer[k + 2] + (255 - pixelBuffer[k + 2]) * redTint;
7-
# if (blue > 255)
8-
# { blue = 255; }
9-
# if (green > 255)
10-
# { green = 255; }
11-
# if (red > 255)
12-
# { red = 255; }
13-
14-
from PIL import Image
15-
i = Image.open("input.png")
16-
print(i.format,i.size,i.mode)
17-
pixels = i.load()
18-
width, height = i.size
19-
j=Image.new(i.mode,i.size)
20-
blueTint=input("enter the percentage of blue tint in fraction")
21-
greenTint=input("enter the percentage of green tint in fraction")
22-
redTint=input("enter the percentage of red tint in fraction")
23-
for x in range(width):
24-
for y in range(height):
25-
cpixel = pixels[x, y]
26-
#cpixel[0] contains red value cpixel[1] contains green value
27-
#cpixel[2] contains blue value cpixel[3] contains alpha value
28-
outputBlue = int(cpixel[0] + (255 - cpixel[0]) * blueTint);
29-
outputGreen = int(cpixel[1] + (255 - cpixel[1]) * greenTint);
30-
outputRed = int(cpixel[2] + (255 - cpixel[2]) * redTint);
31-
if(outputRed>255):
32-
outputRed=255
33-
if(outputGreen>255):
34-
outputGreen=255
35-
if(outputBlue>255):
36-
outputBlue=255
37-
j.putpixel((x,y),(outputRed,outputGreen,outputBlue))
38-
j.save('output.png')
39-
1+
# Author Sri Vennela Vaishnapu
2+
3+
# ColourTint algorithm
4+
#blue = pixelBuffer[k] + (255 - pixelBuffer[k]) * blueTint;
5+
# green = pixelBuffer[k + 1] + (255 - pixelBuffer[k + 1]) * greenTint;
6+
# red = pixelBuffer[k + 2] + (255 - pixelBuffer[k + 2]) * redTint;
7+
# if (blue > 255)
8+
# { blue = 255; }
9+
# if (green > 255)
10+
# { green = 255; }
11+
# if (red > 255)
12+
# { red = 255; }
13+
14+
from PIL import Image
15+
i = Image.open("input.png")
16+
print(i.format,i.size,i.mode)
17+
pixels = i.load()
18+
width, height = i.size
19+
j=Image.new(i.mode,i.size)
20+
blueTint=input("enter the percentage of blue tint in fraction")
21+
greenTint=input("enter the percentage of green tint in fraction")
22+
redTint=input("enter the percentage of red tint in fraction")
23+
for x in range(width):
24+
for y in range(height):
25+
cpixel = pixels[x, y]
26+
#cpixel[0] contains red value cpixel[1] contains green value
27+
#cpixel[2] contains blue value cpixel[3] contains alpha value
28+
outputBlue = int(cpixel[0] + (255 - cpixel[0]) * blueTint);
29+
outputGreen = int(cpixel[1] + (255 - cpixel[1]) * greenTint);
30+
outputRed = int(cpixel[2] + (255 - cpixel[2]) * redTint);
31+
if(outputRed>255):
32+
outputRed=255
33+
if(outputGreen>255):
34+
outputGreen=255
35+
if(outputBlue>255):
36+
outputBlue=255
37+
j.putpixel((x,y),(outputRed,outputGreen,outputBlue))
38+
j.save('output.png')
39+

ColourBalanceAlgo.py

+44-44
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
# Author Sri Vennela Vaishnapu
2-
3-
# bi toning algorithm
4-
# blue = 255.0f / blueLevelFloat * (float )pixelBuffer[k];
5-
# green = 255.0f / greenLevelFloat * (float)pixelBuffer[k + 1];
6-
# red = 255.0f / redLevelFloat * (float)pixelBuffer[k + 2];
7-
# if (blue > 255) {blue = 255;}
8-
# else if (blue < 0) {blue = 0;}
9-
# if (green > 255) {green = 255;}
10-
# else if (green < 0) {green = 0;}
11-
# if (red > 255) {red = 255;}
12-
# else if (red < 0) {red = 0;}
13-
from PIL import Image
14-
i = Image.open("lena.jpg")
15-
print(i.format,i.size,i.mode)
16-
pixels = i.load() # this is not a list, nor is it list()'able
17-
width, height = i.size
18-
j=Image.new(i.mode,i.size)
19-
blueLevelFloat=input("enter the color level for blue which is ranging from 0 to 255")
20-
greenLevelFloat=input("enter the color level for green which is ranging from 0 to 255")
21-
redLevelFloat=input("enter the color level for red which is ranging from 0 to 255")
22-
for x in range(width):
23-
for y in range(height):
24-
cpixel = pixels[x, y]
25-
#cpixel[0] contains red value cpixel[1] contains green value
26-
#cpixel[2] contains blue value cpixel[3] contains alpha value
27-
outputBlue = int(255.0 / blueLevelFloat * cpixel[0]);
28-
outputGreen = int(255.0 / greenLevelFloat * cpixel[1]);
29-
outputRed = int(255.0 / redLevelFloat * cpixel[2]);
30-
if(outputRed>255):
31-
outputRed=255
32-
elif(outputRed<0):
33-
outputRed=0
34-
if(outputGreen>255):
35-
outputGreen=255
36-
elif(outputGreen<0):
37-
outputGreen=0
38-
if(outputBlue>255):
39-
outputBlue=255
40-
elif(outputBlue<0):
41-
outputBlue=0
42-
j.putpixel((x,y),(outputRed,outputGreen,outputBlue))
43-
j.save('colourbal.png')
44-
1+
# Author Sri Vennela Vaishnapu
2+
3+
# bi toning algorithm
4+
# blue = 255.0f / blueLevelFloat * (float )pixelBuffer[k];
5+
# green = 255.0f / greenLevelFloat * (float)pixelBuffer[k + 1];
6+
# red = 255.0f / redLevelFloat * (float)pixelBuffer[k + 2];
7+
# if (blue > 255) {blue = 255;}
8+
# else if (blue < 0) {blue = 0;}
9+
# if (green > 255) {green = 255;}
10+
# else if (green < 0) {green = 0;}
11+
# if (red > 255) {red = 255;}
12+
# else if (red < 0) {red = 0;}
13+
from PIL import Image
14+
i = Image.open("lena.jpg")
15+
print(i.format,i.size,i.mode)
16+
pixels = i.load() # this is not a list, nor is it list()'able
17+
width, height = i.size
18+
j=Image.new(i.mode,i.size)
19+
blueLevelFloat=input("enter the color level for blue which is ranging from 0 to 255")
20+
greenLevelFloat=input("enter the color level for green which is ranging from 0 to 255")
21+
redLevelFloat=input("enter the color level for red which is ranging from 0 to 255")
22+
for x in range(width):
23+
for y in range(height):
24+
cpixel = pixels[x, y]
25+
#cpixel[0] contains red value cpixel[1] contains green value
26+
#cpixel[2] contains blue value cpixel[3] contains alpha value
27+
outputBlue = int(255.0 / blueLevelFloat * cpixel[0]);
28+
outputGreen = int(255.0 / greenLevelFloat * cpixel[1]);
29+
outputRed = int(255.0 / redLevelFloat * cpixel[2]);
30+
if(outputRed>255):
31+
outputRed=255
32+
elif(outputRed<0):
33+
outputRed=0
34+
if(outputGreen>255):
35+
outputGreen=255
36+
elif(outputGreen<0):
37+
outputGreen=0
38+
if(outputBlue>255):
39+
outputBlue=255
40+
elif(outputBlue<0):
41+
outputBlue=0
42+
j.putpixel((x,y),(outputRed,outputGreen,outputBlue))
43+
j.save('colourbal.png')
44+

ColourInversionAlgo.py

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
# Author Sri Vennela Vaishnapu
2-
3-
# Inversion algorithm
4-
# colour = GetPixelColour(x, y)
5-
# invertedRed = 255 - Red(colour)
6-
# invertedGreen = 255 - Green(colour)
7-
# invertedBlue = 255 - Blue(colour)
8-
# PutPixelColour(x, y) = RGB(invertedRed, invertedGreen,invertedBlue)
9-
10-
from PIL import Image
11-
i = Image.open("input.png")
12-
13-
#pixel data is stored in pixels in form of two dimensional array
14-
pixels = i.load()
15-
width, height = i.size
16-
j=Image.new(i.mode,i.size)
17-
18-
for x in range(width):
19-
for y in range(height):
20-
cpixel = pixels[x, y]
21-
#cpixel[0] contains red value cpixel[1] contains green value
22-
#cpixel[2] contains blue value cpixel[3] contains alpha value
23-
invertedRed = 255 - cpixel[0]
24-
invertedGreen = 255 - cpixel[1]
25-
invertedBlue = 255 - cpixel[2]
26-
j.putpixel((x, y),(invertedRed, invertedGreen, invertedBlue))
27-
j.save('output.png')
1+
# Author Sri Vennela Vaishnapu
2+
3+
# Inversion algorithm
4+
# colour = GetPixelColour(x, y)
5+
# invertedRed = 255 - Red(colour)
6+
# invertedGreen = 255 - Green(colour)
7+
# invertedBlue = 255 - Blue(colour)
8+
# PutPixelColour(x, y) = RGB(invertedRed, invertedGreen,invertedBlue)
9+
10+
from PIL import Image
11+
i = Image.open("input.png")
12+
13+
#pixel data is stored in pixels in form of two dimensional array
14+
pixels = i.load()
15+
width, height = i.size
16+
j=Image.new(i.mode,i.size)
17+
18+
for x in range(width):
19+
for y in range(height):
20+
cpixel = pixels[x, y]
21+
#cpixel[0] contains red value cpixel[1] contains green value
22+
#cpixel[2] contains blue value cpixel[3] contains alpha value
23+
invertedRed = 255 - cpixel[0]
24+
invertedGreen = 255 - cpixel[1]
25+
invertedBlue = 255 - cpixel[2]
26+
j.putpixel((x, y),(invertedRed, invertedGreen, invertedBlue))
27+
j.save('output.png')

ColourShadingAlgo.py

+30-30
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
# Author Sri Vennela Vaishnapu
2-
3-
# Colour Shading algorithm
4-
from PIL import Image
5-
import random
6-
i = Image.open("lena.jpg")
7-
blueShade = input("enter the ahdingfactor for blue range:0 to 1")
8-
redShade = input("enter the ahdingfactor for red range:0 to 1")
9-
greenShade = input("enter the ahdingfactor for green range:0 to 1")
10-
#pixel data is stored in pixels in form of two dimensional array
11-
pixels = i.load()
12-
width, height = i.size
13-
j=Image.new(i.mode,i.size)
14-
15-
for x in range(width):
16-
for y in range(height):
17-
cpixel = pixels[x, y]
18-
#cpixel[0] contains red value cpixel[1] contains green value
19-
#cpixel[2] contains blue value cpixel[3] contains alpha value
20-
blue = int(cpixel[0] * blueShade)
21-
green = int(cpixel[1] * greenShade)
22-
red = int(cpixel[2] * redShade)
23-
if(blue < 0):
24-
blue = 0
25-
if(green < 0):
26-
green = 0
27-
if(red < 0):
28-
red = 0
29-
j.putpixel((x,y),(red,green,blue))
30-
j.save('shading.png')
1+
# Author Sri Vennela Vaishnapu
2+
3+
# Colour Shading algorithm
4+
from PIL import Image
5+
import random
6+
i = Image.open("lena.jpg")
7+
blueShade = input("enter the ahdingfactor for blue range:0 to 1")
8+
redShade = input("enter the ahdingfactor for red range:0 to 1")
9+
greenShade = input("enter the ahdingfactor for green range:0 to 1")
10+
#pixel data is stored in pixels in form of two dimensional array
11+
pixels = i.load()
12+
width, height = i.size
13+
j=Image.new(i.mode,i.size)
14+
15+
for x in range(width):
16+
for y in range(height):
17+
cpixel = pixels[x, y]
18+
#cpixel[0] contains red value cpixel[1] contains green value
19+
#cpixel[2] contains blue value cpixel[3] contains alpha value
20+
blue = int(cpixel[0] * blueShade)
21+
green = int(cpixel[1] * greenShade)
22+
red = int(cpixel[2] * redShade)
23+
if(blue < 0):
24+
blue = 0
25+
if(green < 0):
26+
green = 0
27+
if(red < 0):
28+
red = 0
29+
j.putpixel((x,y),(red,green,blue))
30+
j.save('shading.png')

0 commit comments

Comments
 (0)