Reputation: 41
I'm trying to make an indoor navigation and I need indoor map that robot can automatically navigate the way. I'm thinking of using image which have different colors for each place(certain section), and I want to know the way to get the coordinates of the certain colors. So that I can designate places to certain color area using that coordinate. How can I get the list of pixel coordinates of the image which have certain color using python? In this case, I know RGB code of color! I am currently using pycharm
Upvotes: 2
Views: 2176
Reputation: 599
Assuming your picture has shape (Y, X, 3). Y
is the height of the image and X
the width. Last dimension is for the 3 RGB colors channels.
You can use this code on the image to get a list of pixels coordinates with particular RGB set:
def pixels(image, rgb_set):
set = list()
for j in range(0, image.shape[0]):
for i in range(0, image.shape[1]):
if image[j][i] == rgb_set:
set.append([j, i])
return set
Upvotes: 2