code: void computeCellHistograms() {
  
  		int width = cellCols* pixelsPerCell;
  		int height = cellRows* pixelsPerCell;
  
  		float angleBinSize = GrlConstants.F_PI/orientationBins;
  
  		int indexCell = 0;
  		for (int i = 0; i < height; i += pixelsPerCell) {
  			for (int j = 0; j < width; j += pixelsPerCell, indexCell++ ) {
  				Cell c = cells[indexCell];
  				c.reset();
  
  				for (int k = 0; k < pixelsPerCell; k++) {
  					int indexPixel = (i+k)*derivX.width+j;
  
  					for (int l = 0; l < pixelsPerCell; l++, indexPixel++ ) {
  						float pixelDX = this.derivX.data[indexPixel];
  						float pixelDY = this.derivY.data[indexPixel];
  
  						// angle from 0 to pi radians
  						float angle = UtilAngle.atanSafe(pixelDY,pixelDX) + GrlConstants.F_PId2;
  
  						// gradient magnitude
  						float magnitude = (float)Math.sqrt(pixelDX*pixelDX + pixelDY*pixelDY);
  
  						// Add the weighted gradient using bilinear interpolation
  						float findex0 = angle/angleBinSize;
  						int index0 = (int)findex0;
  						float weight1 = findex0-index0;
  						index0 %= orientationBins;
  						int index1 = (index0+1)%orientationBins;
  
  						c.histogram[index0] += magnitude*(1.0f-weight1);
  						c.histogram[index1] += magnitude*weight1;
  					}
  				}
  
  			}
  		}
  	}
docs: Compute histograms for all the cells inside the image using precomputed derivative.