// Path: core/src/main/java/org/hipi/image/PixelArray.java
// public abstract class PixelArray {
// 
//   public static final int TYPE_BYTE  = 0;
//   public static final int TYPE_USHORT = 1;
//   public static final int TYPE_SHORT = 2;
//   public static final int TYPE_INT   = 3;
//   public static final int TYPE_FLOAT  = 4;
//   public static final int TYPE_DOUBLE  = 5;
//   public static final int TYPE_UNDEFINED = 32;
// 
//   private static final int dataTypeSize[] = {1,2,2,4,4,8};
// 
//   /**
//    * Integer value indicating underlying scalar value data type.
//    */
//   protected int dataType;
// 
//   /**
//    * Size, in bytes, of a single scalar value in pixel array.
//    */
//   protected int size;
// 
//   /**
//    * Static function that reports size, in bytes, of a single scalar value for different types
//    * of pixel arrays.
//    *
//    * @param type scalar value type
//    *
//    * @return size, in bytes, of single scalar value for specified type
//    */
//   public static int getDataTypeSize(int type) {
//     if (type < TYPE_BYTE || type > TYPE_DOUBLE) {
//       throw new IllegalArgumentException("Unknown data type "+type);
//     }
//     return dataTypeSize[type];
//   }
// 
//   public PixelArray() {
//     this.dataType = TYPE_UNDEFINED;
//     this.size = 0;
//   }
// 
//   protected PixelArray(int dataType, int size) {
//     this.dataType = dataType;
//     this.size = size;
//   }
// 
//   public int getDataType() {
//     return dataType;
//   }
// 
//   public int getSize() {
//     return size;
//   }
// 
//   public abstract void setSize(int size) throws IllegalArgumentException;
// 
//   public abstract byte[] getByteArray();
// 
//   public abstract void setFromByteArray(byte[] bytes) throws IllegalArgumentException;
// 
//   public abstract int getElem(int i);
// 
//   public abstract int getElemNonLinSRGB(int i);
// 
//   public abstract void setElem(int i, int val);
// 
//   public abstract void setElemNonLinSRGB(int i, int val);
// 
//   public float getElemFloat(int i) {
//     return (float)getElem(i);
//   }
// 
//   public void setElemFloat(int i, float val) {
//     setElem(i,(int)val);
//   }
// 
//   public double getElemDouble(int i) {
//     return (double)getElem(i);
//   }
// 
//   public void setElemDouble(int i, double val) {
//     setElem(i,(int)val);
//   }
// 
// }


import org.hipi.image.PixelArray;
import org.hipi.image.RasterImage;
import org.hipi.util.ByteUtils;
import org.apache.hadoop.mapreduce.RecordReader;
import org.bytedeco.javacpp.opencv_core;
import org.bytedeco.javacpp.opencv_core.Mat;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
package org.hipi.opencv;



/**
 * Various static helper methods which facilitate conversion between HIPI and OpenCV image 
 * representations.
 */
public class OpenCVUtils {

  private static int[][] openCVTypeLUT = new int[][] 
      {{opencv_core.CV_8UC1, opencv_core.CV_8UC2, opencv_core.CV_8UC3, opencv_core.CV_8UC4},     
       {opencv_core.CV_16UC1, opencv_core.CV_16UC2, opencv_core.CV_16UC3, opencv_core.CV_16UC4},
       {opencv_core.CV_16SC1, opencv_core.CV_16SC2, opencv_core.CV_16SC3, opencv_core.CV_16SC4},
       {opencv_core.CV_32SC1, opencv_core.CV_32SC2, opencv_core.CV_32SC3, opencv_core.CV_32SC4},
       {opencv_core.CV_32FC1, opencv_core.CV_32FC2, opencv_core.CV_32FC3, opencv_core.CV_32FC4},
       {opencv_core.CV_64FC1, opencv_core.CV_64FC2, opencv_core.CV_64FC3, opencv_core.CV_64FC4}};
  
