'python function to change RGB values of an image
I have this function that solely displays the red RGB values of an image. However, I am confused about how the function works. Specifically, why is there a 0 in brackets in this line:
newimage[i][j] = [image[i][j][0], 0, 0]
How can I alter this function to swap the green and blue RGB values while keeping the red value the same?
from matplotlib.pyplot import imshow #command to display a 2D array as an image
from imageio import imread #command to read images from a file or url
coffee = imread('imageio:coffee.png') #Image
def RedImage(image):
newimage = ArrayOfZeros(400, 600)
for i in range(400):
for j in range(600):
newimage[i][j] = [image[i][j][0], 0, 0]
return newimage
imshow(RedImage(coffee))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
