Get colour value and change the colour

edited August 2015 in How To...

Hi there,

Very new to processing and am looking to move a project into the video space. However to move forward I would like to learn how to select a specific hex colour from an image and then change its value.

This is probably very simple, so any help would be greatly appreciated.

The next steps, would be trying to implement this in real time through a camera feed.

Thanks!

Answers

  • edited August 2015 Answer ✓

    Start with a sketch that just displays an image. You can move to displaying a video later (keep in mind that a video is just lots of images displayed one at a time).

    To do that, you will need to load the image, and display it. Learn about setup(), draw(), loadImage(), image(), and PImage. Look them up in the Reference.

    Then you need to select a color. Use mouseX and mouseY, and get(). Also, look at the reference to learn about Processing's "color" data type. You might want to use println() to display some information about your color.

    Once that's working, read up on loadPixels(), pixels, and updatePixels(). You can use them to check each color in an image to see if it matches a given color, and replace it with a different color if you like. You will also need to know how to use conditionals (if statements) and loops (for loops).

    It's hard to help you without seeing the code that you have working already - we have no idea how far along in this process you are! Write what you can - even a poor attempt will do - and post it here for more help. Also check the sticky thread to learn how to format your posted code correctly.

Sign In or Register to comment.