Wednesday
April 16, 2014

Homework Help: computers

Posted by Billy on Friday, February 25, 2011 at 12:55am.

Need help with writing an imageJ plugin which is in java. Here is the question:
Create an ImageJ plugin for 8-bit grayscale images of arbitrary size that
paints a white frame (with pixel value 255) 10 pixels wide into the image.

Here is the current plugin to modify:

import ij.*;
import ij.plugin.filter.PlugInFilter;
import ij.process.*;
import java.awt.*;

/** This sample ImageJ plug-in filter inverts 8-bit images.

A few things to note:
1) Filter plug-ins must implement the PlugInFilter interface.
2) Plug-ins located in the "plug-in" folder must not use
the package statement;
3) Plug-ins residing in the "plugins" folder and with at
least one underscore in their name will be automatically
installed in the PlugIns menu.
4) Plug-ins can be installed in other menus be editing
the ij.properties file.
5) You must edit ij.properties to get you plug-in to appear
in the Help->About PlugIns sub-menu.
6) The class name and file name must be the same.
7) This filter works with ROIs, including non-rectangular ROIs.
5) It will be called repeatedly to process all the slices in a stack.
6) This plug-in can't be named "Invert_" because this would
conflict with the built-in command of the same name.
7) The inverterting is accomplished with: pixels[i] = pixels[i] = (byte)(0);
8) Set ROI to value pixels[i] = (byte)(0);
*/

public class Inverter_ implements PlugInFilter {

public int setup(String arg, ImagePlus imp) {
if (arg.equals("about"))
{showAbout(); return DONE;}
return DOES_8G+DOES_STACKS+SUPPORTS_MASKING;
}

public void run(ImageProcessor ip) {
byte[] pixels = (byte[])ip.getPixels();
int width = ip.getWidth();
Rectangle r = ip.getRoi();
int offset, i;
for (int y=r.y; y<(r.y+r.height); y++) {
offset = y*width;
for (int x=r.x; x<(r.x+r.width); x++) {
i = offset + x;
pixels[i] = pixels[i] = (byte)(0);
}
}
}

void showAbout() {
IJ.showMessage("About Inverter_...",
"This sample plug-in filter inverts 8-bit images. Look\n" +
"at the 'Inverter_.java' source file to see how easy it is\n" +
"in ImageJ to process non-rectangular ROIs, to process\n" +
"all the slices in a stack, and to display an About box."
);
}
}

Answer this Question

First Name:
School Subject:
Answer:

Related Questions

humanities - Do you know GATEWAYS TO WORLD LITERATURE THE ANCIENT WORLD THROUGH ...
computer - this isnt really a school question but i have a question about the ...
Powerpoint #3 - okay, I need to do a powerpoint for this career "computer ...
eng. macbeth - this is a question on macbeth act II, i truly NEED anyone's help ...
Java - create a java program that accepts students names, and test scores from a...
Geometry - I appreciate any help you can give me. Here is my question: Find the ...
Java Programming - Don't know how to start.. Can anyone help me? For this ...
math - paul paints a house in 4 hours, mike paints the same house in 6 hours. ...
english - You are writing a paragraph on how to make your favorite sandwich. You...
computers - why do we need computer ethics? Why should we need ethics at all? ...

Search
Members