Here you can find the source of height(BufferedImage image, Double measurementLatitude, Double measurementLongitude)
Parameter | Description |
---|---|
image | a parameter |
measurementLatitude | a parameter |
measurementLongitude | a parameter |
public static double height(BufferedImage image, Double measurementLatitude, Double measurementLongitude)
//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; } }