0

I'm working in Python reading in images, and getting a 3-dimensional matrix of RGB values for pixels.

I want to take these 3-d arrays and make a matrix with only RGB values equal to r=62, g=57, b=47.

How can I do this? I've looked into masking but I don't understand how to implement this.

Edit: I'm talking about numpy arrays not lists. numpy has a lot of built in functions, for loops are pretty inefficient.

3
  • @Art I said arrays. imread from scimage.io returns a 3-d numpy array. Commented Dec 12, 2016 at 0:40
  • 1
    @TigerhawkT3 that post is for lists, does it also work for 3-d numpy arrays? Commented Dec 12, 2016 at 0:41
  • That would be stackoverflow.com/questions/19666626/… instead then. Next time, please provide all relevant information within your question. Commented Dec 12, 2016 at 0:45

1 Answer 1

1

If rgb is a NumPy array, then this should work:

rgb[rgb!=[62,57,47]]=0
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.