package yi.iu.processor.seg.blob;

/**
 * LabeledRegionFeatures generated by BlobworldSegmenter
 */

import yi.iu.region.LabeledRegionFeatures;
import yi.iu.imgdb.learn.*;
import yi.util.config.*;
import yi.iu.processor.color.reg.merge.*;
import yi.util.io.input.*;
import java.awt.*;

public class BlobworldLabeledRgnFts extends LabeledRegionFeatures
{
  static final long serialVersionUID = -2501535559898707541L;


  public BlobworldLabeledRgnFts() {};

  public BlobworldLabeledRgnFts(double[][] means, int[] labels, int w, int h,
                            int old_w, int old_h, boolean zeroAsBg) {
    super(means, labels, w, h, old_w, old_h, zeroAsBg, 6, true);
  }

  protected double[][] generateFeatureVectors(String processor_name, int mode, Dimension fv_dim) {

    // remove the region pixel number (the last number)
    fv_dim.width = m_ftVectDim - 1;
    fv_dim.height = featureMeans.length;

    double[][] fv = new double[featureMeans.length][];
    for (int i=0; i<fv.length; i++) {
      if (featureMeans[i] == null) continue;
      fv[i] = new double[featureMeans[i].length - 1];
      for (int j=0; j<fv[i].length; j++) {
        fv[i][j] = featureMeans[i][j];
      }
    }
    return fv;
  }


  public int[] colorDemo(Dimension d) {
    d.width = width; d.height = height;

    int[] demo = (int[])m_labels.clone();
    int[] colors = new int[featureMeans.length];
    for (int i=0; i<featureMeans.length; i++) {
      colors[i] = featureMeans[i]==null?
          0xffffffff:
          yi.iu.processor.color.CIELab.lab2rgb(featureMeans[i][0], featureMeans[i][1], featureMeans[i][2]);
    }
    for (int i=0; i<demo.length; i++) demo[i] = colors[m_labels[i]];
    return demo;
  }
}
