Login  Register

Re: Change color of a pixel on image. Plugin Java

Posted by Wayne Rasband-2 on Mar 15, 2017; 7:35pm
URL: http://imagej.273.s1.nabble.com/Change-color-of-a-pixel-on-image-Plugin-Java-tp5018304p5018320.html

> On Mar 15, 2017, at 7:58 AM, Danae <[hidden email]> wrote:
>
> Good Afternoon.
>
> I'm currently doing a plugin for imageJ and I need to change the color of
> some of the pixels (given its coordinates)
> I've seen how people do this on a macro but I can't figure out how to do it
> in JAVA.
>
> For example, I want to change the color from black to red

Here is JavaScript code that changes the color of the pixel at 200,200 in the Leaf example image from green to red.

-wayne

   img = IJ.openImage("http://wsr.imagej.net/images/leaf.jpg");
   ip = img.getProcessor();
   ip.setColor(Color.red);
   roi = new Roi(200,200,1,1);
   ip.fill(roi);
   img.show();
   img.setRoi(170,166,70,70);
   IJ.run("To Selection", "”);


> --
> View this message in context: http://imagej.1557.x6.nabble.com/Change-color-of-a-pixel-on-image-Plugin-Java-tp5018304.html
> Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html