Image Processing Toolbox | ![]() ![]() |
Nesting Calls to Image Arithmetic Functions
You can use the image arithmetic functions in combination to perform a series of operations. For example, to calculate the average of two images,
I = imread('rice.tif'); I2 = imread('cameraman.tif'); K = imdivide(imadd(I,I2), 2); % not recommended
However, when used with uint8
or uint16
data, each arithmetic function truncates its result before passing it on to the next operation. This truncation can significantly reduce the amount of information in the output image. A better way to perform this series of calculations is to use the imlincomb
function. imlincomb
performs all the arithmetic operations in the linear combination in double precision and only truncates the final result.
![]() | Dividing Images | Coordinate Systems | ![]() |