Plugin- new image, set pixels-newbie question

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

Plugin- new image, set pixels-newbie question

Liisa Palomaa
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
Reply | Threaded
Open this post in threaded view
|

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

Michael Miller
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
Reply | Threaded
Open this post in threaded view
|

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

Graeme Kidd
In reply to this post by Liisa Palomaa
Sorry for such a short reply as I am about to go to bed.
If you are wanting to make a plug-in then it will be beneficial to you if
you give this tutorial on "Writing ImageJ Plugins-A Tutorial" a read. It
shows you how to make a plug-in and how to use the createByteImage which
creates a new 8 bit greyscale or colour image with the specified title,
width and height.

http://mtd.fh-hagenberg.at/depot/imaging/imagej/tutorial171.pdf

Is there any command for setPixels?
"The pixel array you work on is a reference to the ImageProcessor's pixel
array. So any modifications affect the ImageProcessor immediately. However,
if you want the Image - Processor to use another (perhaps newly created)
array, you can do this using:
void setPixels(java.lang.Object pixels)"

Hope that helps in someway.
-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Liisa
Palomaa
Sent: 30 October 2006 02:59
To: [hidden email]
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