user11322373
user11322373

Reputation:

remove red text from image

How can I remove the red text from image,enter image description here

src = cv2.imread('original.png', cv2.IMREAD_UNCHANGED)
src[:,:,2] = np.zeros([src.shape[0], src.shape[1]])
#cv2.imwrite('changed.png',src) 

this does remove the red color but also gives it a blueish background,how can I fix this or maybe do it in a better way.

Ideally the output would be like this

output

Upvotes: 1

Views: 2721

Answers (1)

TheoNeUpKID
TheoNeUpKID

Reputation: 893

The problem is that your extracting the image's Red Component, and not the image's red channel itself. Try the following:

src = cv2.imread('original.png', cv2.IMREAD_UNCHANGED)
print(src.shape)

#extract red channel
red_channel = src[:,:,2]

#write red channel to greyscale image
cv2.imwrite('changed.png', red_channel)

Below you'll see resources that describe the difference. If you found this useful please mark as answer. Thanks

Resources:

Upvotes: 1

Related Questions