MATLAB: How to add two binay images and add the result to a third image

for loop for array binary imagesImage Acquisition ToolboxImage Processing Toolbox

Dear all,
I have one array that includes 5 binary images [I1, I2, I3, I4, I5].
I want to have a new array [R1, R2, R3, R4] where:
R1 = I1 + I2
R2 = R1 + I3
R3 = R2 + I4
R4 = R3 + I5
How to make a for loop for that?
Any help will be very appreciated.
Thank you very much.
Meshoo

Best Answer

Try this:
R1 = int32(I1) + int32(I2);
R2 = R1 + int32(I3);
R3 = R2 + int32(I4);
R4 = R3 + int32(I5);
output_R = [R1, R2, R3, R4];
imshow(output_R, []); % The [] are important.