package de.mpi.rgblab.data;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import de.mpi.rgblab.color.ColorModel;
import de.mpi.rgblab.color.ColorType;
import de.mpi.rgblab.math.numeric.Numeric;
import de.mpi.rgblab.utils.ImageResizer;
import de.mpi.rgblab.utils.MemoryUtil;
import de.mpi.rgblab.utils.VisUtil;
/**
* at issue - compute saliency change radius
*
* @author nnachev
*
*/
public class ImageData {
// current data is a vector of coordinates (x,y), the classlabel and
// measures (z_score, visibility_score)
// x, y, classlabel, z_score, visibility_score
protected Vector<Vector<Integer>> point = new Vector<Vector<Integer>>();
protected Vector<Vector<Integer>> number_surrounding_elements = new Vector<Vector<Integer>>();
// protected Vector<Integer> class_labels; // = new Vector<Integer>();
protected int classNumbers = 0;
protected Vector<Integer> classSize = new Vector<Integer>();
/*
*
* it stores the number of every label class up to the current point. the
* variable is used for the integral image algorithm it starts with
* coordinates (0,0) then goes to (0,1), (0,2) (0,n), (1,0) (1,1) ... (1,n)
* ... (n,n)
*
* the first parameter corresponds the the parameter in the variable named
* data
*/
protected int[][][] integralClassLabels = null;
protected float[][][] integralSaliency = null;
protected float[][] integralVis = null;
protected Vector<Float> saliency = new Vector<Float>();
protected Vector<Float> visibility = new Vector<Float>();
protected Vector<Float> meanVis = new Vector<Float>();
public Vector<Float> getMeanViewVisibility() {
return meanVis;
}
protected double min_saliency;
protected double max_saliency;
protected double min_visibility;
protected double max_visibility;
protected static ColorModel labWhite = new ColorModel(100, 0, 0,
ColorType.LAB);
protected String outputFile = "measures.dat";
protected int x_res;
protected int y_res;
public int getX_res() {
return x_res;
}
public void setX_res(int x_res) {
this.x_res = x_res;
}
public int getY_res() {
return y_res;
}
public void setY_res(int y_res) {
this.y_res = y_res;
}
public Vector<Vector<Integer>> getData() {
return point;
}
public Vector<Vector<Integer>> getSurrounding() {
return number_surrounding_elements;
}
public int getClassNumbers() {
return classNumbers;
}
public int getNumberOfAllElements() {
return point.size();
}
// public ImageData(int x, int y) {
// x_res = x;
// y_res = y;
// }
public ImageData() {
}
public void printResolution() {
System.out.println(x_res);
System.out.println(y_res);
}
public void initResolution() {
Dimension windowSize = Toolkit.getDefaultToolkit().getScreenSize();
x_res = windowSize.width;
y_res = windowSize.height;
System.out.println("screen resolution");
printResolution();
}
public boolean importData(String inputData) {
// data = new Vector<Vector<Integer>>();
point.removeAllElements();
saliency.removeAllElements();
visibility.removeAllElements();
meanVis.removeAllElements();
number_surrounding_elements.removeAllElements();
// class_labels = new Vector<Integer>();
// saliency = new Vector<Double>();
// visibility = new Vector<Double>();
int oldClassNumbers = classNumbers;
readAndSortInputData(inputData);
if (integralClassLabels == null || classNumbers != oldClassNumbers) {
integralClassLabels = new int[y_res + 1][x_res + 1][classNumbers + 1];
}
if (integralSaliency == null || classNumbers != oldClassNumbers) {
integralSaliency = new float[y_res + 1][x_res + 1][classNumbers];
}
if (integralVis == null || classNumbers != oldClassNumbers) {
integralVis = new float[y_res + 1][x_res + 1];
}
precomputeIntegralClassLabelNumbers();
initMinSaliency();
initMaxSaliency();
initMinVisibility();
initMaxVisibility();
// freeMemory();
return true;
}
public boolean importDataWithoutTransformingToScreemRes(String inputData) {
// data = new Vector<Vector<Integer>>();
point.removeAllElements();
saliency.removeAllElements();
visibility.removeAllElements();
number_surrounding_elements.removeAllElements();
// class_labels = new Vector<Integer>();
// saliency = new Vector<Double>();
// visibility = new Vector<Double>();
int oldClassNumbers = classNumbers;
// readAndSortInputDataNoScreenRes(inputData);
if (integralClassLabels == null || classNumbers != oldClassNumbers) {
integralClassLabels = new int[y_res + 1][x_res + 1][classNumbers + 1];
}
if (integralSaliency == null || classNumbers != oldClassNumbers) {
integralSaliency = new float[y_res + 1][x_res + 1][classNumbers];
}
precomputeIntegralClassLabelNumbers();
initMinSaliency();
initMaxSaliency();
initMinVisibility();
initMaxVisibility();
// freeMemory();
return true;
}
public boolean importDataTest(String inputData) {
// data = new Vector<Vector<Integer>>();
point.removeAllElements();
saliency.removeAllElements();
visibility.removeAllElements();
// class_labels = new Vector<Integer>();
// saliency = new Vector<Double>();
// visibility = new Vector<Double>();
// readAndSortInputDataTest(inputData);
readAndSortInputData(inputData);
if (integralClassLabels == null)
integralClassLabels = new int[y_res + 1][x_res + 1][classNumbers];
if (integralSaliency == null)
integralSaliency = new float[y_res + 1][x_res + 1][classNumbers];
precomputeIntegralClassLabelNumbers0Test();
initMinSaliency();
initMaxSaliency();
initMinVisibility();
initMaxVisibility();
MemoryUtil.freeMemory();
return true;
}
// invokes readAndSortInputData1 which does not invert to screen coordinates
// and directly reads integers - is faster
public boolean importData1(String inputData) {
point = new Vector<Vector<Integer>>();
// class_labels = new Vector<Integer>();
saliency = new Vector<Float>();
visibility = new Vector<Float>();
readAndSortInputData1(inputData);
integralClassLabels = new int[y_res + 1][x_res + 1][classNumbers + 1];
if (integralSaliency == null)
integralSaliency = new float[y_res + 1][x_res + 1][classNumbers];
precomputeIntegralClassLabelNumbers();
initMinSaliency();
initMaxSaliency();
initMinVisibility();
initMaxVisibility();
// freeMemory();
return true;
}
private void initMinSaliency() {
min_saliency = 1000000;
}
private void initMaxSaliency() {
max_saliency = 0;
}
private void initMinVisibility() {
min_visibility = 1000000;
}
private void initMaxVisibility() {
max_visibility = 0;
}
// if we do not need to to tranform it to screen coordinates and to
// eliminate the duplicates
private void readAndSortInputData1(String inputFile) {
Comparator comp = new YXComparator();
// read the input data
Vector<Vector<Float>> coordinates = new Vector<Vector<Float>>();
Vector<Integer> class_label = new Vector<Integer>();
Vector<Vector<Integer>> ret = new Vector<Vector<Integer>>();
DataReader fileReader = new DataReader(inputFile);
fileReader.get_data(coordinates);
fileReader.get_class_label(class_label);
classNumbers = fileReader.get_number_classes();
// Numeric.scale_data_2_screen_res(coordinates, ret, x_res, y_res);
// data = eliminatePoints(ret, class_label);
Vector<Integer> t = new Vector<Integer>();
Vector<Float> tmp;
for (int i = 0; i < coordinates.size(); i++) {
tmp = coordinates.get(i);
t.add(tmp.get(0).intValue());
t.add(tmp.get(1).intValue());
t.add(class_label.get(i));
point.add(t);
}
Collections.sort(point, comp);
}
// Vector<Integer> getNumberClassElements() {
//
// }
private void readAndSortInputData(String inputFile) {
Comparator comp = new XYComparator();
// read the input data
Vector<Vector<Float>> coordinates = new Vector<Vector<Float>>();
Vector<Integer> class_label = new Vector<Integer>();
Vector<Vector<Integer>> ret = new Vector<Vector<Integer>>();
DataReader fileReader = new DataReader(inputFile);
// read 7sec
//fileReader.get_data(coordinates);
fileReader.get_data_int(point);
fileReader.get_class_label(class_label);
classNumbers = fileReader.get_number_classes();
printResolution();
if (x_res == 0 || y_res == 0){
x_res = (int) (fileReader.get_max_x() - fileReader.get_min_x());
y_res = (int) (fileReader.get_max_y() - fileReader.get_min_y());
}
printResolution();
// 6sec
//ImageResizer.scale_data_2_screen_res(coordinates, ret, x_res, y_res);
printCoordinates();
// ImageResizer.scale_data(coordinates, ret, x_res, y_res, double
// resolution);
//point = eliminatePoints(ret, class_label);
// 0,3sec
Collections.sort(point, comp);
// compute the number of elemetns of each class
Iterator it = point.iterator();
Vector<Integer> p;
int l;
classSize.clear();
for (int i = 0; i < classNumbers; i++) {
classSize.add(0);
}
while (it.hasNext()) {
p = (Vector<Integer>) it.next();
l = p.get(2);
classSize.set(l, classSize.get(l) + 1);
}
// System.out.println("Number of input points: " + coordinates.size());
// System.out.println("Number of transformed input points on the screen: "
// + ret.size());
System.out
.println("Number of points on the screen after duplicate elimantion: "
+ point.size());
System.out.println("Number of classes: " + classNumbers);
System.out.println("Number of points of classes: "
+ classSize.toString());
// convert vector to array
// Vector[] inputArray = new Vector[data.size()];
// data.copyInto(inputArray);
//
// // sort
// Arrays.sort(inputArray, comp);
// for (int i = 0; i < data.size(); i++) {
// data.set(i, inputArray[i]);
// }
/*
* adding the class_labels to the vector of the coordinates
*
* Vector <Float> row = new Vector<Float>(); double classLabel;
* Vector<Integer> class_labels = new Vector<Integer>();
* fileReader.get_class_label(class_labels);
*
* for(int j=0; j< current_data.size(); j++) { row = (Vector<Float>)
* current_data.get(j); classLabel = class_labels.get(j);
* row.add(classLabel); current_data.set(j, row); }
*/
}
public Vector<Integer> getNumberElementsOfEachClass() {
return classSize;
}
public void readAndSortInputDataTest(String inputFile) {
Comparator comp = new YXComparator();
// read the input data
Vector<Vector<Float>> coordinates = new Vector<Vector<Float>>();
Vector<Integer> class_label = new Vector<Integer>();
Vector<Vector<Integer>> ret = new Vector<Vector<Integer>>();
DataReader fileReader = new DataReader(inputFile);
// read 7sec
fileReader.get_data(coordinates);
fileReader.get_class_label(class_label);
classNumbers = fileReader.get_number_classes();
// 6sec
ImageResizer.scale_data_2_screen_res(coordinates, ret, x_res, y_res);
// 1sec
point = eliminatePoints(ret, class_label);
// for (int i = 0; i < data.size(); i++) {
// Vector<Integer> tmp = data.get(i);
// tmp.add(class_label.get(i));
// data.set(i, tmp);
// }
// 0,3sec
Collections.sort(point, comp);
// convert vector to array
// Vector[] inputArray = new Vector[data.size()];
// data.copyInto(inputArray);
//
// // sort
// Arrays.sort(inputArray, comp);
// for (int i = 0; i < data.size(); i++) {
// data.set(i, inputArray[i]);
// }
/*
* adding the class_labels to the vector of the coordinates
*
* Vector <Float> row = new Vector<Float>(); double classLabel;
* Vector<Integer> class_labels = new Vector<Integer>();
* fileReader.get_class_label(class_labels);
*
* for(int j=0; j< current_data.size(); j++) { row = (Vector<Float>)
* current_data.get(j); classLabel = class_labels.get(j);
* row.add(classLabel); current_data.set(j, row); }
*/
int i = 1;
}
public double getMaxSaliency() {
return max_saliency;
}
public double getMinSaliency() {
return min_saliency;
}
public double getMaxVisibility() {
return max_visibility;
}
public double getMinVisibility() {
return min_visibility;
}
public Vector<Float> getVisibility() {
return visibility;
}
public Vector<Float> getSaliency() {
return saliency;
}
public int getNumberOfClasses() {
return classNumbers;
}
public boolean computeSaliencyPrintTime(int radius,
Vector<ColorModel> rgbColors) {
System.out.println("start computing saliency");
long currentTimeInSeconds = System.currentTimeMillis();
boolean ret = computeSaliency(radius, rgbColors);
currentTimeInSeconds = System.currentTimeMillis()
- currentTimeInSeconds;
System.out.println("saliency computed in: " + currentTimeInSeconds
+ " milliseconds");
return ret;
}
public boolean computeSaliencySungKill(int radius,
Vector<ColorModel> rgbColors) {
// MemoryUtil.printMemoryToFile("1");
initMinSaliency();
initMaxSaliency();
saliency.clear();
number_surrounding_elements.clear();
int[] sliceBoundaries = getSliceBoundaries(radius);
Vector<ColorModel> labColors = new Vector<ColorModel>();
VisUtil.rgbToLabColors(rgbColors, labColors);
ColorModel currentPointColor;
// int my_count1 = 0;
// tmp variables
// Iterator it_map_matrix1 = coordinates.iterator();
// Iterator it_map_matrix2;
// Iterator it_tmp = it_map_matrix
Vector<Integer> tmp;
int x, y, l;
// // the number of elements in the surrounding belonging to the pixel
// // int[] sum = new int[classNumbers + 1];
// Vector<Integer> number_of_elements = new Vector<Integer>(classNumbers
// +1);
// for (int i = 0; i < classNumbers +1; i++)
// number_of_elements.add(0);
int upperBound_y, right_x;
int lowerBound_y, left_x; // [] = new int[sliceBoundaries.length];
float z;
// Vector<ColorModel> nbh = new Vector<ColorModel>();
// Vector<Integer> nbh_number = new Vector<Integer>();
// System.out.print(point.size());
// MemoryUtil.printMemoryToFile("2");
for (int i = 0; i < point.size(); i++) {
tmp = point.get(i);
x = tmp.get(0);
y = tmp.get(1);
l = tmp.get(2);
// the number of elements in the surrounding belonging to the pixel
// int[] sum = new int[classNumbers + 1];
// MemoryUtil.printMemoryToFile("3");
// Vector<Integer> number_of_elements = new
// Vector<Integer>(classNumbers +1);
// MemoryUtil.printMemoryToFile("3++");
Vector<Integer> number_of_elements = new Vector<Integer>(
classNumbers + 1);
for (int t = 0; t < classNumbers + 1; t++)
number_of_elements.add(0);
for (int j = 0; j < sliceBoundaries.length; j++) {
right_x = x + j;
left_x = x - j;
// if (left_x < 0) {
// left_x = 0;
// }
// else if (right_x > x_res) {
// right_x = x_res;
// }
upperBound_y = y + sliceBoundaries[j];
lowerBound_y = y - sliceBoundaries[j] - 1;
// check index boundaries
if (upperBound_y > y_res)
upperBound_y = y_res;
else if (lowerBound_y < 0)
lowerBound_y = 0;
for (int k = 0; k <= classNumbers; k++) {
try {
number_of_elements
.set(
k,
integralClassLabels[upperBound_y][right_x][k]
- integralClassLabels[lowerBound_y][right_x][k]
+ number_of_elements.get(k));
/*
* sum[k] +=
* integralClassLabels[upperBound_y][right_x][k] -
* integralClassLabels[lowerBound_y][right_x][k];
*/
} catch (Exception e) {
}
try {
number_of_elements
.set(
k,
integralClassLabels[upperBound_y][left_x][k]
- integralClassLabels[lowerBound_y][left_x][k]
+ number_of_elements.get(k));
/*
* sum[k] +=
* integralClassLabels[upperBound_y][left_x][k] -
* integralClassLabels[lowerBound_y][left_x][k];
*/
} catch (Exception e) {
}
}
}
// change to the algorithm mike suggested.
// here we are not important what colors in the surrounding are
// represented, but also how many points from this color are
// presented
// it means we are interested in the weight of the colors in the
// surrounding.
// for (int k = 0; k < classNumbers; k++) {
// if (sum[k] > 0) {
// nbh.add((ColorModel) labColors.elementAt(k));
// sum[k] = 0;
// }
// }
// nbh.add(labWhite);
currentPointColor = (ColorModel) labColors.elementAt(l);
// compute z score
// if (computing_type == 0)
// z = Numeric.compute_z_score(tmp, nbh);
// // compute euclidian distance
// else
// if (computing_type == 1) {
// System.out.println("current color: " + tmp);
// System.out.println("neigbours' color: " + nbh);
z = (float) VisUtil.eucl_distance_center_surrounding(
currentPointColor, labColors, number_of_elements,
classNumbers);
// } else {
// System.out.println("false computing type");
// return false;
// }7
if (z > max_saliency)
max_saliency = z;
if (z < min_saliency)
min_saliency = z;
saliency.add(z);
// ?
number_surrounding_elements.add(number_of_elements);
// for (int k = 0; k <= classNumbers; k++) {
// // sum[k] = 0;
// number_of_elements.set(k, 0);
// }
// nbh.clear();
}
// MemoryUtil.closeFile();
return true;
}
public boolean computeSaliencySungKill(Vector<ColorModel> labColors) {
// MemoryUtil.printMemory("start");
initMinSaliency();
initMaxSaliency();
saliency.clear();
ColorModel currentPointColor;
int l;
float z;
Vector<Integer> number_of_elements;
for (int i = 0; i < point.size(); i++) {
l = point.get(i).get(2);
number_of_elements = number_surrounding_elements.get(i);
currentPointColor = (ColorModel) labColors.elementAt(l);
z = (float) VisUtil.eucl_distance_center_surrounding(
currentPointColor, labColors, number_of_elements,
classNumbers);
if (z > max_saliency)
max_saliency = z;
if (z < min_saliency)
min_saliency = z;
saliency.add(z);
}
return true;
}
// public boolean computeSaliencySungKill(
// Vector<ColorModel> labColors) {
//
// initMinSaliency();
// initMaxSaliency();
// saliency.clear();
// int[] sliceBoundaries = getSliceBoundaries(radius);
//
// Vector<ColorModel> labColors = new Vector<ColorModel>();
// VisUtil.rgbToLabColors(rgbColors, labColors);
// ColorModel currentPointColor;
//
// // int my_count1 = 0;
// // tmp variables
// // Iterator it_map_matrix1 = coordinates.iterator();
// // Iterator it_map_matrix2;
// // Iterator it_tmp = it_map_matrix
//
// Vector<Integer> tmp;
// int x, y, l;
// // // the number of elements in the surrounding belonging to the pixel
// // // int[] sum = new int[classNumbers + 1];
// // Vector<Integer> number_of_elements = new Vector<Integer>(classNumbers
// +1);
// // for (int i = 0; i < classNumbers +1; i++)
// // number_of_elements.add(0);
//
// int upperBound_y, right_x;
// int lowerBound_y, left_x; // [] = new int[sliceBoundaries.length];
//
// double z;
// // Vector<ColorModel> nbh = new Vector<ColorModel>();
// // Vector<Integer> nbh_number = new Vector<Integer>();
//
// System.out.print(point.size());
// for (int i = 0; i < point.size(); i++) {
// tmp = point.get(i);
// x = tmp.get(0);
// y = tmp.get(1);
// l = tmp.get(2);
//
// // the number of elements in the surrounding belonging to the pixel
// // int[] sum = new int[classNumbers + 1];
// Vector<Integer> number_of_elements = new Vector<Integer>(classNumbers
// +1);
// for (int t = 0; t < classNumbers +1; t++)
// number_of_elements.add(0);
//
// for (int j = 0; j < sliceBoundaries.length; j++) {
// right_x = x + j;
// left_x = x - j;
//
// // if (left_x < 0) {
// // left_x = 0;
// // }
// // else if (right_x > x_res) {
// // right_x = x_res;
// // }
//
// upperBound_y = y + sliceBoundaries[j];
// lowerBound_y = y - sliceBoundaries[j] - 1;
//
// // check index boundaries
// if (upperBound_y > y_res)
// upperBound_y = y_res;
// else if (lowerBound_y < 0)
// lowerBound_y = 0;
//
// for (int k = 0; k <= classNumbers; k++) {
// try {
// number_of_elements
// .set(
// k,
// integralClassLabels[upperBound_y][right_x][k]
// - integralClassLabels[lowerBound_y][right_x][k]
// + number_of_elements.get(k));
// /*
// * sum[k] +=
// * integralClassLabels[upperBound_y][right_x][k] -
// * integralClassLabels[lowerBound_y][right_x][k];
// */
// } catch (Exception e) {
//
// }
// try {
// number_of_elements
// .set(
// k,
// integralClassLabels[upperBound_y][left_x][k]
// - integralClassLabels[lowerBound_y][left_x][k]
// + number_of_elements.get(k));
// /*
// * sum[k] +=
// * integralClassLabels[upperBound_y][left_x][k] -
// * integralClassLabels[lowerBound_y][left_x][k];
// */
// } catch (Exception e) {
//
// }
// }
// }
//
// // change to the algorithm mike suggested.
// // here we are not important what colors in the surrounding are
// // represented, but also how many points from this color are
// // presented
// // it means we are interested in the weight of the colors in the
// // surrounding.
// // for (int k = 0; k < classNumbers; k++) {
// // if (sum[k] > 0) {
// // nbh.add((ColorModel) labColors.elementAt(k));
// // sum[k] = 0;
// // }
// // }
// // nbh.add(labWhite);
//
// currentPointColor = (ColorModel) labColors.elementAt(l);
//
// // compute z score
// // if (computing_type == 0)
// // z = Numeric.compute_z_score(tmp, nbh);
// // // compute euclidian distance
// // else
// // if (computing_type == 1) {
// // System.out.println("current color: " + tmp);
// // System.out.println("neigbours' color: " + nbh);
// z = VisUtil.eucl_distance_center_surrounding(currentPointColor,
// labColors, number_of_elements);
//
// // } else {
// // System.out.println("false computing type");
// // return false;
// // }7
//
// if (z > max_saliency)
// max_saliency = z;
// if (z < min_saliency)
// min_saliency = z;
//
// saliency.add(z);
// // ?
// number_elements.add(number_of_elements);
// // for (int k = 0; k <= classNumbers; k++) {
// // // sum[k] = 0;
// // number_of_elements.set(k, 0);
// // }
// // nbh.clear();
// }
//
// return true;
// }
public boolean computeSaliency(int radius, Vector<ColorModel> rgbColors) {
return computeSaliencySungKill(radius, rgbColors);
// return computeSaliencyTest(radius, rgbColors);
// initMinSaliency();
// initMaxSaliency();
// saliency.clear();
// int[] sliceBoundaries = getSliceBoundaries(radius);
//
// Vector<ColorModel> labColors = new Vector<ColorModel>();
// rgbToLabColors(rgbColors, labColors);
// ColorModel currentPointColor;
//
// // int my_count1 = 0;
// // tmp variables
// // Iterator it_map_matrix1 = coordinates.iterator();
// // Iterator it_map_matrix2;
// // Iterator it_tmp = it_map_matrix
//
// Vector<Integer> tmp;
// int x, y, l;
// int[] sum = new int[classNumbers];
// int upperBound_y, right_x;
// int lowerBound_y, left_x; // [] = new int[sliceBoundaries.length];
//
// double z;
// Vector<ColorModel> nbh = new Vector<ColorModel>();
// System.out.print(data.size());
// for (int i = 0; i < data.size(); i++) {
// tmp = data.get(i);
// x = tmp.get(0);
// y = tmp.get(1);
// l = tmp.get(2);
//
// for (int j = 0; j < sliceBoundaries.length; j++) {
// right_x = x + j;
// left_x = x - j;
//
// // if (left_x < 0) {
// // left_x = 0;
// // }
// // else if (right_x > x_res) {
// // right_x = x_res;
// // }
//
// upperBound_y = y + sliceBoundaries[j];
// lowerBound_y = y - sliceBoundaries[j] - 1;
//
// // check index boundaries
// if (upperBound_y > y_res)
// upperBound_y = y_res;
// else if (lowerBound_y < 0)
// lowerBound_y = 0;
//
// for (int k = 0; k < classNumbers; k++) {
// try {
// sum[k] += integralClassLabels[upperBound_y][right_x][k]
// - integralClassLabels[lowerBound_y][right_x][k];
// } catch (Exception e) {
//
// }
// try {
// sum[k] += integralClassLabels[upperBound_y][left_x][k]
// - integralClassLabels[lowerBound_y][left_x][k];
// } catch (Exception e) {
//
// }
// }
// }
//
// for (int k = 0; k < classNumbers; k++) {
// if (sum[k] > 0) {
// nbh.add((ColorModel) labColors.elementAt(k));
// sum[k] = 0;
// }
// }
// nbh.add(labWhite);
//
// currentPointColor = (ColorModel) labColors.elementAt(l);
//
// // compute z score
// // if (computing_type == 0)
// // z = Numeric.compute_z_score(tmp, nbh);
// // // compute euclidian distance
// // else
// // if (computing_type == 1) {
// // System.out.println("current color: " + tmp);
// // System.out.println("neigbours' color: " + nbh);
// z = Numeric.eucl_Distance(currentPointColor, nbh);
//
// // } else {
// // System.out.println("false computing type");
// // return false;
// // }
//
// if (z > max_saliency)
// max_saliency = z;
// if (z < min_saliency)
// min_saliency = z;
//
// saliency.add(z);
// nbh.clear();
// }
//
// return true;
}
public boolean computeSaliencyTest(int radius, Vector<ColorModel> rgbColors) {
BufferedWriter out;
FileWriter fw;
initMinSaliency();
initMaxSaliency();
saliency.clear();
int[] sliceBoundaries = getSliceBoundaries(radius);
Vector<ColorModel> labColors = new Vector<ColorModel>();
VisUtil.rgbToLabColors(rgbColors, labColors);
ColorModel currentPointColor;
// int my_count1 = 0;
// tmp variables
// Iterator it_map_matrix1 = coordinates.iterator();
// Iterator it_map_matrix2;
// Iterator it_tmp = it_map_matrix
Vector<Integer> tmp;
int x, y, l;
int[] sum = new int[classNumbers];
int upperBound_y, right_x;
int lowerBound_y, left_x; // [] = new int[sliceBoundaries.length];
float z;
Vector<ColorModel> nbh = new Vector<ColorModel>();
System.out.print(point.size());
try {
File file = new File("saliency_test.dat");
fw = new FileWriter(file);
out = new BufferedWriter(fw);
for (int i = 0; i < point.size(); i++) {
tmp = point.get(i);
x = tmp.get(0);
y = tmp.get(1);
l = tmp.get(2);
for (int j = 0; j < sliceBoundaries.length; j++) {
right_x = x + j;
left_x = x - j;
// if (left_x < 0) {
// left_x = 0;
// }
// else if (right_x > x_res) {
// right_x = x_res;
// }
upperBound_y = y + sliceBoundaries[j];
lowerBound_y = y - sliceBoundaries[j] - 1;
// check index boundaries
if (upperBound_y > y_res)
upperBound_y = y_res;
else if (lowerBound_y < 0)
lowerBound_y = 0;
for (int k = 0; k < classNumbers; k++) {
try {
sum[k] += integralClassLabels[upperBound_y][right_x][k]
- integralClassLabels[lowerBound_y][right_x][k];
} catch (Exception e) {
}
try {
sum[k] += integralClassLabels[upperBound_y][left_x][k]
- integralClassLabels[lowerBound_y][left_x][k];
} catch (Exception e) {
}
}
}
for (int k = 0; k < classNumbers; k++) {
if (sum[k] > 0) {
nbh.add((ColorModel) labColors.elementAt(k));
sum[k] = 0;
}
}
nbh.add(labWhite);
currentPointColor = (ColorModel) labColors.elementAt(l);
// compute z score
// if (computing_type == 0)
// z = Numeric.compute_z_score(tmp, nbh);
// // compute euclidian distance
// else
// if (computing_type == 1) {
// System.out.println("current color: " + tmp);
// System.out.println("neigbours' color: " + nbh);
z = (float) Numeric.eucl_Distance(currentPointColor, nbh);
// } else {
// System.out.println("false computing type");
// return false;
// }
if (z > max_saliency)
max_saliency = z;
if (z < min_saliency)
min_saliency = z;
out.write(Integer.toString(x));
out.write("|");
out.write(Integer.toString(y));
out.write("|");
out.write(Integer.toString(l));
out.write("|");
out.write(Float.toString(z));
out.write("|");
out.write(Integer.toString(nbh.size()));
out.write("|");
for (int tmpi = 0; tmpi < nbh.size(); tmpi++) {
out.write(Double.toString(nbh.get(tmpi).getDimension_1()));
out.write(",");
out.write(Double.toString(nbh.get(tmpi).getDimension_2()));
out.write(",");
out.write(Double.toString(nbh.get(tmpi).getDimension_3()));
out.write("|");
}
out.write(System.getProperty("line.separator"));
saliency.add(z);
nbh.clear();
}
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
return true;
}
public boolean computeVisiblityPrintTime(int radius) {
System.out.println("start computing visibility");
long currentTimeInSeconds = System.currentTimeMillis();
boolean ret = computeVisibility(radius);
currentTimeInSeconds = System.currentTimeMillis()
- currentTimeInSeconds;
System.out.println("Visibility computed in: " + currentTimeInSeconds
+ " milliseconds");
return ret;
}
public boolean computeVisibility(int radius) {
precomputeIntegralSaliency();
initMinVisibility();
initMaxVisibility();
visibility.clear();
int[] sliceBoundaries = getSliceBoundaries(radius);
// Vector<ColorModel> labColors = new Vector<ColorModel>();
// rgbToLabColors(rgbColors, labColors);
// ColorModel currentPointColor;
// int my_count1 = 0;
// tmp variables
// Iterator it_map_matrix1 = coordinates.iterator();
// Iterator it_map_matrix2;
// Iterator it_tmp = it_map_matrix
Vector<Integer> tmp;
int x, y, l;
// float[] sum = new float[classNumbers];
int upperBound_y, right_x;
int lowerBound_y, left_x; // [] = new int[sliceBoundaries.length];
float z = 0;
// Vector<ColorModel> nbh = new Vector<ColorModel>();
// System.out.print(point.size());
for (int i = 0; i < point.size(); i++) {
tmp = point.get(i);
x = tmp.get(0);
y = tmp.get(1);
l = tmp.get(2);
for (int j = 0; j < sliceBoundaries.length; j++) {
right_x = x + j;
left_x = x - j;
upperBound_y = y + sliceBoundaries[j];
lowerBound_y = y - sliceBoundaries[j] - 1;
// check index boundaries
if (upperBound_y > y_res)
upperBound_y = y_res;
else if (lowerBound_y < 0)
lowerBound_y = 0;
// compute
try {
z += integralSaliency[upperBound_y][right_x][l]
- integralSaliency[lowerBound_y][right_x][l];
} catch (Exception e) {
// right_x > res_x or right_x < 0
}
try {
z += integralSaliency[upperBound_y][left_x][l]
- integralSaliency[lowerBound_y][left_x][l];
} catch (Exception e) {
}
}
// depends on whether it must be computed in the sum of the nbh
// try {
// try {
// z -= (integralSaliency[y][x][l] - integralSaliency[y - 1][x][l]);
// } catch (Exception e) {
// z -= (integralSaliency[y][x][l] - integralSaliency[y_res][x -
// 1][l]);
// }
//
// } catch (Exception e) {
// System.out.println(y);
// System.out.println(x);
// System.out.println(l);
// System.out.println(y_res);
// System.out.println(x - 1);
// }
if (z > max_visibility)
max_visibility = z;
if (z < min_visibility)
min_visibility = z;
visibility.add(z);
z = 0;
}
computeMeanVisibility(radius);
return true;
}
public void computeMeanVisibility(int radius) {
precomputeIntegralVisibility();
meanVis.clear();
int[] sliceBoundaries = getSliceBoundaries(radius);
// Vector<ColorModel> labColors = new Vector<ColorModel>();
// rgbToLabColors(rgbColors, labColors);
// ColorModel currentPointColor;
// int my_count1 = 0;
// tmp variables
// Iterator it_map_matrix1 = coordinates.iterator();
// Iterator it_map_matrix2;
// Iterator it_tmp = it_map_matrix
Vector<Integer> tmp;
int x, y;
// float[] sum = new float[classNumbers];
int upperBound_y, right_x;
int lowerBound_y, left_x; // [] = new int[sliceBoundaries.length];
float z = 0;
int counter = 0;
// Vector<ColorModel> nbh = new Vector<ColorModel>();
// System.out.print(point.size());
for (int i = 0; i < point.size(); i++) {
tmp = point.get(i);
x = tmp.get(0);
y = tmp.get(1);
// l = tmp.get(2);
for (int j = 0; j < sliceBoundaries.length; j++) {
right_x = x + j;
left_x = x - j;
upperBound_y = y + sliceBoundaries[j];
lowerBound_y = y - sliceBoundaries[j] - 1;
// check index boundaries
if (upperBound_y > y_res)
upperBound_y = y_res;
else if (lowerBound_y < 0)
lowerBound_y = 0;
// compute
try {
z += integralVis[upperBound_y][right_x]
- integralVis[lowerBound_y][right_x];
for (int l = 0; l < classNumbers; l++) {
counter += integralClassLabels[upperBound_y][right_x][l]
- integralClassLabels[lowerBound_y][right_x][l];
}
} catch (Exception e) {
// right_x > res_x or right_x < 0
}
try {
z += integralVis[upperBound_y][left_x]
- integralVis[lowerBound_y][left_x];
for (int l = 0; l < classNumbers; l++) {
counter += integralClassLabels[upperBound_y][right_x][l]
- integralClassLabels[lowerBound_y][right_x][l];
}
} catch (Exception e) {
}
}
// System.out.println(tmp);
// System.out.println("vis: " + this.visibility.get(i));
// System.out.println("z: " + z);
// System.out.println("counter: " + counter);
// System.out.println("meanVis" + (float)z/counter);
// System.out.println();
meanVis.add(z / counter);
z = 0;
counter = 0;
}
}
// public boolean computeVisibility(int radius) {
//
// precomputeIntegralSaliency();
//
// initMinVisibility();
// initMaxVisibility();
// visibility.clear();
// int[] sliceBoundaries = getSliceBoundaries(radius);
//
// // Vector<ColorModel> labColors = new Vector<ColorModel>();
// // rgbToLabColors(rgbColors, labColors);
// // ColorModel currentPointColor;
//
// // int my_count1 = 0;
// // tmp variables
// // Iterator it_map_matrix1 = coordinates.iterator();
// // Iterator it_map_matrix2;
// // Iterator it_tmp = it_map_matrix
//
// Vector<Integer> tmp;
// int x, y, l;
// // float[] sum = new float[classNumbers];
// int upperBound_y, right_x;
// int lowerBound_y, left_x; // [] = new int[sliceBoundaries.length];
//
// double z = 0;
// // Vector<ColorModel> nbh = new Vector<ColorModel>();
// System.out.print(point.size());
// for (int i = 0; i < point.size(); i++) {
// tmp = point.get(i);
// x = tmp.get(0);
// y = tmp.get(1);
// l = tmp.get(2);
//
// for (int j = 0; j < sliceBoundaries.length; j++) {
// right_x = x + j;
// left_x = x - j;
//
// upperBound_y = y + sliceBoundaries[j];
// lowerBound_y = y - sliceBoundaries[j] - 1;
//
// // check index boundaries
// if (upperBound_y > y_res)
// upperBound_y = y_res;
// else if (lowerBound_y < 0)
// lowerBound_y = 0;
//
// // compute
// try {
// z += integralSaliency[upperBound_y][right_x][l]
// - integralSaliency[lowerBound_y][right_x][l];
// } catch (Exception e) {
// // right_x > res_x or right_x < 0
// }
// try {
// z += integralSaliency[upperBound_y][left_x][l]
// - integralSaliency[lowerBound_y][left_x][l];
// } catch (Exception e) {
//
// }
//
// }
//
// // depends on whether it must be computed in the sum of the nbh
// try {
// z -= (integralSaliency[y][x][l] - integralSaliency[y - 1][x][l]);
// } catch (Exception e) {
// z -= (integralSaliency[y][x][l] - integralSaliency[y_res][x - 1][l]);
// }
//
// if (z > max_visibility)
// max_visibility = z;
// if (z < min_visibility)
// min_visibility = z;
//
// visibility.add(z);
// z = 0;
// }
//
// return true;
// }
public void precomputeIntegralSaliencyPrintTime() {
System.out.println("start precomputeIntegralSaliencyPrintTime");
long currentTimeInSeconds = System.currentTimeMillis();
precomputeIntegralSaliency();
currentTimeInSeconds = System.currentTimeMillis()
- currentTimeInSeconds;
System.out.println("Running Time: " + currentTimeInSeconds
+ " milliseconds");
}
public void precomputeIntegralSaliency() {
int currentClassLabelValue = 0;
float[] sum = new float[classNumbers];
int i = 0;
Vector<Integer> tmp = point.get(i);
for (int x = 0; x <= x_res; x++) {
for (int y = 0; y <= y_res; y++) {
if (tmp.get(1) == y && tmp.get(0) == x) {
currentClassLabelValue = (int) tmp.get(2);
sum[currentClassLabelValue] += saliency.get(i).floatValue();
i++;
try {
tmp = point.get(i);
} catch (Exception e) {
}
}
for (int k = 0; k < classNumbers; k++) {
integralSaliency[y][x][k] = sum[k];
}
}
}
}
public void precomputeIntegralVisibility() {
float sum = 0;
int i = 0;
Vector<Integer> tmp = point.get(i);
int x = 0, y = 0;
for (x = 0; x <= x_res; x++) {
for (y = 0; y <= y_res; y++) {
if (y == tmp.get(1) && x == tmp.get(0)) {
sum += this.visibility.get(i);
i++;
try {
tmp = point.get(i);
} catch (Exception e) {
}
}
integralVis[y][x] = sum;
}
}
}
// not updated - for update have a look at
// precomputeIntegralClassLabelNumbers0
public void precomputeIntegralSaliency0() {
// not changed
// if (integralSal == null)
// integralSal = new float[y_res +1 ][x_res +1][classNumbers];
Vector<Integer> tmp;
int currentClassLabelValue;
float[] last = new float[classNumbers];
// like do while
tmp = point.get(0);
currentClassLabelValue = (int) tmp.get(2);
last[currentClassLabelValue] = saliency.get(0).floatValue();
integralSaliency[tmp.get(1)][tmp.get(0)][currentClassLabelValue] = last[currentClassLabelValue];
int i = 1;
try {
for (i = 1; i < point.size(); i++) {
tmp = point.get(i);
currentClassLabelValue = (int) tmp.get(2);
last[currentClassLabelValue] += saliency.get(0).floatValue();
integralSaliency[tmp.get(1)][tmp.get(0)][currentClassLabelValue] = last[currentClassLabelValue];
}
} catch (Exception e) {
// System.out.println(e);
e.printStackTrace();
System.out.println(tmp.get(1));
System.out.println(tmp.get(0));
System.out.println(currentClassLabelValue);
System.out.println(last[currentClassLabelValue]);
System.out.println(i);
}
for (i = 0; i <= y_res; i++) {
for (int j = 0; j <= x_res; j++) {
for (int k = 0; k < classNumbers; k++) {
if (integralSaliency[i][j][k] == 0) {
if (i > 0)
integralSaliency[i][j][k] = integralSaliency[i - 1][j][k];
else if (j > 0)
integralSaliency[i][j][k] = integralSaliency[i][j - 1][k];
}
}
}
}
}
private void precomputeIntegralClassLabelNumbersPrintTime() {
System.out.println("start precomputeIntegralClassLabelNumbers1");
long currentTimeInSeconds = System.currentTimeMillis();
precomputeIntegralClassLabelNumbers();
currentTimeInSeconds = System.currentTimeMillis()
- currentTimeInSeconds;
System.out.println("time: " + currentTimeInSeconds + " milliseconds");
}
private void precomputeIntegralClassLabelNumbers0PrintTime() {
System.out.println("start precomputeIntegralClassLabelNumbers1");
long currentTimeInSeconds = System.currentTimeMillis();
precomputeIntegralClassLabelNumbers0();
currentTimeInSeconds = System.currentTimeMillis()
- currentTimeInSeconds;
System.out.println("time: " + currentTimeInSeconds + " milliseconds");
}
private void precomputeIntegralClassLabelNumbers() {
int currentClassLabelValue;
int[] sum = new int[classNumbers + 1];
int i = 0;
Vector<Integer> tmp = point.get(i);
int x = 0, y = 0, k;
for (x = 0; x <= x_res; x++) {
for (y = 0; y <= y_res; y++) {
if (y == tmp.get(1) && x == tmp.get(0)) {
currentClassLabelValue = (int) tmp.get(2);
sum[currentClassLabelValue]++;
i++;
try {
tmp = point.get(i);
} catch (Exception e) {
}
} else {
sum[classNumbers]++;
}
for (k = 0; k <= classNumbers; k++) {
integralClassLabels[y][x][k] = sum[k];
}
}
}
}
private void precomputeIntegralClassLabelNumbersTest() {
System.out.println("start precomputeIntegralClassLabelNumbers1");
long currentTimeInSeconds = System.currentTimeMillis();
Vector<Integer> tmp;
int currentClassLabelValue = 0;
int[] sum = new int[classNumbers];
// like do while
// tmp = data.get(0);
// currentClassLabelValue = (int) tmp.get(2);
// sum[currentClassLabelValue]++;
// integralClassLabels[tmp.get(1)][tmp.get(0)][currentClassLabelValue] =
// 1;
int i = 0;
tmp = point.get(i);
int x = 0, y = 0, k;
// try {
for (x = 0; x <= x_res; x++) {
for (y = 0; y <= y_res; y++) {
if (y == tmp.get(1) && x == tmp.get(0)) {
currentClassLabelValue = (int) tmp.get(2);
sum[currentClassLabelValue]++;
i++;
try {// will throw an exception if the end of data comes
tmp = point.get(i);
} catch (Exception e) {
}
}
for (k = 0; k < classNumbers; k++) {
integralClassLabels[y][x][k] = sum[k];
}
}
}
// } catch (Exception e) {
// System.out.println(tmp.get(1));
// System.out.println(tmp.get(0));
// System.out.println(currentClassLabelValue);
// System.out.println(sum[currentClassLabelValue]);
// System.out.println(i);
// }
currentTimeInSeconds = System.currentTimeMillis()
- currentTimeInSeconds;
System.out.println("time: " + currentTimeInSeconds + " milliseconds");
}
public void precomputeIntegralClassLabelNumbers_Export(int xprint) {
BufferedWriter out;
FileWriter fw;
System.out.println("start precomputeIntegralClassLabelNumbers1Export");
long currentTimeInSeconds = System.currentTimeMillis();
//
// Vector<Integer> tmp;
// int currentClassLabelValue;
// int[] sum = new int[classNumbers];
//
// // like do while
// tmp = data.get(0);
// currentClassLabelValue = (int) tmp.get(2);
// sum[currentClassLabelValue]++;
// integralClassLabels[tmp.get(1)][tmp.get(0)][currentClassLabelValue] =
// 1;
//
// int i = 1;
// tmp = data.get(i);
// //
// try {
// for (int y = 1; y <= y_res; y++) {
// for (int x = 0; x <= x_res; x++) {
// if (y == tmp.get(1) && x == tmp.get(0)) {
//
// currentClassLabelValue = (int) tmp.get(2);
// sum[currentClassLabelValue]++;
// i++;
// try {
// tmp = data.get(i);
// } catch (Exception e) {
// }
// }
// for (int k = 0; k < classNumbers; k++) {
// integralClassLabels[y][x][k] = sum[k];
// }
// }
// }
// } catch (Exception e) {
// System.out.println(tmp.get(1));
// System.out.println(tmp.get(0));
// System.out.println(currentClassLabelValue);
// System.out.println(sum[currentClassLabelValue]);
// System.out.println(i);
// }
int i;
try {
File file = new File(
"precomputeIntegralClassLabelNumbers1Export.dat");
fw = new FileWriter(file);
out = new BufferedWriter(fw);
for (int j = xprint; j < xprint + 1; j++) {
for (i = 0; i < y_res; i++) {
out.write(Integer.toString(xprint));
out.write('|');
out.write(Integer.toString(i));
out.write('|');
for (int k = 0; k <= classNumbers; k++) {
out.write(Integer
.toString(integralClassLabels[i][j][k]));
out.write('|');
}
out.write(System.getProperty("line.separator"));
}
}
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
currentTimeInSeconds = System.currentTimeMillis()
- currentTimeInSeconds;
System.out.println("time: " + currentTimeInSeconds + " milliseconds");
}
private void precomputeIntegralClassLabelNumbers0() {
Vector<Integer> tmp;
int currentClassLabelValue;
int[] last = new int[classNumbers];
// like do while
tmp = point.get(0);
currentClassLabelValue = (int) tmp.get(2);
last[currentClassLabelValue]++;
integralClassLabels[tmp.get(1)][tmp.get(0)][currentClassLabelValue] = 1;
int i = 1;
for (i = 1; i < point.size(); i++) {
tmp = point.get(i);
currentClassLabelValue = (int) tmp.get(2);
last[currentClassLabelValue]++;
integralClassLabels[tmp.get(1)][tmp.get(0)][currentClassLabelValue] = last[currentClassLabelValue];
}
for (int j = 0; j <= x_res; j++) {
for (i = 0; i <= y_res; i++) {
for (int k = 0; k < classNumbers; k++) {
if (integralClassLabels[i][j][k] == 0) {
if (i > 0) {
integralClassLabels[i][j][k] = integralClassLabels[i - 1][j][k];
} else if (j > 0) {
integralClassLabels[i][j][k] = integralClassLabels[y_res][j - 1][k];
}
}
}
}
}
}
private void precomputeIntegralClassLabelNumbers0Test() {
System.out.println("start precomputeIntegralClassLabelNumbers");
long currentTimeInSeconds = System.currentTimeMillis();
Vector<Integer> tmp;
int currentClassLabelValue;
int[] last = new int[classNumbers];
// like do while
tmp = point.get(0);
currentClassLabelValue = (int) tmp.get(2);
last[currentClassLabelValue]++;
integralClassLabels[tmp.get(1)][tmp.get(0)][currentClassLabelValue] = 1;
int i = 1;
try {
for (i = 1; i < point.size(); i++) {
tmp = point.get(i);
currentClassLabelValue = (int) tmp.get(2);
last[currentClassLabelValue]++;
// if (tmp.get(0) == 800) {
// System.out.print(currentClassLabelValue);
// System.out.print(" ");
// System.out.println(last[currentClassLabelValue]);
// }
integralClassLabels[tmp.get(1)][tmp.get(0)][currentClassLabelValue] = last[currentClassLabelValue];
}
} catch (Exception e) {
System.out.println(tmp.get(1));
System.out.println(tmp.get(0));
System.out.println(currentClassLabelValue);
System.out.println(last[currentClassLabelValue]);
System.out.println(i);
}
for (int j = 0; j <= x_res; j++) {
for (i = 0; i <= y_res; i++) {
for (int k = 0; k < classNumbers; k++) {
if (integralClassLabels[i][j][k] == 0) {
if (i > 0) {
integralClassLabels[i][j][k] = integralClassLabels[i - 1][j][k];
} else if (j > 0) {
integralClassLabels[i][j][k] = integralClassLabels[y_res][j - 1][k];
}
// System.out.println(integralClassLabels[i][j][k]);
}
}
}
}
currentTimeInSeconds = System.currentTimeMillis()
- currentTimeInSeconds;
System.out.println("time: " + currentTimeInSeconds + " milliseconds");
}
private static Vector<Vector<Integer>> eliminatePoints(
Vector<Vector<Integer>> inputData, Vector<Integer> colors) {
HashMap hm = new HashMap(15000, 0.75f);
for (int i = 0; i < inputData.size(); i++) {
hm.put((Vector<Integer>) inputData.get(i), colors.get(i));
}
Vector<Vector<Integer>> ret = new Vector<Vector<Integer>>();
Set set = hm.entrySet();
Iterator i = set.iterator();
Map.Entry me;
Vector<Integer> tmp;
while (i.hasNext()) {
me = (Map.Entry) i.next();
tmp = (Vector<Integer>) me.getKey();
tmp.add((Integer) me.getValue());
ret.add(tmp);
}
return ret;
}
private static Vector<Vector<Float>> eliminatePoints_float(
Vector<Vector<Float>> inputData, Vector<Integer> colors) {
HashMap hm = new HashMap(15000, 0.75f);
for (int i = 0; i < inputData.size(); i++) {
hm.put((Vector<Float>) inputData.get(i), colors.get(i));
}
Vector<Vector<Float>> ret = new Vector<Vector<Float>>();
Set set = hm.entrySet();
Iterator i = set.iterator();
Map.Entry me;
Vector<Float> tmp;
while (i.hasNext()) {
me = (Map.Entry) i.next();
tmp = (Vector<Float>) me.getKey();
tmp.add((Float) (float) (int) (Integer) me.getValue());
ret.add(tmp);
}
return ret;
}
public void export(String filename) {
outputFile = filename;
export();
}
public void export() {
BufferedWriter out;
FileWriter fw;
int x1 = 0, y1 = 0, class_ = 0;
float sal_score = 0, vis_score = 0;
Vector<Float> key_row, key_row2, value_row;
Vector<Integer> tmp;
try {
File file = new File(outputFile);
fw = new FileWriter(file);
out = new BufferedWriter(fw);
for (int i = 0; i < point.size(); i++) {
tmp = point.get(i);
x1 = tmp.get(0);
y1 = tmp.get(1);
class_ = tmp.get(2);
try {
sal_score = saliency.get(i);
vis_score = visibility.get(i);
} catch (Exception e) {
}
out.write(Float.toString(x1));
out.write('|');
out.write(Float.toString(y1));
out.write('|');
out.write(Float.toString(class_));
out.write('|');
out.write(Float.toString(sal_score));
out.write('|');
out.write(Float.toString(vis_score));
out.write(System.getProperty("line.separator"));
}
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
*
* @param center
* - the color of the center pixel
* @param colors
* - all the colors availabe on the image except the white color
* @param number_of_elements
* - the number of pixels of any color. The last number of the
* array is the number of white pixels (the background)
* @return
*/
}