Package net.sourceforge.jiu.data

Examples of net.sourceforge.jiu.data.RGB24Image


   * becomes a pixel in an image of width 1 and height
   * palette.getNumEntries().
   */
  public static RGB24Image convertPaletteToImage(Palette palette)
  {
    RGB24Image result = new MemoryRGB24Image(1, palette.getNumEntries());
    for (int index = 0; index < palette.getNumEntries(); index++)
    {
      result.putSample(INDEX_RED, 0, index, palette.getSample(INDEX_RED, index));
      result.putSample(INDEX_GREEN, 0, index, palette.getSample(INDEX_GREEN, index));
      result.putSample(INDEX_BLUE, 0, index, palette.getSample(INDEX_BLUE, index));
    }
    return result;
  }
View Full Code Here


   * Uses {@link net.sourceforge.jiu.codecs.PNMCodec}.
   */
  public static void save(Palette palette, File paletteFile) throws
    IOException
  {
    RGB24Image image = convertPaletteToImage(palette);
    PNMCodec codec = new PNMCodec();
    codec.setOutputStream(new FileOutputStream(paletteFile));
    codec.setAscii(true);
    codec.setImage(image);
    try
View Full Code Here

    PixelImage pixelImage = getInputImage();
    if (!(pixelImage instanceof RGB24Image))
    {
      throw new WrongParameterException("Input image must implement RGB24Image.");
    }
    RGB24Image originalImage = (RGB24Image)pixelImage;
    quantizer.setInputImage(originalImage);
    quantizer.setMapping(true); // we want the quantizer to create an output image
    quantizer.setTruecolorOutput(false); // that output image must be paletted
    quantizer.process();
    for (int currentPass = 0; currentPass < numPasses; currentPass++)
View Full Code Here

    MissingParameterException,
    WrongParameterException
  {
    PixelImage in = getInputImage();
    prepare(in);
    RGB24Image out = (RGB24Image)getOutputImage();
    if (in instanceof BilevelImage)
    {
      process((BilevelImage)in, out);
    }
    else
View Full Code Here

  private IntegerImage readImage() throws
    InvalidFileStructureException,
    java.io.IOException
  {
    RGB24Image rgb24Image = null;
    Paletted8Image paletted8Image = null;
    IntegerImage result = null;
    int numChannels = 1;
    int bytesPerRow = 0;
    switch(depth)
    {
      case(8):
      {
        paletted8Image = new MemoryPaletted8Image(width, height, palette);
        result = paletted8Image;
        numChannels = 1;
        bytesPerRow = width;
        break;
      }
      case(24):
      {
        rgb24Image = new MemoryRGB24Image(width, height);
        result = rgb24Image;
        numChannels = 3;
        bytesPerRow = width;
        break;
      }
    }
    setImage(result);
    byte[][] buffer = new byte[numChannels][];
    for (int i = 0; i < numChannels; i++)
    {
      buffer[i] = new byte[bytesPerRow];
    }
    for (int y = 0, destY = -getBoundsY1(); destY <= getBoundsY2(); y++, destY++)
    {
      if (rgb24Image != null)
      {
        for (int x = 0; x < width; x++)
        {
          buffer[RGBIndex.INDEX_BLUE][x] = in.readByte();
          buffer[RGBIndex.INDEX_GREEN][x] = in.readByte();
          buffer[RGBIndex.INDEX_RED][x] = in.readByte();
        }
        rgb24Image.putByteSamples(RGBIndex.INDEX_RED, 0, destY, getBoundsWidth(), 1, buffer[0], getBoundsX1());
        rgb24Image.putByteSamples(RGBIndex.INDEX_GREEN, 0, destY, getBoundsWidth(), 1, buffer[1], getBoundsX1());
        rgb24Image.putByteSamples(RGBIndex.INDEX_BLUE, 0, destY, getBoundsWidth(), 1, buffer[2], getBoundsX1());
      }
      else
      if (paletted8Image != null)
      {
        in.readFully(buffer[0], 0, width);
View Full Code Here

  private int initOctree()
  {
    int numUniqueColors = 0;
    root = new OctreeNode();
    RGB24Image in = (RGB24Image)getInputImage();
    for (int y = 0; y < in.getHeight(); y++)
    {
      for (int x = 0; x < in.getWidth(); x++)
      {
        int red = in.getSample(INDEX_RED, x, y);
        int green = in.getSample(INDEX_GREEN, x, y);
        int blue = in.getSample(INDEX_BLUE, x, y);
        if (OctreeNode.add(root, red, green, blue, 8))
        {
          numUniqueColors++;
        }
      }
View Full Code Here

    }
  }

  private void mapImage()
  {
    RGB24Image in = (RGB24Image)getInputImage();
    Palette palette = createPalette();
    Paletted8Image out = new MemoryPaletted8Image(in.getWidth(), in.getHeight(), palette);
    int[] origRgb = new int[3];
    int[] quantizedRgb = new int[3];
    for (int y = 0; y < in.getHeight(); y++)
    {
      for (int x = 0; x < in.getWidth(); x++)
      {
        origRgb[INDEX_RED] = in.getSample(INDEX_RED, x, y);
        origRgb[INDEX_GREEN] = in.getSample(INDEX_GREEN, x, y);
        origRgb[INDEX_BLUE] = in.getSample(INDEX_BLUE, x, y);
        int index = map(origRgb, quantizedRgb);
        out.putSample(0, x, y, index);
      }
    }
    setOutputImage(out);
View Full Code Here

  {
    if (image == null)
    {
      return null;
    }
    RGB24Image in = (RGB24Image)image;
    int[] result = new int[8];
    for (int y = 0; y < image.getHeight(); y++)
    {
      for (int x = 0; x < image.getWidth(); x++)
      {
        int red = in.getSample(RGBIndex.INDEX_RED, x, y) >> 7;
        int green = in.getSample(RGBIndex.INDEX_GREEN, x, y) >> 7;
        int blue = in.getSample(RGBIndex.INDEX_BLUE, x, y) >> 7;
        int index = (red << 2) | (green << 1) | blue;
        result[index]++;
      }
    }
    return result;
View Full Code Here

    graphics.fillRect(0, 0, awtImage.getWidth(), awtImage.getHeight());
    // draw on it in white
    graphics.setColor(Color.WHITE);
    graphics.drawString("Hello World!", 5, 15);
    // conversion AWT image to JIU image
    RGB24Image jiuImage = ImageCreator.convertImageToRGB24Image(awtImage);
    // saving JIU image to file
    PNGCodec codec = new PNGCodec();
    codec.setImage(jiuImage);
    codec.appendComment("Hello World! as a text comment; " +
      "see http://schmidt.devlib.org/jiu/introduction.html");
View Full Code Here

  public static void main(String[] args) throws Exception
  {
    String[] FILE_NAMES = {"jiu-hello-world.png", "resources/images/image1.jpg", "out-image1.jpg"};
    for (int i = 0; i < FILE_NAMES.length; i++)
    {
      RGB24Image image = ToolkitLoader.loadAsRgb24Image(FILE_NAMES[i]);
      System.out.println(FILE_NAMES[i] + "\t" + Histogram3DCreator.count(image));
    }
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.jiu.data.RGB24Image

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.