please format code with </> button * homework policy * asking questions
Hi, I’m new to processing, and I’m trying to flip the image horizontally. However, I am facing the problem of only flipping half of the image, could you guys help me with it?
Here is my code:
PImage img;
void setup()
{
img = loadImage( “coffee.JPG”);
size(img.width,img.height); // use size of the image
noLoop();
}
void draw()
{
// Use for loops to go through every pixel
for (int y = 0; y < img.height; y++ )
{
for (int x = 0; x < img.width/2; x++ )
{
// get the color values
float r = red (img.get(x, y));
float g = green(img.get(x, y));
float b = blue (img.get(x, y));
/******** image processing goes here **********/
// Set the new color to the pixel
img.set(width-x, y, color(r,g,b));
}
}
image(img, 0, 0); // display the image
}