Thanks PhiLho. I didn't mention the other part of the code where after changing the pixel he has to PImage.save the imageg by hitting the key "S".
The Image is being saved onto the filesystem after being modified by the img.set() and then img.save() but when a loadImage is performed to load the same saved image, it shows the pixel but on a different location.
Am attaching the code with the missing part.
Thanks again, appreciate your input
Code:
void draw()
{
if (mousePressed)
{
ellipse(mouseX,mouseY,2,2);
/*
* This part is if you want to change the color of the pixel under the mouse click
*/
int pixelColorYellow = color(254, 255, 0);
img.set(mouseX,mouseY, pixelColorYellow);
img.updatePixels();
img.get().save(fileName.substring(0, fileName.length()-4).concat("_Modified.jpg")); // This does save the file on the disk
}
if (key =='L')
{
imgModified = loadImage(fileName.substring(0, fileName.length()-4).concat("_Modified.jpg"));
image(imgModified,screenWidth-472,100,412,412);
}
if (key=='S' || key=='s')
{
if (fileName != "")
{
// Saving the modified image to be loaded for Simulation
// If the original Medical Image has been modified then save it with a new name for Simulation
if (img.isModified())
{
img.get().save(fileName.substring(0, fileName.length()-4).concat("_Modified.jpg"));
}
}
else
{
System.out.println("Cannot save without an image being loaded first!");
}
}
}