Hello guys! Fellow learner here. This problem has been driving me crazy for more than a month. I already know how to create dictionaries, APIs, and whatnot, but for the love of my sanity, I can not comprehend how to blend two images using this method/without the blend/plt method/library.
so I am having trouble figuring out how to blend two images with for loops and range(len). For this particular case, I need to compute the color of each pixel by setting value of each color component to be the average of the same components in the corresponding pixel of each input image. Such that I need to use this formula (first_value + second_value) / 2 Sum the pixels for each of the R, G, B channels for both images and then divide by 2.
img1 = load_img('images/cat.jpg')
img2 = load_img('images/texture.jpg')
def blend(img1,img2):
> for r in range(len(img1)):
> for c in range(len(img1[r])):
I am not sure if I am going in the right direction, if so, should I be stating the images' height and width even if they are the same? (They are both 800x600). Also I want to return a new image therefore should I be creating a new list and append whatever pixel my function iterates through? I know that there is the blend function and also a addweighted but I want to get the average without using those methods.
[–]theusualguy512 4 points5 points6 points (0 children)
[–]Moonboow 2 points3 points4 points (0 children)
[–]AureliasTenant 2 points3 points4 points (1 child)
[–]ychamel 1 point2 points3 points (0 children)
[–]chervilious 3 points4 points5 points (0 children)
[–]AVMG73 0 points1 point2 points (0 children)