public static void equalizeLocalInner ( GrayU8 input , int radius , GrayU8 output , IWorkArrays workArrays ) { int width = 2 * radius + 1 ; int area = width * width ; int maxValue = workArrays . length ( ) - 1 ; //CONCURRENT_BELOW BoofConcurrency.loopBlocks(radius,input.height-radius,(y0,y1)->{ int y0 = radius , y1 = input . height - radius ; int [ ] histogram = workArrays . pop ( ) ; for ( int y = y0 ; y < y1 ; y ++ ) { localHistogram ( input , 0 , y - radius , width , y + radius + 1 , histogram ) ; // compute equalized pixel value using the local histogram int inputValue = input . unsafe_get ( radius , y ) ; int sum = 0 ; for ( int i = 0 ; i <= inputValue ; i ++ ) { sum += histogram [ i ] ; } output . set ( radius , y , ( sum * maxValue ) / area ) ; // start of old and new columns in histogram region int indexOld = input . startIndex + y * input . stride ; int indexNew = indexOld + width ; // index of pixel being examined int indexIn = input . startIndex + y * input . stride + radius + 1 ; int indexOut = output . startIndex + y * output . stride + radius + 1 ; for ( int x = radius + 1 ; x < input . width - radius ; x ++ ) { // update local histogram by removing the left column for ( int i = - radius ; i <= radius ; i ++ ) { histogram [ input . data [ indexOld + i * input . stride ] & 0xFF ] -- ; } // update local histogram by adding the right column for ( int i = - radius ; i <= radius ; i ++ ) { histogram [ input . data [ indexNew + i * input . stride ] & 0xFF ] ++ ; } // compute equalized pixel value using the local histogram inputValue = input . data [ indexIn ++ ] & 0xFF ; sum = 0 ; for ( int i = 0 ; i <= inputValue ; i ++ ) { sum += histogram [ i ] ; } output . data [ indexOut ++ ] = ( byte ) ( ( sum * maxValue ) / area ) ; indexOld ++ ; indexNew ++ ; } } workArrays . recycle ( histogram ) ; //CONCURRENT_ABOVE }); }
Performs local histogram equalization just on the inner portion of the image