How to add two binay images and add the result to a third image?
显示 更早的评论
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
采纳的回答
更多回答(1 个)
Ahmet Cecen
2014-8-18
Here is how to make a loop for that:
R(:,1)=I(:,1)+I(:,2); %Initialization
for i=2:4
R(:,i)=R(:,i-1)+I(:,i+1); %This is the loop that you asked for.
end
5 个评论
Image Analyst
2014-8-18
His I1, I2, etc. are arrays (2D images), not 1D column vectors like your code requires.
Ahmet Cecen
2014-8-18
In that case, I can't repair the loop until I know exactly how each image is stored. Are they literally a concatenated array like [I1 I2 ...] or ar they stored individually as variables I1 and I2 or are they cell arrays or a struct. The same indexing logic should work regardless though.
One fool-proof way to do it would be to flatten the images to 1D, and form the 2D array I=[I1,I2...] and use the above code, then unflatten them using "reshape".
Image Analyst
2014-8-18
My question exactly. The situation is not defined clearly enough to answer. But I think it can be done without reshaping, just so long as you know the size and number of the I1, I2, etc. that make up the "one array".
Meshooo
2014-8-18
Image Analyst
2014-8-18
Yes. Did you read our comments about what information is required?
类别
在 帮助中心 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!