Change color of a pixel on image. Plugin Java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Change color of a pixel on image. Plugin Java

Danae
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.


Thank you so much.

Dánae


PD: Please, don't ask me why I'm doing a plugin instead of a macro, just answer my doubt please.
Reply | Threaded
Open this post in threaded view
|

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

Wayne Rasband-2
> 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
Reply | Threaded
Open this post in threaded view
|

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

Danae
Thank you so much Wayne.

It has been so useful.


Have a nice day :)


Dánae