Re: Plugin- new image, set pixels-newbie question

Posted by Michael Miller on
URL: http://imagej.273.s1.nabble.com/Plugin-new-image-set-pixels-newbie-question-tp3701144p3701146.html

Liisa,

I'm very glad you finally asked a question that I knew the answer to :-)

http://rsb.info.nih.gov/ij/developer/index.html

Please check this out! You can see browsable source code, API documentation,
etc. to help you get started writing plugins for ImageJ.
Since you want to learn how to write plugins, I suggest you start with
http://mtd.fh-hagenberg.at/depot/imaging/imagej/ (download the PDF on this
website)

That should give you plenty of resources on how to create a class that
implements either a Plugin or PluginFilter and imports the necessary
packages to get your plugin running.

I hate being vague, so here is a little more specific help. A method to
create a 384x384 image, color it with whatever pixels you want, and display
it:

public boolean createImage() {
 int width = 384;
 int height = 384;
 int stacks = 1;

 String title = "The Title of your Image";
 ImagePlus myIMP = NewImage.createByteImage (title, width, height, stacks,
NewImage.FILL_WHITE);

 ImageProcessor myNP = surfaceIMP.getProcessor();

 int color, x, y;
 for (y=0; y<height; y++) {
  for (x=0; x<width; x++) {
   color = someInteger; // any byte value from 0-255 since this is a
ByteImage (8-bit)
   myNP.putPixel(x,y,color); // this is your 'setPixels'
  }
 }

 myIMP.show();
 IJ.selectWindow(title);
 return true;
}

Good luck!
-Mike
[hidden email]

----- Original Message -----
From: "Liisa Palomaa" <[hidden email]>
To: <[hidden email]>
Sent: Sunday, October 29, 2006 8:59 PM
Subject: Plugin- new image, set pixels-newbie question


> Hi everyone!
>
> I try to find a plugin -that create a newimage-and lets me to set the
> pixelvalues.
> I want to have a new image wthat is 384*384 pixels.(8bit)
>
> Should I use this command:
> static ImagePlus createByteImage (java.lang.String title, int width,
> int height, int fill)
> How and where should I put the width and height? How should the plugin
> look like? Do I have to write something for string title?
>
> Is there any command for setPixels?
>
> Sorry for sending this kind of newbie questions- but I can't get my
> plugin to work.
>
> Thanks in advance
> //Liisa