Package hipi.image

Examples of hipi.image.FloatImage


      Mapper<ImageHeader, FloatImage, IntWritable, FloatImage> {   
   
    public void map(ImageHeader key, FloatImage value, Context context)
        throws IOException, InterruptedException {
      if (value != null && value.getWidth() > N && value.getHeight() > N) {
        FloatImage mean = new FloatImage(N, N, 1);
        for (int i = 0; i < 10; i++) {
          int x = (value.getWidth() - N) * i / 10;
          for (int j = 0; j < 10; j++) {
            int y = (value.getHeight() - N) * j / 10;
            FloatImage patch = value.crop(x, y, N, N).convert(FloatImage.RGB2GRAY);
            mean.add(patch);
          }
        }
        mean.scale(0.01f);
        context.write(new IntWritable(0), mean);
View Full Code Here


  public static class MeanReduce extends
      Reducer<IntWritable, FloatImage, IntWritable, FloatImage> {
    public void reduce(IntWritable key, Iterable<FloatImage> values,
        Context context) throws IOException, InterruptedException {
      FloatImage mean = new FloatImage(N, N, 1);
      int total = 0;
      for (FloatImage val : values) {
        mean.add(val);
        total++;
      }
      if (total > 0) {
        mean.scale(1.0f / total);
        context.write(key, mean);
      }
    }
View Full Code Here

          g[i * N + j] *= tg;
      /* DistributedCache will be deprecated in 0.21 */
      Path file = DistributedCache.getLocalCacheFiles(job.getConfiguration())[0];
      FSDataInputStream dis = FileSystem.getLocal(job.getConfiguration()).open(file);
      dis.skip(4);
      FloatImage image = new FloatImage();
      image.readFields(dis);
      mean = image.getData();
    }
View Full Code Here

        float[][] tp = new float[100][N * N];
        for (int i = 0; i < 10; i++) {
          int x = (value.getWidth() - N) * i / 10;
          for (int j = 0; j < 10; j++) {
            int y = (value.getHeight() - N) * j / 10;
            FloatImage patch = value.crop(x, y, N, N).convert(FloatImage.RGB2GRAY);
            float[] pels = patch.getData();
            for (int k = 0; k < N * N; k++)
                tp[i * 10 + j][k] = (pels[k] - mean[k]) * g[k];
          }
        }
        float[] cov = new float[N * N * N * N];
        for (int i = 0; i < N * N; i++)
          for (int j = 0; j < N * N; j++) {
            cov[i * N * N + j] = 0;
            for (int k = 0; k < 100; k++)
              cov[i * N * N + j] += tp[k][i] * tp[k][j];
          }
        context.write(new IntWritable(0), new FloatImage(N * N, N * N, 1, cov));
      }
    }
View Full Code Here

  public static class CovarianceReduce extends
      Reducer<IntWritable, FloatImage, IntWritable, FloatImage> {
    public void reduce(IntWritable key, Iterable<FloatImage> values,
        Context context) throws IOException, InterruptedException {
      FloatImage cov = new FloatImage(N * N, N * N, 1);
      for (FloatImage val : values) {
        cov.add(val);
      }
      context.write(key, cov);
    }
View Full Code Here

          pels[i* w * 3 + j * 3] = (float) (Y / 255.0);
          pels[i* w * 3 + j * 3 + 1] = (float) (Y / 255.0);
          pels[i* w * 3 + j * 3 + 2] = (float) (Y / 255.0);
        }
    }
    FloatImage image = new FloatImage(w, h, 3, pels);
    return image;
  }
View Full Code Here

  public static void convert(
      InputStream image_in, OutputStream image_out,
      ImageDecoder decoder_in, ImageEncoder encoder_out) throws IOException {

    ImageHeader header = decoder_in.decodeImageHeader(image_in);
    FloatImage float_image = decoder_in.decodeImage(image_in);
    encoder_out.encodeImage(float_image, header, image_out);
  }
View Full Code Here

  public void testDecodeImage() throws IOException {
    ImageDecoder jpgDecoder, ppmDecoder;
    jpgDecoder = JPEGImageUtil.getInstance();
    ppmDecoder = PPMImageUtil.getInstance();
    FileInputStream fis;
    FloatImage ppmImage, jpgImage;
    String[] fileName = {"canon-ixus", "cmyk-jpeg-format"};
    for (int i = 0; i < fileName.length; i++)
    {
      fis = new FileInputStream("data/test/JPEGImageUtilTestCase/truth/" + fileName[i] + ".ppm");
      ppmImage = ppmDecoder.decodeImage(fis);
View Full Code Here

  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);
View Full Code Here

    if (_cacheData != null) {
      ImageDecoder decoder = CodecManager.getDecoder(ImageType.fromValue(_cacheType));
      if (decoder == null)
        return null;
      ByteArrayInputStream bis = new ByteArrayInputStream(_cacheData);
      FloatImage image = decoder.decodeImage(bis);
      bis.close();
      return image;
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of hipi.image.FloatImage

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.