core.image
Class RGBImage

java.lang.Object
  extended bycore.image.RGBImage

public class RGBImage
extends java.lang.Object

Stores an RGB image = < width, height, red-buffer, green-buffer, blue-buffer > An RGBImage stores a rectangular, color image in RGB format. The image's width and height are specified upon construction, and three byte arrays are created to store all the red, green, and blue components separately. The pixel data is stored in left-right, top-down scanline order. Each component value is from 0 to 255, stored in a byte.

Version:
1.0
Author:
Andreas Sundquist

Field Summary
 byte[] b
          r, g, and b store the red, green, and blue pixel components
 byte[] g
          r, g, and b store the red, green, and blue pixel components
 int height
          width, height store the dimensions of the image.
 int[] offset
          offset[] indexes the left-most pixel of each scanline in r,g,b[] The index of pixel (x,y) is therefore offset[y]+x
 byte[] r
          r, g, and b store the red, green, and blue pixel components
 int size
          width, height store the dimensions of the image.
 int width
          width, height store the dimensions of the image.
 
Constructor Summary
RGBImage(int width, int height)
          Constructs a new RGBImage =
 
Method Summary
 void BfromScalarImage(ScalarImage image, double B)
           
 void BtoScalarImage(ScalarImage image)
           
private  double clamp(double x, double min, double max)
           
 void Clear()
          Sets all the pixels values to zero
 void Copy(RGBImage image)
          Copies the RGB values from the top-left corner of 'image' to 'this' Requires: 'image' is at least as large as 'this'
 void Copy(RGBImage image, int xorigin, int yorigin)
          Copies the RGB values from the sub-window of 'image' starting at (xorigin, yorigin) to 'this'.
 void fromScalarImage(ScalarImage image, double R, double G, double B)
          Sets 'this' to a colorized representation of 'image' within the window starting at the top-left corner.
 void fromScalarImage(ScalarImage image, int xorigin, int yorigin, double R, double G, double B)
          Sets 'this' to a colorized representation of 'image' within the sub-window starting at (xorigin, yorigin).
 void fromScalarImageMagnitude(ScalarImage image, Vec2Field f, Vec2Transform ftoi, Vec3Field func)
           
 byte getB(int x, int y)
          Returns: the blue component of the pixel at (x, y) Requires: 0<=x
 byte getG(int x, int y)
          Returns: the green component of the pixel at (x, y) Requires: 0<=x
 byte getR(int x, int y)
          Returns: the red component of the pixel at (x, y) Requires: 0<=x
 void GfromScalarImage(ScalarImage image, double G)
           
 void GtoScalarImage(ScalarImage image)
           
 void RfromScalarImage(ScalarImage image, double R)
           
 void RtoScalarImage(ScalarImage image)
           
 void Set(int x, int y, byte R, byte G, byte B)
          Sets the pixel at (x, y) to the color (R, G, B).
 void toBGRBytes(byte[] buf)
          Copies the pixel data in 'this' to the byte-buffer 'buf' in BGR packed order.
 void toRGBBytes(byte[] buf)
          Copies the pixel data in 'this' to the byte-buffer 'buf' in RGB packed order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

width

public final int width
width, height store the dimensions of the image. size = width*height, the number of pixels


height

public final int height
width, height store the dimensions of the image. size = width*height, the number of pixels


size

public final int size
width, height store the dimensions of the image. size = width*height, the number of pixels


r

public byte[] r
r, g, and b store the red, green, and blue pixel components


g

public byte[] g
r, g, and b store the red, green, and blue pixel components


b

public byte[] b
r, g, and b store the red, green, and blue pixel components


offset

public final int[] offset
offset[] indexes the left-most pixel of each scanline in r,g,b[] The index of pixel (x,y) is therefore offset[y]+x

Constructor Detail

RGBImage

public RGBImage(int width,
                int height)
Constructs a new RGBImage =

Method Detail

Clear

public void Clear()
Sets all the pixels values to zero


Copy

public void Copy(RGBImage image,
                 int xorigin,
                 int yorigin)
Copies the RGB values from the sub-window of 'image' starting at (xorigin, yorigin) to 'this'. Requires: the sub-window fits inside 'image'


Copy

public void Copy(RGBImage image)
Copies the RGB values from the top-left corner of 'image' to 'this' Requires: 'image' is at least as large as 'this'


getR

public byte getR(int x,
                 int y)
Returns: the red component of the pixel at (x, y) Requires: 0<=x

getG

public byte getG(int x,
                 int y)
Returns: the green component of the pixel at (x, y) Requires: 0<=x

getB

public byte getB(int x,
                 int y)
Returns: the blue component of the pixel at (x, y) Requires: 0<=x

Set

public void Set(int x,
                int y,
                byte R,
                byte G,
                byte B)
Sets the pixel at (x, y) to the color (R, G, B). Requires: 0<=x

toRGBBytes

public void toRGBBytes(byte[] buf)
Copies the pixel data in 'this' to the byte-buffer 'buf' in RGB packed order. Requires: buf.length = 3*width*height


toBGRBytes

public void toBGRBytes(byte[] buf)
Copies the pixel data in 'this' to the byte-buffer 'buf' in BGR packed order. Requires: buf.length = 3*width*height


fromScalarImage

public void fromScalarImage(ScalarImage image,
                            int xorigin,
                            int yorigin,
                            double R,
                            double G,
                            double B)
Sets 'this' to a colorized representation of 'image' within the sub-window starting at (xorigin, yorigin). The (R,G,B) triad is the color of a scalar value of 1.0, and the resulting RGB values are all clamped to the 0-255 range. Requires: the sub-window fits within 'image'


fromScalarImage

public void fromScalarImage(ScalarImage image,
                            double R,
                            double G,
                            double B)
Sets 'this' to a colorized representation of 'image' within the window starting at the top-left corner. The (R,G,B) triad is the color of a scalar value of 1.0, and the resulting RGB values are all clamped to the 0-255 range. Requires: 'image' is at least as large as 'this'


fromScalarImageMagnitude

public void fromScalarImageMagnitude(ScalarImage image,
                                     Vec2Field f,
                                     Vec2Transform ftoi,
                                     Vec3Field func)

RfromScalarImage

public void RfromScalarImage(ScalarImage image,
                             double R)

RtoScalarImage

public void RtoScalarImage(ScalarImage image)

GfromScalarImage

public void GfromScalarImage(ScalarImage image,
                             double G)

GtoScalarImage

public void GtoScalarImage(ScalarImage image)

BfromScalarImage

public void BfromScalarImage(ScalarImage image,
                             double B)

BtoScalarImage

public void BtoScalarImage(ScalarImage image)

clamp

private double clamp(double x,
                     double min,
                     double max)