  /**
   * Returns the OpenCV data type which is associated with a particular {@link PixelArray} data type 
   * and number of bands.
   * 
   * @return integer representation of OpenCV data type
   */
  public static int generateOpenCVType(int pixelArrayDataType, int numBands) {
    
    int depthIndex = -1;
    switch(pixelArrayDataType) {
// Path: core/src/main/java/org/hipi/image/PixelArray.java
// public abstract class PixelArray {
// 
//   public static final int TYPE_BYTE  = 0;
//   public static final int TYPE_USHORT = 1;
//   public static final int TYPE_SHORT = 2;
//   public static final int TYPE_INT   = 3;
//   public static final int TYPE_FLOAT  = 4;
//   public static final int TYPE_DOUBLE  = 5;
//   public static final int TYPE_UNDEFINED = 32;
// 
//   private static final int dataTypeSize[] = {1,2,2,4,4,8};
// 
//   /**
//    * Integer value indicating underlying scalar value data type.
//    */
//   protected int dataType;
// 
//   /**
//    * Size, in bytes, of a single scalar value in pixel array.
//    */
//   protected int size;
// 
//   /**
//    * Static function that reports size, in bytes, of a single scalar value for different types
//    * of pixel arrays.
//    *
//    * @param type scalar value type
//    *
//    * @return size, in bytes, of single scalar value for specified type
//    */
//   public static int getDataTypeSize(int type) {
//     if (type < TYPE_BYTE || type > TYPE_DOUBLE) {
//       throw new IllegalArgumentException("Unknown data type "+type);
//     }
//     return dataTypeSize[type];
//   }
// 
//   public PixelArray() {
//     this.dataType = TYPE_UNDEFINED;
//     this.size = 0;
//   }
// 
//   protected PixelArray(int dataType, int size) {
//     this.dataType = dataType;
//     this.size = size;
//   }
// 
//   public int getDataType() {
//     return dataType;
//   }
// 
//   public int getSize() {
//     return size;
//   }
// 
//   public abstract void setSize(int size) throws IllegalArgumentException;
// 
//   public abstract byte[] getByteArray();
// 
//   public abstract void setFromByteArray(byte[] bytes) throws IllegalArgumentException;
// 
//   public abstract int getElem(int i);
// 
//   public abstract int getElemNonLinSRGB(int i);
// 
//   public abstract void setElem(int i, int val);
// 
//   public abstract void setElemNonLinSRGB(int i, int val);
// 
//   public float getElemFloat(int i) {
//     return (float)getElem(i);
//   }
// 
//   public void setElemFloat(int i, float val) {
//     setElem(i,(int)val);
//   }
// 
//   public double getElemDouble(int i) {
//     return (double)getElem(i);
//   }
// 
//   public void setElemDouble(int i, double val) {
//     setElem(i,(int)val);
//   }
// 
// }


// Path: core/src/main/java/org/hipi/opencv/OpenCVUtils.java
import org.hipi.image.PixelArray;
import org.hipi.image.RasterImage;
import org.hipi.util.ByteUtils;
import org.apache.hadoop.mapreduce.RecordReader;
import org.bytedeco.javacpp.opencv_core;
import org.bytedeco.javacpp.opencv_core.Mat;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;

package org.hipi.opencv;



/**
 * Various static helper methods which facilitate conversion between HIPI and OpenCV image 
 * representations.
 */
public class OpenCVUtils {

  private static int[][] openCVTypeLUT = new int[][] 
      {{opencv_core.CV_8UC1, opencv_core.CV_8UC2, opencv_core.CV_8UC3, opencv_core.CV_8UC4},     
       {opencv_core.CV_16UC1, opencv_core.CV_16UC2, opencv_core.CV_16UC3, opencv_core.CV_16UC4},
       {opencv_core.CV_16SC1, opencv_core.CV_16SC2, opencv_core.CV_16SC3, opencv_core.CV_16SC4},
       {opencv_core.CV_32SC1, opencv_core.CV_32SC2, opencv_core.CV_32SC3, opencv_core.CV_32SC4},
       {opencv_core.CV_32FC1, opencv_core.CV_32FC2, opencv_core.CV_32FC3, opencv_core.CV_32FC4},
       {opencv_core.CV_64FC1, opencv_core.CV_64FC2, opencv_core.CV_64FC3, opencv_core.CV_64FC4}};
  
  /**
   * Returns the OpenCV data type which is associated with a particular {@link PixelArray} data type 
   * and number of bands.
   * 
   * @return integer representation of OpenCV data type
   */
  public static int generateOpenCVType(int pixelArrayDataType, int numBands) {
    
    int depthIndex = -1;
    switch(pixelArrayDataType) {
      case PixelArray.TYPE_BYTE: