public static boolean isHit(int i, int j, int[][] imageGraph,
			int[][] structuringElement, int foregroundClass) {
		int rowCounter = i - structuringElement.length / 2;
		int columnCounter = j - structuringElement[0].length / 2;
		int initialColumnValue = columnCounter;
		for (int k = 0; k < structuringElement.length; k++) {
			columnCounter = initialColumnValue;
			for (int l = 0; l < structuringElement[0].length; l++) {

				if (rowCounter >= 0 && rowCounter < imageGraph.length
						&& columnCounter >= 0
						&& columnCounter < imageGraph[0].length) {
					if (structuringElement[k][l] == foregroundClass
							&& imageGraph[rowCounter][columnCounter] == foregroundClass) {
						return true;
					}
				}
				columnCounter++;
			}
			rowCounter++;
		}
		return false;

	}