CityLandscapeTree { public String classifyImage( FImage image, int k ) { System.out.println( "Classifying image... " ); double[][] query = getImageVectorAsArray( image ); int[][] indexes = new int[1][k]; double[][] distances = new double[1][k]; dnn.searchKNN( query, k, indexes, distances ); double cat1Counter = 0, cat2Counter = 0; for( int i = 0; i < distances[0].length; i++ ) { if( indexes[0][i] < trainingSetSize / 2 ) cat1Counter += 1 / distances[0][i]; else cat2Counter += 1 / distances[0][i]; } if( cat1Counter > cat2Counter ) return cat1; else if( cat2Counter > cat1Counter ) return cat2; else return "?"; } CityLandscapeTree( String cat1, String cat2 );  CityLandscapeTree( String cat1, String cat2,
			InputStream trainingSet, int trainingSetSize ); String classifyImage( FImage image, int k ); double[][] loadTrainingSet( InputStream is, int vecSize ); static void main( String[] args );  }
@Test public void testCityDetection() { try { FImage cityImage = ImageUtilities.readF( new File( "src/test/resources/city.jpg" ) ); String classification = clt.classifyImage( cityImage, 1 ); System.out.println( classification ); Assert.assertEquals( CITY_STRING, classification ); } catch( IOException e ) { e.printStackTrace(); } }
@Test public void testLandscapeDetection() { try { FImage cityImage = ImageUtilities.readF( new File( "src/test/resources/landscape.jpg" ) ); String classification = clt.classifyImage( cityImage, 1 ); System.out.println( classification ); Assert.assertEquals( LANDSCAPE_STRING, classification ); } catch( IOException e ) { e.printStackTrace(); } }