i want to knw the working of this code section:

2 views (last 30 days)
for i=1:(row-25)
for j=1:24
rv(i)=rv(i)+rv(i+1);
end;
rv(i)=rv(i)/25;
end;
where row means number of row in binary image.and rv means row variance of that image.

Accepted Answer

Image Analyst
Image Analyst on 18 Sep 2013
They're getting the averaged row variance (rv) over a pair of lines. So they're taking the row variance and adding the rv from the next row. Then they divide by 25 to scale it (for some reason, instead of 2 which would get you the average). Just follow the logic:
rv(1) = rv(1)+rv(2);
rv(2) = rv(2)+rv(3);
rv(3) = rv(3)+rv(4);
etc.
The loop over j is totally useless - it just calculates the same rv(i) 24 times. There is no need at all for the j loop!
It doesn't make much sense to me why you'd want to do that.
  2 Comments
Vandana
Vandana on 18 Sep 2013
Thank u very much sir Sir can I use 2 instead of 25?
Image Analyst
Image Analyst on 20 Sep 2013
Well, yes - but that assumes that all the indexes inside your inner loop are i. I have my doubts. I mean, why have a loop over j if you never refer to j??? If I were you, I'd check what I wrote and make sure all your i's are really i's and none of them is supposed to be a j. Because it just doesn't make sense that someone would have a loop over j for no reason.

Sign in to comment.

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!