Java Array Min Value minDistance(int[][] colors, int len, int[] color)

Here you can find the source of minDistance(int[][] colors, int len, int[] color)

Description

min Distance

License

Open Source License

Declaration

public static int minDistance(int[][] colors, int len, int[] color) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int minDistance(int[][] colors, int len, int[] color) {
        int smallest = 0;
        int minDist = 3 * 256;
        for (int x = 0; x < len; x++) {
            int dist = Math.abs(color[0] - colors[x][0]) + Math.abs(color[1] - colors[x][1])
                    + Math.abs(color[2] - colors[x][2]);
            if (dist < minDist) {
                minDist = dist;/*from   w w w .  j av  a  2 s .  c o m*/
                smallest = x;
            }
        }
        return smallest;
    }
}

Related

  1. minarr(double[] a)
  2. minArray(int[] arr)
  3. minCeilDiv(int c, int... vals)
  4. minDiff(int... offs)
  5. minDist(double[] q, double[] c, double[][] distMatrix, int orig_n)
  6. minDouble(double a, double... others)
  7. minDouble(double... values)
  8. minDoubleArray(double[] data)
  9. minElement(int[] array)