The J Maker
[The J Maker Home] [Program Home] [Pricing] [Contact] [FAQ]


Lab with Image Utilities (LIU)


Examples
The Package:
  • Introduction: The entire LIU package contains 90+ image programs with 24300+ lines of code. Most of the ideas in LIU are inspired from general image processing, computer vision and graphics books, and from commercial packages like PhotoShop, PhotoVision, XV, Image Magick, GIMP, etc. Some of the algorithms are my own inventions, especially in the category, "Special Effect". Categories include boundary detection (BD), contrast enhancement (CE), fundamental tools (FT), geometric transformations (GT), image segmentation (IS), mensuration (M), noise simulation / reduction (NSR), and special effect (SE). Programs can be run either individually or invoked from the main menu. They can start as applications or applets. While executed as an applet, it will not be able to save the results due to Java's security reasons and the subprogram "data" will not function properly. Reading multiple local and URL images is supported. Jquest 1999 winners' logo
  • Award: This applet was the second place cash award winner of the ACM / IBM 1999 Quest for Java Programming Contest. Click here to read the interview at ACM's Contest site
  • Download: [program download] [examples download]
  • File Description:
  • liu.html - staring HTML
  • liutm.gif - LIU logo
  • LIU*.class - library classes
  • liu.class - starting application
  • liuapplet.class - staring applet
  • liu*.class - used by main menu "liu"
  • GIF*.class - GIF encoder
  • other *.class - individual programs
  • liu*.gif - LIU program images
  • x*.gif x*.jpg - test images
  • proto.java - sample source code to use the image library
  • Author: The J Maker (webmaster@thejmaker.com)
  • Quick Execution Guide:
  • General Steps: For example, if you want to run the "ripple" program, you can do any of the followings:
  • Run as an application by starting the main menu from the command line with "java liu"
  • Select "ripple" from "Programs" menu
  • Enter "x1.gif" in input file list
  • Enter "y1.gif" in output file list
  • Click on "run" button
  • Run as an application by starting "ripple" from the command line with "java ripple x1.gif y1.gif"
  • Run as an applet by starting the main menu from the command line with "appletviewer liu.html"
  • Run as an applet by starting the main menu (liu.html) through the LIU launcher in a web browser (again, it will not save your result and subprogram "data" will not run properly)
  • Mouse Input: In addition to general mouse actions in JDK, some mouse input types on an image are implemented in LIU. They include:
    1. click to find out the current position in an image (Fig. 1), e.g. "affine" and most subprograms
    2. drag to get the frame containing the region (Fig. 2), e.g. "blossom" and most subprograms
    3. click to match positions between a pair of images to manually establish correspondences (Fig. 3), e.g. "morph"
    4. drag to get the vector representing point movement (Fig. 4), e.g. "warp"
    Fig. 1 Fig. 2 Fig. 3 Fig. 4
  • Text Input: A few points are to be noted here:
  • Properly modify all default values if desired. Some programs can take a variable number of filenames, e.g. "array", "view", etc.
  • Supply your input filenames with URLs when necessary, e.g. http://www.nowhere.com/test.gif
  • Technical Background:
    As mentioned at the beginning of this documentation, this package utilizes knowledge from computer vision, image processing, computer graphics, and some ideas from commercial packages. A few programs are started from scratch and thus original. I would rather not go into mathematical details here, e.g. matrix algebra or Fourier analysis because that will probably take up lengthy pages just to make people understand the magic behind these programs. Some references are attached at the end for interested readers.
    There are some major techniques explained as follows:
  • Java-related:
  • Some missing GUI components in JDK 1.1 are implemented just to make the interface more desirable, e.g. image button, labeled panel, etc.
  • Immediate garbage collection is done to keep the memory usage more managable.
  • Internal text parsing is done to handle variable number of file processing.
  • A general purpose image access library (starting with LIU*) is implemented and used in all subprograms.
  • The package is designed to run in different modes - independent or comprehensive, applet or application.
  • Global Spline Warping: In morph and warp, a global spline is defined by a set of vector bases computed from user's mouse inputs. With the basis function, all the points are transformed (warped) into new locations. This requires solving the matrix inverse by LU decomposition.
  • Cross Dissolve: In order to smoothly transform from image A to B, creating transition frames in between needs to take two things into account - position and color. This effect can be achieved by a combination of warping A to B and warping B to A simultaneously. Cross dissolve is thus to create smooth transitions. Fig. 5 and Fig. 6 are our image A and B. Fig. 7 is the 31st frame out of 60 in the sequence. Notice in Fig. 7 that the positions and colors of the features (e.g. eyes) have changed.
    Fig. 5 Fig. 6 Fig. 7
  • Double Buffering: The idea is actually very simple. We first prepare an offscreen duplicate graphics object. Then draw everything on this object. After all the drawing work has been accomplished, we then replace the onscreen image with this offscreen object. This is used to reduce the flickering, especially for animation.
  • Bilinear Interpolation: For example, when we zoom in an image, lots of pixels holes need to be filled in to see a bigger image. By simply using the color of the closest pixel (called nearest neighbor), we will sometimes get undesirable zigzag artifacts. (called aliasing) Therefore, interpolating the color with four closest corners is used here for better results. This is an area-based approach.
  • Inverse Mapping: When transforming a pixel to a new location, instead of applying the transformation matrix to the pixel and then finding out the new loation, it is done backwards in the package. That is - a new location is first assumed and then its orignal location is computed. Thus it is called inverse mapping. This will make the computation more efficient in bilinear interpolation.
  • Physically-Based Deformable Model: As in scissors, this idea is to put a rough initial boundary close to the desired object and hopefully this boundary will automatically deform to "exactly" overlap with the object boundary. Since it uses material properties (stretching and bending), it is thus called. This involves in solving a nonlinear differential equation.
  • A Complete Listing of Examples:
    Since this image package includes quite a number of utilities and has grown somewhat out of proportion, sometimes it is even difficult for myself to choose desirable utility programs in such a collection. These LIU examples serve in two ways: one is to give you a quick overview of what LIU can do, while the other is to act as a learn-from-example manual. Programs with are more emphasized in terms of complexity and originality. For example, morph is one of the most complex programs in the package because techniques in solving a system of linear equations and interpolating with cross dissolve are used.

    affine
    performs general affine transformations on the image, i.e. translation, scaling, rotation, shear
    array
    makes an image array
    bblur
    performs binomial blurring in a selected area
    bitplane
    outputs a selected bitplane on three color channels
    blossom
    blossoms the image
    blur
    blurs the image by averaging neighboring pixels
    bright
    adjusts brightness
    button
    creates a 3-D button
    cblur
    performs circular blurring on the image
    cmap
    displays a color map
    color
    converts the image colors into specified range
    colorpix
    only colors pixels of special interest
    compose
    composes two images with bitwise operations
    concave
    emulates the concave mirror effect
    contrast
    adjusts the image contrast by pixel mean
    convex
    emulates the convex mirror effect
    crop
    crops the image in a selected region
    cube
    maps the image onto a cube
    data
    displays the image data in hexadecimal and ASCII modes
    disarray
    disarrays an image
    dither
    performs dither halftoning
    dizzy
    emulates the dizzy effect
    drain
    computes the drainage pattern of the image on three color channels
    dwmtm
    performs double window modified trimmed mean filtering with specified windows
    emboss
    emulates the emboss effect
    expand
    adds some space to an image
    extrema
    finds local extrema
    flip
    flips the image along X, Y, or diagonal axis
    focus
    focuses on a portion of the image
    frame
    adds a frame to the image
    glass
    emulates the rectangular glass effect
    gnoise
    adds additive Gaussian noise to the image with specified mean and variance
    gpen
    emulates the graphic pen effect
    gradient
    computes the image gradient magnitude
    grey
    converts the image into grey with specified range
    half
    duplicates half an image
    height
    visualizes the image height in 3-D
    highlite
    highlights a selected region
    histeq
    performs histogram equalization
    impress
    emulates the impressionistic effect
    inv
    inverts the image color
    laplacian
    computes Laplacian transform
    layer
    emulates the layer effect with specified transformations
    level
    draws the level curve
    light
    emulates a light source
    line
    detects lines
    maxmin
    performs maxmin filtering with a sized window
    median
    performs median filtering with a sized window
    memo
    makes a photo memo
    mesh
    generates the image mesh
    mmse
    performs adaptive minimum mean square error filtering with a sized window and specified noise variance
    morph
    morphs one image into another (concatenated by GIF Construction Set)
    mosaic
    emulates the mosaic effect in a selected region
    motion
    performs motion blur
    nenoise
    generates negative exponential noise to the image with specified variance (for laser speckle)
    newspaper
    performs newspaper halftoning
    oil
    emulates the oil painting effect
    pastel
    emulates the pastel effect
    pnoise
    adds Poisson noise to the image with specified mean and standard deviation
    point
    detects points
    poster
    posterizes the image
    proto
    serves as a programming template
    pull
    pulls an image region
    push
    pushes an image region
    raise
    raises blocks in the image randomly
    redim
    changes image dimensions
    rgb
    outputs R, G, B channels of the image
    ripple
    emulates the ripple effect of the image at a selected center
    saturate
    saturates colors
    scissors
    cuts and pastes a portion of the first image
    scramble
    emulates the scramble effect
    shade
    performs simple Lambertian shading
    shadow
    creates an image shadow
    sharpen
    sharpens the image
    sketch
    emulates the sketch effect
    sphere
    maps an image onto a sphere
    spnoise
    adds salt and pepper noise to the image with specified probability
    spread
    spreads intensities
    stretch
    stretches the image at four corers
    text
    adds text onto the image
    stretch
    creates a text mask
    thermo
    emulates the thermo effect of the image
    thresh
    threshholds the image into black and white
    tile
    tiles the image
    tint
    adjusts the color tint angle
    triangle
    triangularizes the image
    twirl
    emulates the twirl effect
    unoise
    generates additive uniform noise to the image with specified mean and variance
    vibrate
    emulates the vibration effect
    view
    can display multiple images like a mini VCR
    warp
    warps the image according to mouse inputs
    wave
    emulates the visual effect of the image sitting in front of water
    wind
    emulates the wind effect
    wrinkle
    emulates the wrinkle effect

    References:
    1. Ken Arnold and James Gosling, "The Java Programming Language", Addison-Wesley, 1997
    2. Henning Bassmann and Philipp W. Besslich, "Ad Oculos Digital Image Processing", International Thomson Publishing, 1995
    3. Mary Campione and Kathy Walrath, "The Java Tutorial", Addison-Wesley, 1997
    4. M. Cohn, B. Morgan, M. Morrison, M. Nygard, D. Joshui, and T. Trinko, "Java Developer's Reference", Sams.net Publishing, 1996
    5. Foley, van Dam, Feiner, and Hughes, "Computer Graphics", Addison-Wesley Publishing, 1990
    6. Rafael C. Gonzalez and Richard E. Woods, "Digital Image Processing", Addison-Wesley Publishing, 1994
    7. Harley R. Myler and Arthur R. Weeks, "The Pocket Handbook of Image Processing Algorithms in C", PTR prentice Hall, 1993
    8. Vishvjit Nalwa, "A Guided Tour of Computer Vision", Addison-Wesley Publishing, 1993
    9. K. Siyan and J. Weaver, "Inside Java", New Riders Publishing, 1997


    [The J Maker Home] [Program Home] [Pricing] [Contact] [FAQ]