import numpy as np
import matplotlib.pyplot as plt
import cv2 as cv
#this program conversts color of certain sections of image
#each pixel is checked for the r g b and modified using a numpy array
image = cv.imread('rg.png')
#print(image.shape)
#print(np.asarray(image))
width , height , channels = image.shape
#print(width)
#print(height)
#print(channels)
plt.imshow(image)
plt.show()
#print(image[29][29])
zero_array = np.zeros((2, 3, 3))
for pixeli in range(width):
#print(pixeli)
for pixelj in range(height):
# print(pixeli,pixelj)
#print(image[pixeli][pixelj])
pixelvalue = image[pixeli][pixelj]
#print(pixelvalue)
if pixelvalue[0] == 76 and pixelvalue[1] == 177 and pixelvalue[2] == 34:
#print('mach')
r = 0
g = 0
b = 0
image[pixeli][pixelj] = [r, g, b]
plt.imshow(image)
plt.show()
The pixel level color are changed as you can see the change in lower right rectangles.
please feel free to add any comments.
import matplotlib.pyplot as plt
import cv2 as cv
#this program conversts color of certain sections of image
#each pixel is checked for the r g b and modified using a numpy array
image = cv.imread('rg.png')
#print(image.shape)
#print(np.asarray(image))
width , height , channels = image.shape
#print(width)
#print(height)
#print(channels)
plt.imshow(image)
plt.show()
#print(image[29][29])
zero_array = np.zeros((2, 3, 3))
for pixeli in range(width):
#print(pixeli)
for pixelj in range(height):
# print(pixeli,pixelj)
#print(image[pixeli][pixelj])
pixelvalue = image[pixeli][pixelj]
#print(pixelvalue)
if pixelvalue[0] == 76 and pixelvalue[1] == 177 and pixelvalue[2] == 34:
#print('mach')
r = 0
g = 0
b = 0
image[pixeli][pixelj] = [r, g, b]
plt.imshow(image)
plt.show()
The pixel level color are changed as you can see the change in lower right rectangles.
please feel free to add any comments.
Comments
Post a Comment