I am trying a code to convert a grayscale image to a RGB image format in python, but, a TypeError is raised every time I try to execute it.
My code is as follows:
from PIL import Image
path = "bw.jpg"
img = Image.open(path)
rgb = img.convert("RGB")
width,height = rgb.size
for x in range(width):
for y in range(height):
r, g, b = img.getpixel((x, y))
value = r* 299.0/1000 + g* 299.0/1000 + b * 299.0/1000
value = int(value)
rgb.putpixel ((x, y), value)
rgb.save("abc.png")
The error that I get is:
r, g, b = img.getpixel((x, y))
TypeError: 'int' object is not iterable
Any assistance would be really appreciable.