In a recent workshop we were assigned the task of getting a single pixel colour value from an image. Below I will discuss how I achieved this.
As you can see above my image of a fish has an orange square in the top left corner. I have done this by creating a pImage variable and assigning the name ‘img’. I have then loaded the image in the setup section by using the loadImage function. I have also created a color variable called ‘c’ and then assigned it to my PImage (img) and used the get function to grab a the pixel which is 200 pixels accross and 200 pixels down. I have then created a rect which has a fill of the color variable c, which is using get to find the pixel colour in the image, resulting in the square being the colour of that pixel.
Here I have done the same thing but changed the get parameters (highlighted) to 27k,120, which is the fishes eye. As you can see above the rectangle has now changed colour to black.
What I didn’t do in the workshop was work out how to get the colour value of a pixel that is being captured by the camera, though I intend to work this when I next get time.