Java Array Normalize normalize(int[][][] data, int startX, int startY, int stopX, int stopY, double scale)

Here you can find the source of normalize(int[][][] data, int startX, int startY, int stopX, int stopY, double scale)

Description

Normalizes the image data by the given scale

License

Open Source License

Parameter

Parameter Description
data the image data
startX is the x pixel of the image to start from
startY is the y pixel of the image to start from
stopX is the x pixel of the image to stop
stopY is the y pixel of the image to stop
scale The scale to normalize the image by

Declaration

public static void normalize(int[][][] data, int startX, int startY, int stopX, int stopY, double scale) 

Method Source Code

//package com.java2s;
/*//from  w w w .j  a v  a 2 s . c  o m
 * The MIT License (MIT)
 *
 * Copyright (c) 2015 Ziver Koc
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

public class Main {
    /**
     * Normalizes the image data by the given scale
     *
     * @param   data   the image data
     * @param   startX   is the x pixel of the image to start from
     * @param   startY   is the y pixel of the image to start from
     * @param   stopX   is the x pixel of the image to stop
     * @param   stopY   is the y pixel of the image to stop
     * @param   scale   The scale to normalize the image by
     */
    public static void normalize(int[][][] data, int startX, int startY, int stopX, int stopY, double scale) {
        for (int y = startY; y < stopY; y++) {
            for (int x = startX; x < stopX; x++) {
                data[y][x][1] = (int) (data[y][x][1] * scale);
                data[y][x][2] = (int) (data[y][x][2] * scale);
                data[y][x][3] = (int) (data[y][x][3] * scale);
            }
        }
    }

    /**
     * Normalizes the image data by the given scale
     *
     * @param   output   the output data array
     * @param   data   the image data
     * @param   startX   is the x pixel of the image to start from
     * @param   startY   is the y pixel of the image to start from
     * @param   stopX   is the x pixel of the image to stop
     * @param   stopY   is the y pixel of the image to stop
     * @param   scale   the scale to normalize the image by
     */
    public static void normalize(int[][][] output, int[][][] data, int startX, int startY, int stopX, int stopY,
            double scale) {
        for (int y = startY; y < stopY; y++) {
            for (int x = startX; x < stopX; x++) {
                output[y][x][1] = (int) (data[y][x][1] * scale);
                output[y][x][2] = (int) (data[y][x][2] * scale);
                output[y][x][3] = (int) (data[y][x][3] * scale);
            }
        }
    }
}

Related

  1. normalize(float[] v)
  2. normalize(float[] vec)
  3. normalize(float[][] vals, float min, float max)
  4. normalize(int[] a)
  5. normalize(int[] values)
  6. normalize(long[] v, float[] target)
  7. normalize(Number[] array)
  8. normalize(String[] slist)
  9. normalize01(float[] array)