Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

summation of binary images

Asked by Elysi Cochin on 6 Sep 2013

if i have 5 binary images.... how to compute the summation of all binary images and normalization of the pixel value.. please do reply how to write the matlab code.... please do reply.....

0 Comments

Elysi Cochin

2 Answers

Answer by Image Analyst on 6 Sep 2013
Edited by Image Analyst on 7 Sep 2013
Accepted answer

Not sure if you mean

sumImage = (double(bw1) + double(bw2) + double(bw3) + double(bw4) + double(bw5)) / 5;

or if you mean the union of all of them with the result remaining a binary image:

binaryImage = bw1 | bw2 | bw3 | bw4 | bw5;

Which is it? Or a better question would be, why do you want this image? What are you going to do with it?

0 Comments

Image Analyst
Answer by Geert on 6 Sep 2013
Edited by Geert on 6 Sep 2013

If you would have 5 binary images stored in the variables Im1, Im2, Im3, Im4 and Im5, than you can get the summation by the command:

ImSum = Im1 + Im2 + Im3 + Im4 + Im5;

The new image ( ImSum ) will probably no longer be binary. You can normalize it to have its mean equal to 1 by the command

ImSum = ImSum/(mean(ImSum(:)));

Is this what you were looking for? You should try to be more specific in your question, i.e. post an example of what you are looking for or provide us with more details...

3 Comments

Elysi Cochin on 7 Sep 2013

thank u for replying.... actually i wanted to compute gait energy information... in that it is said... GEI is to compensate for the nonmoving regions and the multiple motion instants regions of the action. The summation of all binary silhouette images and normalization of the pixel value define GEI as

http://img708.imageshack.us/img708/2544/uj0c.png

Image Analyst on 7 Sep 2013

Then you'd better use my answer, Geert's formula does give ImSum as a double, but the max value is still 1, not 5 since the casting to double is done after the sum, not to each image before the sum, thus the sums are clipped to 1.

Elysi Cochin on 9 Sep 2013

ok sir... thank u all....

Geert

Contact us