edu.jhu.tmaj.beans.masks.data
Class PixelUtil

java.lang.Object
  extended by edu.jhu.tmaj.beans.masks.data.PixelUtil

public final class PixelUtil
extends java.lang.Object

Contains utility methods for pixel conversion. We define pixels as an integer that represents an RGB value. The ColorProcessor in ImageJ using an int[] array to represent its pixels, and every element of this int array is a pixel in this RGB format. Anytime we use the term "Pixel", we will be referring to this definition.


Method Summary
static int byteToUnsignedInt(byte b)
          Converts a byte (-128 to 127) to an unsigned int, which ranges from 0 - 255.
static int colorToPixel(java.awt.Color color)
          Converts a java.awt.Color into a int pixel.
static java.awt.Color hsbToColor(HsbPixel hsbPixel)
          Converts an HsbPixel into a java.awt.Color
static int hsbToPixel(HsbPixel hsb)
          Converts an hsb pixel to a imagej-ready pixel.
static java.awt.Color pixelToColor(int pixel)
          Converts a int pixel into a java.awt.Color
static HsbPixel pixelToHsb(int pixel)
          Converts an int pixel into an HsbPixel.
static byte unsignedIntToByte(int i)
          Converts an unsigned int from 0 - 255 into a byte (-128 to 127).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

colorToPixel

public static int colorToPixel(java.awt.Color color)
Converts a java.awt.Color into a int pixel.


pixelToColor

public static java.awt.Color pixelToColor(int pixel)
Converts a int pixel into a java.awt.Color


hsbToColor

public static java.awt.Color hsbToColor(HsbPixel hsbPixel)
Converts an HsbPixel into a java.awt.Color


hsbToPixel

public static int hsbToPixel(HsbPixel hsb)
Converts an hsb pixel to a imagej-ready pixel.


pixelToHsb

public static HsbPixel pixelToHsb(int pixel)
Converts an int pixel into an HsbPixel. This is obtained from ImageJ's getHSB(byte[] H, byte[] S, byte[] B) function. We copy this function so we can cache the hsb[] array. Caching this array gives us better spped.


byteToUnsignedInt

public static int byteToUnsignedInt(byte b)
Converts a byte (-128 to 127) to an unsigned int, which ranges from 0 - 255.


unsignedIntToByte

public static byte unsignedIntToByte(int i)
Converts an unsigned int from 0 - 255 into a byte (-128 to 127).