ThreeB 1.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

ClassicGlow.java
Go to the documentation of this file.

    00001 import ij.plugin.*;
    00002 import ij.process.*;
    00003 import ij.gui.*;
    00004 import ij.*;
    00005
    00006 import java.awt.image.*;
    00007
    00008
    00009 ///Plugin implementing the classic glow/hot
    00010 ///LUT which seems to be missing from ImageJ
    00011 ///@ingroup gPlugin
    00012 public class ClassicGlow implements PlugIn
    00013 {
    00014     static byte red[];
    00015     static byte green[];
    00016     static byte blue[];
    00017
    00018     static{
    00019         red = new byte[256];
    00020         green = new byte[256];
    00021         blue = new byte[256];
    00022
    00023         for(int i=0; i < 256; i++)
    00024         {
    00025             if(i < 85)
    00026                 red[i] = (byte)((i*3) & 0xff);
    00027             else
    00028                 red[i] = (byte)(255 & 0xff);
    00029
    00030             if(i < 85)
    00031                 green[i] = 0;
    00032             else if(i -85 < 85)
    00033                 green[i] = (byte)(((i-85)*3) & 0xff);
    00034             else
    00035                 green[i] = (byte)(255 & 0xff);
    00036
    00037             if(i < 170)
    00038                 blue[i] = 0;
    00039             else
    00040                 blue[i] = (byte)(((i-170)*3) & 0xff);
    00041         }
    00042     }
    00043
    00044
    00045     public void run(String arg)
    00046     {
    00047         ImagePlus imp = WindowManager.getCurrentImage();
    00048
    00049         //If the image exists, it must be of the correct type, otherwise, make a ramp.
    00050         if (imp!=null)
    00051         {
    00052             if (imp.getType()==ImagePlus.COLOR_RGB)
    00053             {
    00054                 IJ.error("Color tables cannot be assiged to RGB Images.");
    00055                 return;
    00056             }
    00057         }
    00058         else
    00059         {
    00060             //Create a ramp
    00061             ByteProcessor r = new ByteProcessor(256, 32);
    00062
    00063             for(int y=0; y < 32; y++)
    00064                 for(int x=0; x < 256; x++)
    00065                     r.set(x, y, x);
    00066
    00067             imp = new ImagePlus("Glow", r);
    00068             imp.show();
    00069         }
    00070
    00071
    00072         ImageProcessor ip = imp.getProcessor();
    00073         ColorModel cm = new IndexColorModel(8, 256, red, green, blue);
    00074         ip.setColorModel(cm);
    00075         if (imp.getStackSize()>1)
    00076             imp.getStack().setColorModel(cm);
    00077         imp.updateAndDraw();
    00078     }
    00079 }