Package com.day.image

Class EmbossOp

  • All Implemented Interfaces:
    java.awt.image.BufferedImageOp

    public class EmbossOp
    extends AbstractBufferedImageOp
    The EmbossOp implements embossing of an image against another image, the so called bump image. The embossing algorithm works like this :
    1. Define the position of the light source using two angles, the azimut and the elevation. The azimut defines the direction in the image plane from where the light shines and the elevation defines the height above the image plane of the light source.
    2. Define a filtersize defining the spread of the embossing effect. We could also say, this is sort of the size of the light.
    3. Define the bump image. This image is scaled to gray and then used to define the embossing piece.
    4. For each pixel position in the images :
      • Define a plane E: ax + bx + cx + d = 0 where a is the luminance difference between pixels above and below the current pixel, b is the luminance difference between pixels left and right of the current pixel and c is constant relative to the filtersize.
      • Calculate the scale factor to apply to the pixel in the image as follows :
        • If factors a and b both are zero, the plane E is no plane at all and the scale factor is the height of the light source.
        • Else it is the distance of the light source to the above defined plane.
      • Multiply each pixel with the scale factor, ignoring the alpha channels.

    The emobossing area is the smaller of the bump and the image to emboss. You will get the best results from using an image as the bump image and some monochromatic image as the image to emboss.

    Since:
    coati
    • Constructor Summary

      Constructors 
      Constructor Description
      EmbossOp​(java.awt.image.BufferedImage bump, float azimut, float elevation, float filtersize)
      Creates a new EmbossOp filter instance with the given parameters for embossing.
    • Constructor Detail

      • EmbossOp

        public EmbossOp​(java.awt.image.BufferedImage bump,
                        float azimut,
                        float elevation,
                        float filtersize)
        Creates a new EmbossOp filter instance with the given parameters for embossing. The bump image is copied into the instance so that subsequent changes to the bump image do not have an effect on the embossing operation.
        Parameters:
        bump - the image being used for the 'bump'
        azimut - the light direction azimut in degrees.
        elevation - the light direction elevation in degrees.
        filtersize - the filtersize for the embossing.
        Throws:
        java.lang.IllegalArgumentException - if any of the azimut, elevation or filtersize arguments is negative or Float.NaN.
        java.lang.NullPointerException - if bump is null.