simple question about one of "Img()" commands

for yy=1:Y
for xx=1:X
frame = img(max(1,yy-WIN):min(Y,yy+WIN),max(1,xx-WIN):min(X,xx+WIN));
ma = max(frame(:)); mi = min(frame(:));
contr(yy,xx) = (ma-mi)/(ma+mi);
end
what does this phrase mean? "max(1,yy-WIN):min(Y,yy+WIN)"

 Accepted Answer

Wayne King
Wayne King on 22 Oct 2012
Edited: Wayne King on 22 Oct 2012
It says create a vector from A to B, where A is the maximum of 1 and yy-WIN and B is the minimum of Y and yy+WIN. That vector is used to index the elements of img(). In other words to select the elements of img() for those row indices. The easiest way to see how this works is to create a simple example for yourself.
Y = 5;
WIN = 2;
for yy = 1:Y
max(1,yy-WIN):min(Y,yy+WIN)
end

2 Comments

thanks for your helpful answer. would you also explain what the img( , ) does?
img( , ) address the row and column index of img()
img = randn(10,10);
img(1,1) % first row -- first column

Sign in to comment.

More Answers (0)

Asked:

on 22 Oct 2012

Community Treasure Hunt

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

Start Hunting!