code: public static void transformSq(final GrayU8 input , final GrayS64 transformed )
  	{
  		int indexSrc = input.startIndex;
  		int indexDst = transformed.startIndex;
  		int end = indexSrc + input.width;
  
  		long total = 0;
  		for( ; indexSrc < end; indexSrc++ ) {
  			int value = input.data[indexSrc]& 0xFF;
  			transformed.data[indexDst++] = total += value*value;
  		}
  
  		for( int y = 1; y < input.height; y++ ) {
  			indexSrc = input.startIndex + input.stride*y;
  			indexDst = transformed.startIndex + transformed.stride*y;
  			int indexPrev = indexDst - transformed.stride;
  
  			end = indexSrc + input.width;
  
  			total = 0;
  			for( ; indexSrc < end; indexSrc++ ) {
  				int value = input.data[indexSrc]& 0xFF;
  				total +=  value*value;
  				transformed.data[indexDst++] = transformed.data[indexPrev++] + total;
  			}
  		}
  	}
docs: Integral image of pixel value squared. integer