Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Edge highlights is an effect that accentuates boundaries and edges in images. Un

ID: 3758997 • Letter: E

Question

Edge highlights is an effect that accentuates boundaries and edges in images. Unlike sharpening, which increases the contrast around edges, the goal here is to add highlights with certain color at the edges. This can be achieved by adding a scaled version of the magnitude of image gradient to the image. In a sense this is an alpha blending between the image and it’s gradient magnitude.

- Implement an ImageJ plugin that takes a gray-level image and produce bright “whitish” highlights on the edges. You need to make sure that the range of any pixel does not exceed 255. Test the code on the image ireland-03gray.tif

I think we need to obtain a magnitude of the image(I do not know how), then have a method to scale it (I do not know how). Then, convolve that scaled version with the image. I'm not sure. Please help.

Explanation / Answer

The PlugIn of image is :
The functions provided by ImageJ’s fare commands most of them are in rundown plugins themselves bouncecel be for ever and ever by freak plugins. These plugins are Java classes implementing the imminent interfaces that are covering in a unquestionable folder. They bouncecel be conveniently compiled inner ImageJ or by a batch charge in a Win dows environment. Plugins hinge on by ImageJ are sitting in the Plugins menu.
Types of PlugIns
There are basically two types of plugins:
1.those that do not require an image as input implementing the interface PlugIn
2. plugin filters, that require an image as input implementing the interface PlugIns

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

we call the method showAbout that displays an about dialog

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

The run method implements the actual function of the plugin

ublic 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] = (byte)(255-pixels[i]);
}
}

showAbout uses the static method showMessage from class IJ to display a text in a message box. The first parameter specifies its title, the second the message text

void showAbout()
{
IJ.showMessage("About Inverter_...", "This sample plugin filter inverts 8-bit images.");
}

Image Representation in ImageJ:
When we recognized the sip plugin in this we borer that images are represented by ImagePlus and ImageProcessor objects in ImageJ. In this requirement we require a closer notice at the behavior images are handled by ImageJ. Methods that are not discussed in the text nonetheless are of some holding the bag for mail plugins gave a pink slip bebutton in the reference.


To construct an ImagePlus use one of the following constructors are used . ImagePlus()
ImagePlus(java.lang.String urlString)
ImagePlus(java.lang.String title, java.awt.Image img)
ImagePlus(java.lang.String title, ImageProcessor ip)
ImagePlus(java.lang.String title, ImageStack stack)
Processor:
The type of the processor depends on the ImageType. You can get and set the image processor using these two methods of an ImagePlus.

import ij.plugin.filter.PlugInFilter;
import ij.process.*;
import java.awt.*;
public class ColorInverter_ implements PlugInFilter

public int setup(String arg, ImagePlus imp)
{
if (arg.equals("about"))
{ showAbout(); return DONE;
}
return DOES_RGB+SUPPORTS_MASKING+NO_CHANGES;
}
{
public void run(ImageProcessor ip)
{

int w = ip.getWidth();
int h = ip.getHeight();
Rectangle roi = ip.getRoi();
ImagePlus inverted = NewImage.createRGBImage ("Inverted image", w, h)
ImageProcessor inv_ip = inverted.getProcessor();
inv_ip.copyBits(ip,0,0,Blitter.COPY);
int[] pixels = (int[]) inv_ip.getPixels();
for (int i=roi.y; i<roi.y+roi.height; i++)
{
int offset =i*w;
for (int j=roi.x; j<roi.x+roi.width; j++)
}
int pos = offset+j;
int c = pixels[pos];
int r = (c&0xff0000)>>16;
int g = (c&0x00ff00)>>8;
int b = (c&0x0000ff) ;
r=255-r;
g=255-g;
b=255-b;
pixels[pos] = ((r & 0xff) << 16) + ((g & 0xff) << 8) + (b & 0xff);

}
}
inverted.show();
inverted.updateAndDraw();
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote