Java BufferedImage Operation height(BufferedImage image, Double measurementLatitude, Double measurementLongitude)

Here you can find the source of height(BufferedImage image, Double measurementLatitude, Double measurementLongitude)

Description

This function converts a measurementLatitude, measurementLongitude into a pixel co-ordinate and reads the associated pixel and returns the red value of the pixel - representing height - 0 is low, 255 is high

License

Open Source License

Parameter

Parameter Description
image a parameter
measurementLatitude a parameter
measurementLongitude a parameter

Return

returns the red value of the read pixel

Declaration

public static double height(BufferedImage image,
        Double measurementLatitude, Double measurementLongitude) 

Method Source Code

//package com.java2s;
import java.awt.image.BufferedImage;

public class Main {
    /**//  w  w w.  ja  va2 s. c o  m
     * This function converts a measurementLatitude, measurementLongitude into a pixel co-ordinate and reads the 
     * associated pixel and returns the red value of the pixel - representing height - 0 is low, 255 is high
     * @param image
     * @param measurementLatitude
     * @param measurementLongitude
     * @return returns the red value of the read pixel 
     */
    public static double height(BufferedImage image,
            Double measurementLatitude, Double measurementLongitude) {
        int w = image.getWidth();
        int h = image.getHeight();
        int zeroLat = h / 2;
        int zeroLong = w / 2;
        Double degreeXPerPixel = (double) w / 360;
        Double degreeYPerPixel = (double) h / 180;
        int y = zeroLat
                + ((int) Math.round(measurementLatitude * degreeYPerPixel
                        * -1));
        int x = zeroLong
                + ((int) Math.round(measurementLongitude * degreeXPerPixel));
        int pixel = image.getRGB(x, y);
        return (pixel >> 16) & 255;
    }
}

Related

  1. generateImageHash(BufferedImage image)
  2. generateOutline(BufferedImage source, Color color, boolean alpha)
  3. gradientMask(BufferedImage img, float start, float stop)
  4. greyScale(BufferedImage image)
  5. grid(BufferedImage image, int between)
  6. highlight(BufferedImage img, Color source, Color dest)
  7. hitTest(BufferedImage image, int x, int y)
  8. hueShift(BufferedImage image, int hue)
  9. inColormap(float[][] in, float min, float max, float[][] colormap, BufferedImage b)