I have been working on a small problem of changing the values of pixels to "red" (or any color other than black or white).
I modify the pixel itself and its six neighbors. As per the changes the pixel values must be changed to "red". But when I run another loop over the image to verify the changes, out of 7 pixels only 3 or sometimes 4 come up as red. Upon further analysis I found out that the pixel values are some shade of red.
How can I make sure that when I set the value of the pixel it is color(255,0,0) and not a shade?
Ciao!
img1.loadPixels();
int loc = pixelX + pixelY*img2.width;
img1.pixels[loc] = color(255,0,0);
loc = pixelX + (pixelY +1)*img2.width;
img1.pixels[loc] = color(255,0,0);
loc = (pixelX+1) + (pixelY+1)*img2.width;
img1.pixels[loc] = color(255,0,0);
loc = pixelX + (pixelY-1)*img2.width;
img1.pixels[loc] = color(255,0,0);
loc = (pixelX+1) + (pixelY-1)*img2.width;
img1.pixels[loc] = color(255,0,0);
loc = (pixelX+1) + (pixelY)*img2.width;
img1.pixels[loc] = color(255,0,0);
loc = (pixelX-1) + (pixelY)*img2.width;
img1.pixels[loc] = color(255,0,0);
img1.updatePixels();
img1.save("modifiedImage.jpg");
img1.loadpixels();
for (int i=2; i < img1.width; i++)
{
for (int j=2; j < img1.height; j++)
{
loc = i + (2*j)*img1.width;
if (img1.pixels[i + (2*j)*img1.width] == color(255,0,0))
I am trying to simulate a set of values which are being calculated inside a class. Its based on cellular automata. I tried simulating the same from within the for loops but it never showed up as a simulation in the final output (I used a PImage on top on the real image). This is the class definition -> public class TumorGrowth extends PApplet
My question is how can I simulate the growth of the tumor in my case so that it shows growing or simulating based on the values returned in the 2D array? The function cancerGrowth() is called from within the program once the user presses the simulate button on the screen and its outside the draw() function. Is it possible to perform simulation outside the draw() function in processing.