How to change the color of a png image to different colors

I am hoping to know how to write a program that changes the pixels of an image to different colors (ideally it would loop through r,g,b for a variety of colors)

tint is not giving the desired effect I want.

say if the image is green, I would want the program to change its pixels to shades of red, blue, green, orange, brown, yellow etc. thanks!

PImage amzbox;
PImage logo;
PImage bckgrd;

void setup(){
size(1000,displayHeight);

amzbox = loadImage(“amzbox.png”);
logo = loadImage(“amznlogo.png”);
bckgrd = loadImage(“amzbackg.png”);
image(logo,0,-50);
}

void draw(){
run();
}

void run(){
image(bckgrd,0,-50);
image(amznbox,0,-50);
// tint(random(255), random(255),random(255));

}

1 Like

Hi and welcome

This may help

https://funprogramming.org/90-Change-pixel-hue-saturation-and-brightness.html

https://funprogramming.org/89-Create-your-own-photo-filters.html

https://funprogramming.org/88-Change-pixels-using-the-pixels-array.html

https://funprogramming.org/81-How-to-read-the-color-of-a-pixel.html

1 Like

Instead of PImage how about you use PGraphics? This allows you to write specific points to specific areas. Example

PGraphics img;

int red = 0;
int blue = 0;
int green = 0;


void setup(){
img = new PGraphics(100,100);
img.beginDraw();
img.fill(color(255,0,0));
img.stroke(color(255,0,0));
img.point(0,0);
img.endDraw();

image(img,0,0);

//you get the color of a point on screen by

round(red(get(0,0)));
}

I hope this helps!