Here you can find the source of normalize(double[] descriptor)
Parameter | Description |
---|---|
descriptor | a parameter |
public static double[] normalize(double[] descriptor)
//package com.java2s; /*/* w ww . jav a 2 s .c om*/ * The GPLv3 licence : * ----------------- * Copyright (c) 2009 Ricardo Dias * * This file is part of MuVis. * * MuVis is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * MuVis is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MuVis. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Method that normalizes the descriptor passed as a parameter * Limits for this method are: * --- Min: 0 * --- Max: 200 * @param descriptor * @return */ public static double[] normalize(double[] descriptor) { int max = 200; int min = 0; int minNorm = 0; int maxNorm = 1; double[] normalizedDescriptor = new double[descriptor.length]; for (int i = 0; i < descriptor.length; i++) { double parc1 = descriptor[i] - min; double parc2 = max - min; double num = minNorm + (parc1 / parc2) * (maxNorm - minNorm); //update the new position normalizedDescriptor[i] = num; } return normalizedDescriptor; } }