Package hipi.image.io

Examples of hipi.image.io.ImageEncoder


   * @throws IOException
   */
  @Test
  public void testEncodeImage() throws IOException {
    ImageDecoder decoder = PPMImageUtil.getInstance();
    ImageEncoder encoder = JPEGImageUtil.getInstance();
    FileInputStream pis;
    FileOutputStream jos;
    FloatImage image;
    String[] fileName = {"canon-ixus", "cmyk-jpeg-format"};
    for (int i = 0; i < fileName.length; i++)
    {
      pis = new FileInputStream("data/test/JPEGImageUtilTestCase/truth/" + fileName[i] + ".ppm");
      image = decoder.decodeImage(pis);
      jos = new FileOutputStream("/tmp/" + fileName[i] + ".jpg");
      encoder.encodeImage(image, null, jos);
      Runtime rt = Runtime.getRuntime();
      Process pr = rt.exec("compare -metric PSNR data/test/JPEGImageUtilTestCase/truth/" + fileName[i] + ".ppm /tmp/" + fileName[i] + ".jpg /tmp/psnr.png");
      Scanner scanner = new Scanner(new InputStreamReader(pr.getErrorStream()));
      float psnr = scanner.hasNextFloat() ? scanner.nextFloat() : 0;
      assertTrue(fileName[i] + " PSNR is too low : " + psnr, psnr > 30);
View Full Code Here


   * @throws IOException
   */
  @Test
  public void testEncodeImage() throws IOException {   
    ImageDecoder decoder = PPMImageUtil.getInstance();
    ImageEncoder encoder = PNGImageUtil.getInstance();
    FileInputStream pis;
    FileOutputStream pos;
    FloatImage image;
    String[] fileName = {"canon-ixus", "cmyk-jpeg-format"};
    for (int i = 0; i < fileName.length; i++)
    {
      pis = new FileInputStream("data/test/PNGImageUtilTestCase/truth/" + fileName[i] + ".ppm");
      image = decoder.decodeImage(pis);
      pos = new FileOutputStream("/tmp/" + fileName[i] + ".png");
      encoder.encodeImage(image, null, pos);
      Runtime rt = Runtime.getRuntime();
      Process pr = rt.exec("compare -metric MSE data/test/PNGImageUtilTestCase/truth/" + fileName[i] + ".ppm /tmp/" + fileName[i] + ".png /tmp/psnr.png");
      Scanner scanner = new Scanner(new InputStreamReader(pr.getErrorStream()));
      float mse = scanner.hasNextFloat() ? scanner.nextFloat() : -1;
      assertTrue(fileName[i] + " MSE is too high : " + mse, mse == 0);
View Full Code Here

    @Override
    public void map(ImageHeader key, FloatImage value, Context context)
    throws IOException, InterruptedException {
      if(value != null){
        ImageEncoder encoder = JPEGImageUtil.getInstance();
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        encoder.encodeImage(value, key, os);
        os.close();
        byte[] val = os.toByteArray();
        long sig = 0<<2 | ImageType.JPEG_IMAGE.toValue();
        context.write(new LongWritable(sig), new BytesWritable(val));
      }
View Full Code Here

TOP

Related Classes of hipi.image.io.ImageEncoder

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.