/** Read a line into the cache (including padding in x). * If y>=height, instead of reading new data, it duplicates the line y=height-1. * If y==0, it also creates the data for y<0, as far as necessary, thus filling the cache with * more than one line (padding by duplicating the y=0 row). */ private static void readLineToCacheOrPad(Object pixels, int width, int height, int roiY, int xminInside, int widthInside, float[]cache, int cacheWidth, int cacheHeight, int padLeft, int padRight, int colorChannel, int kHeight, int y) { int lineInCache = y%cacheHeight; if (y < height) { readLineToCache(pixels, y*width, xminInside, widthInside, cache, lineInCache*cacheWidth, padLeft, padRight, colorChannel); if (y==0) for (int prevY = roiY-kHeight/2; prevY<0; prevY++) { //for y<0, pad with y=0 border pixels int prevLineInCache = cacheHeight+prevY; System.arraycopy(cache, 0, cache, prevLineInCache*cacheWidth, cacheWidth); } } else System.arraycopy(cache, cacheWidth*((height-1)%cacheHeight), cache, lineInCache*cacheWidth, cacheWidth); }
/** Read a line into the cache (including padding in x). * If y>=height, instead of reading new data, it duplicates the line y=height-1. * If y==0, it also creates the data for y<0, as far as necessary, thus filling the cache with * more than one line (padding by duplicating the y=0 row). */ private static void readLineToCacheOrPad(Object pixels, int width, int height, int roiY, int xminInside, int widthInside, float[]cache, int cacheWidth, int cacheHeight, int padLeft, int padRight, int colorChannel, int kHeight, int y) { int lineInCache = y%cacheHeight; if (y < height) { readLineToCache(pixels, y*width, xminInside, widthInside, cache, lineInCache*cacheWidth, padLeft, padRight, colorChannel); if (y==0) for (int prevY = roiY-kHeight/2; prevY<0; prevY++) { //for y<0, pad with y=0 border pixels int prevLineInCache = cacheHeight+prevY; System.arraycopy(cache, 0, cache, prevLineInCache*cacheWidth, cacheWidth); } } else System.arraycopy(cache, cacheWidth*((height-1)%cacheHeight), cache, lineInCache*cacheWidth, cacheWidth); }