Java Advanced Imaging (JAI) Application Program Interface (API) provides a low cost, licensing independence and inter-platform independent API to create java applications for image processing, representation and visualization . It gives a professional approach to image manipulation by allowing to write our own routines rather than just using commercial image processing systems.
JAI provides an effective solution for handling large image files over the internet. There are different classes in JAI to deal with image processing.
PlanarImage
This is the basic class used for image representation, it uses Raster objects to store the pixel data associated with the image. The PlanarImage image object has a ColorModel with it,which specifies how the pixel data is converted into colors.
TiledImage
This class is used to read and write image data. It isa sub class of the above PlanarImage class.
RenderedOp
This is also a sub-class of PlanarImage used to represent a node in rendered imaging chain , which is one of the most powerful concepts in JAI allowing processing of an image in a series of steps.
Advantages of JAI
  • Cross-platform Imaging – since JAI runs from java library, it has the feature of a java application ‘write once and run anywhere ‘ ,the cross platform interoperability. This is one of the major advantages considering other commercial applications.
  • Object-oriented API – JAI is purely object oriented
  • Flexible and Extensible – JAI provides an extensible framework to support advanced image processing, allows the programmer to add customized implementations to core API. JAI also provides compression/decompression and coding/decoding methods.
  • Device Independent – In JAI the image transformation to pixel is only specified at run time,making it possible to develop device independent applications.
  • Distributed Imaging – JAI support RMI and IIP protocols, making it one of the effective solutions for distributed image processing.
  • Tiling -This feature allows users process image in different sections. So only the corresponding section need to be downloaded at a time. This feature is very effective in case of low bandwidth situations.
  • Extends existing Java 2D imaging capabilities
  • The JAI support different color systems (CIE/CMYK/RGB) and conversion between them.
  • Consider an example to understand how the image is processed using JAI
      Web server with an application server
    1.load the image using
    FileSeekableStream fstream = = new FileSeekableStream(“file”);
    2.create an operator to decode the image
    RenderedOp image = JAI.create(“stream”, fstream);
    3.create an interpolation object and parameterBlock
    4.Interpolation intp = Interpolation.getInstance(Interpolation.INTERP_BILINEAR);
    ParameterBlock paramb= new ParameterBlock();
    paramb.addSource(image);
    paramb.add(3.0F); // x scale
    paramb.add(3.0F); // y scale
    paramb.add(1.0F); // x translate
    paramb.add(1.0F); // y translate
    paramb.add(intp); // interpolation
    5. RenderedOp imagenew = JAI.create(“scale”, params);
    or
    float scale = ‘newWidth’ / image.getWidth();
    RenderingHints rh = new RenderingHints(RenderingHints.KEY_RENDERING,
    RenderingHints.VALUE_RENDER_QUALITY);

    RenderedOp imagenew = JAI.create(“SubsampleAverage”,
    image, scale, scale, rh);
    6.Output the image:
    JAI.create(“encode”, resizedImage, outputStream, “JPEG”, null);

    JAI helps programmers to make easy image processing applications and it reduces substantial programming effort of developers by over re-coding algorithms. JAI provides above 80 pre-canned algorithms to save development time. JAI is more portable than any other typical libraries targeted for specific platforms. It provides a scalable solution in image processing in PDA, laptop etc.