1

Given the next picture:

robot = io.imread('robot.png')

enter image description here

robot will be a 1277x789x3 RGB matrix.

The question is that I want to change the orange color of the robot to purple, like this:

enter image description here

the problem is that I don't know how to detect the robot's orange color. Any suggestions?

Sergio
  • 63
  • 5

1 Answers1

2

I found a similar problem here: I want to change the colors in image with python from specific color range to another color

Following the code from link above and changing some parameters:

#!/usr/local/bin/python3
import cv2 as cv
import numpy as np

# Load the aerial image and convert to HSV colourspace
image = cv.imread("path/image.jpg")
hsv=cv.cvtColor(image,cv.COLOR_BGR2HSV)

# Define lower and uppper limits of what we call "orange"
orange_lo=np.array([10,100,20])
orange_hi=np.array([30,255,255])

# Mask image to only select oranges
mask=cv.inRange(hsv,orange_lo,orange_hi)

# Change image to purple where we found orange
image[mask>0]=(188,0,188)

cv.imwrite("result.png",image)