/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package colorsegmentation;

import baseclasses.ObjImport;
import baseclasses.Point;
import java.io.IOException;
import java.util.Arrays;

/**
 *
 * @author Alex
 */
public class ColorAverager {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        ObjImport scanImport = new ObjImport("Scan3_15_1_red.obj");
        try {
            scanImport.read();
        } catch (IOException e) {
            System.out.println("wat.");
        }
        Point[] pts = scanImport.getPoints();
        double[] avg = {0.0, 0.0, 0.0};
        for (int i = 0; i < pts.length; i++) {
            double[] tRgb = pts[i].getRGBColor();
            avg[0] += tRgb[0];
            avg[1] += tRgb[1];
            avg[2] += tRgb[2];
        }
        avg[0] /= pts.length;
        avg[1] /= pts.length;
        avg[2] /= pts.length;
        
        avg[0] *= 255;
        avg[1] *= 255;
        avg[2] *= 255;
        
        System.out.println(Arrays.toString(avg));
    }
    
}
