BlockMean

버전 1.2.0.0 (9.8 KB) 작성자: Jan
Mean of rectangular submatrices, fast C-Mex (no running mean)
다운로드 수: 2.5K
업데이트 날짜: 2010/11/5

라이선스 보기

BLOCKMEAN - Fast mean of rectangular submatrices

The mean of V*W elements along the 1st and 2nd dimension is calculated. This is no running mean filter: The sizes of the 1st and 2nd dimension are reduced by the factors V and W.
I use this as cheap anti-aliasing of RGB images, therefore it is implemented for DOUBLE and UINT8 input.

Y = BlockMean(X, V, W)
Input:
X: UINT8 or DOUBLE array of any size.
V, W: 2 scalars as size of the window. Each element of the output is the
mean over V*W neighbouring elements of the input.
V and W are limited to 256 to limit memory usage.
Output:
Y: UINT8 or DOUBLE array, the 1st and 2nd dimensions are V and W times shorter:
[FIX(X / V) x FIX(Y / W) x (further dims...)]
If the size of the 1st or 2nd dimension is not a multiple of V and W, the
remaining elements at the end are skipped.

E.g. for 4x4 blocks of a 1024x768x3 double array, this MEX implementation is about 5 times faster than the corresponding Matlab method (Matlab 2009a, 1.5GHz Pentium-M, WinXP, MSVC 2008):
reshape(sum(sum(reshape(X, 4, 256, 4, 192, 3), 1), 3), 256, 192, 3).
Run the unit-test uTest_BlockMean to check validity and speed.

Tested with: LCC v2.4, v3.8, Open Watcom 1.8, BCC 5.5, MSVC 2008, Matlab 6.5, 7.7, 7.8, WinXP 32 bit
Compatibility assumed: Linux, MacOS, 64bit.

Pre-compiled Mex: http://www.n-simon.de/mex

I'd appreciate suggestions for improvements and bug reports sent through email - thanks.

인용 양식

Jan (2024). BlockMean (https://www.mathworks.com/matlabcentral/fileexchange/24812-blockmean), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2009a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Neighborhood and Block Processing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.2.0.0

No need to enable 80bit extended precision under Linux. This avoids troubles during the compilation.

1.1.0.0

64 bit addressing supported, rectangular blocks: V ~= W, isEqualTol included in the test function

1.0.0.0