protected double [ ] aggregateInternal ( ArrayList < double [ ] > descriptors ) { double [ ] vlad = new double [ numCentroids * descriptorLength ] ; if ( descriptors . size ( ) == 0 ) { // when there are 0 local descriptors extracted return vlad ; } for ( double [ ] descriptor : descriptors ) { int nnIndex = computeNearestCentroid ( descriptor ) ; for ( int i = 0 ; i < descriptorLength ; i ++ ) { vlad [ nnIndex * descriptorLength + i ] += descriptor [ i ] - codebook [ nnIndex ] [ i ] ; } } return vlad ; }
Takes as input an ArrayList of double arrays which contains the set of local descriptors for an image . Returns the VLAD vector representation of the image using the codebook supplied in the constructor .