Facemorph.mask
Class BitmapMask

java.lang.Object
  extended by Facemorph.mask.BitmapMask
All Implemented Interfaces:
MaskInterface, java.lang.Cloneable

public class BitmapMask
extends java.lang.Object
implements MaskInterface

Extends the MaskInterface class to allow for bitmap based masking


Constructor Summary
BitmapMask()
           
 
Method Summary
 MaskInterface clone()
          Creates and returns a copy of this object.
protected  java.awt.Image convertToImagePlusAlpha(FloatImage mask)
           
 FloatImage getAsFloatImage(Template tem, int w, int h, float min, float max)
          Constructs a FloatImage with values of 0 (masked) and max (not masked)
 double getBlur()
          Gets the size of the Gaussian (or implementation specific) blur to apply to the mask
 javax.swing.filechooser.FileNameExtensionFilter getExt()
           
 FloatImage maskImage(FloatImage img, Template tem, java.awt.Color col, boolean reverse)
          Masks an image using the template object specified/
 java.awt.Image maskImage(java.awt.Image img, Template tem, java.awt.Color col, boolean reverse)
          Masks an image using the template object specified/
 void paint(Template tem, java.awt.Graphics g, java.awt.Color col, int xoff, int yoff, int width, int height, float zoom)
          Paint the mask using the supplied Graphics component
 void paint(Template tem, java.awt.Graphics g, java.awt.Color col, int xoff, int yoff, int width, int height, float zoom, boolean invert)
          Paint the mask using the supplied Graphics component, with option to invert the mask
 void read(java.io.File file)
          Reads a mask from a file
 void read(java.io.Reader r)
          Reads a mask from a Reader (e.g.
 void setBlur(double blurLevel)
          Sets the size of the Gaussian (or implementation specific) blur to apply to the mask The size specified as multiple applications of a Gaussian blur function
 void setFloatImage(FloatImage img)
          Sets the floatimage to be used as a mask
 void write(java.io.File file)
          Writes the mask to a file
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitmapMask

public BitmapMask()
Method Detail

setFloatImage

public void setFloatImage(FloatImage img)
Sets the floatimage to be used as a mask

Parameters:
img -

read

public void read(java.io.File file)
          throws java.io.FileNotFoundException,
                 java.io.IOException
Reads a mask from a file

Specified by:
read in interface MaskInterface
Parameters:
file - The name of the mask file
Throws:
java.io.FileNotFoundException - thrown if file not found
java.io.IOException - thrown if some other I/O error

clone

public MaskInterface clone()
Description copied from interface: MaskInterface
Creates and returns a copy of this object.

Specified by:
clone in interface MaskInterface
Overrides:
clone in class java.lang.Object

read

public void read(java.io.Reader r)
          throws java.io.IOException
Reads a mask from a Reader (e.g. InputStreamReader or FileReader)

Parameters:
r - The Reader to read from
Throws:
java.io.IOException - if an IOException occurs

write

public void write(java.io.File file)
           throws java.io.IOException
Writes the mask to a file

Specified by:
write in interface MaskInterface
Parameters:
file - the name of the file to write to
Throws:
java.io.IOException

getAsFloatImage

public FloatImage getAsFloatImage(Template tem,
                                  int w,
                                  int h,
                                  float min,
                                  float max)
Description copied from interface: MaskInterface
Constructs a FloatImage with values of 0 (masked) and max (not masked)

Specified by:
getAsFloatImage in interface MaskInterface
Parameters:
tem - the template to apply the mask to
w - The width of the output mask image
h - The height of the output mask image
min - The values to draw outside the masked regions
max - The values to draw in the masked regions
Returns:
The mask as a FloatImage, this allows it to be smoothed for softer edges

paint

public void paint(Template tem,
                  java.awt.Graphics g,
                  java.awt.Color col,
                  int xoff,
                  int yoff,
                  int width,
                  int height,
                  float zoom)
Description copied from interface: MaskInterface
Paint the mask using the supplied Graphics component

Specified by:
paint in interface MaskInterface
Parameters:
tem - Template to form mask around
g - Graphics object to paint onto
col - Colour to paint the mask
xoff - the x-offset
yoff - the y-offset
zoom - the zoom

paint

public void paint(Template tem,
                  java.awt.Graphics g,
                  java.awt.Color col,
                  int xoff,
                  int yoff,
                  int width,
                  int height,
                  float zoom,
                  boolean invert)
Description copied from interface: MaskInterface
Paint the mask using the supplied Graphics component, with option to invert the mask

Specified by:
paint in interface MaskInterface
Parameters:
tem - Template to form mask around
g - Graphics object to paint onto
col - Colour to paint the mask
xoff - the x-offset
yoff - the y-offset
zoom - the zoom
invert - will invert the mask if true.

maskImage

public java.awt.Image maskImage(java.awt.Image img,
                                Template tem,
                                java.awt.Color col,
                                boolean reverse)
Description copied from interface: MaskInterface
Masks an image using the template object specified/

Specified by:
maskImage in interface MaskInterface
Parameters:
img - The image to mask
tem - The template to use
col - The colour to draw in the masked regions
reverse - If true draw outside the polygon defined by the mask, otherwise draw inside
Returns:
return the masked image, the original is unmodified

maskImage

public FloatImage maskImage(FloatImage img,
                            Template tem,
                            java.awt.Color col,
                            boolean reverse)
Description copied from interface: MaskInterface
Masks an image using the template object specified/

Specified by:
maskImage in interface MaskInterface
Parameters:
img - The floating point image to mask
tem - The template to use
col - The colour to draw in the masked regions
reverse - If true draw outside the polygon defined by the mask, otherwise draw inside
Returns:
return the masked image, the original is unmodified

convertToImagePlusAlpha

protected java.awt.Image convertToImagePlusAlpha(FloatImage mask)

getExt

public javax.swing.filechooser.FileNameExtensionFilter getExt()
Specified by:
getExt in interface MaskInterface
Returns:
the file extensions appropriate for this type of mask

setBlur

public void setBlur(double blurLevel)
Description copied from interface: MaskInterface
Sets the size of the Gaussian (or implementation specific) blur to apply to the mask The size specified as multiple applications of a Gaussian blur function

Specified by:
setBlur in interface MaskInterface

getBlur

public double getBlur()
Description copied from interface: MaskInterface
Gets the size of the Gaussian (or implementation specific) blur to apply to the mask

Specified by:
getBlur in interface MaskInterface
Returns: