Here you can find the source of findLegendLH(BufferedImage bufferedImage)
public static int[] findLegendLH(BufferedImage bufferedImage)
//package com.java2s; /* /*from www .ja v a2 s .co m*/ * SgtUtil Copyright 2005, NOAA. * See the LICENSE.txt file in this file's directory. */ import java.awt.image.BufferedImage; public class Main { /** This find the low and high pixels with the legend * (assuming the legend is near the bottom and is along the left edge, * and spans the width of the image). * * @return the low (a smaller number) and high y (a bigger number) of the legend. * They are the y's of the edges. * If trouble, this returns {0, 0}. */ public static int[] findLegendLH(BufferedImage bufferedImage) { int black = 0xFF000000; int height = bufferedImage.getHeight(); int lh[] = new int[] { 0, 0 }; //find bottom edge for (int y = height - 1; y >= 0; y--) { if (bufferedImage.getRGB(0, y) == black) { lh[1] = y; break; } } //find top edge for (int y = lh[1] - 1; y >= 0; y--) { if (bufferedImage.getRGB(0, y) != black) { lh[0] = y + 1; break; } } //String2.log("findLegendLH low=" + lh[0] + " high=" + lh[1]); return lh; } }