doubt in specific line

3 views (last 30 days)
Rd
Rd on 23 Jul 2020
Commented: Rd on 24 Jul 2020
img_filt_up = img_filt(1:floor(img_h/2),:);
[~, y_up] = max(img_filt_up);
% Lower part of filtred image
img_filt_lo = img_filt(half_img_h:end,:);
[~,y_lo] = min(img_filt_lo);
Could you please explain the following line
region(y_up(i):y_lo(i)+size(img_filt_lo,1), i) = 1;

Accepted Answer

Arthur Roué
Arthur Roué on 23 Jul 2020
The line is settings to 1 elements of matrix region from row y_up(i) to row y_lo(i)+size(img_filt_lo,1) in column i.
I suppose i is your index in a for loop, but it would be simpler to answer with a bit of context .
  3 Comments
Arthur Roué
Arthur Roué on 23 Jul 2020
The function size returns a row vector whose elements are the lengths of the corresponding dimensions.
For instance,
% m is a 2 x 3 matrix
m = [1, 1, 1;
2, 2 ,2]
size(m)
ans =
2 3
When calling size with a second argument, you get the number of element of the specific dimension
size(m,1)
>> 2
size(m,2)
>> 3
In Matlab, rows are dimension 1 and column dimension 2.
% Return the number element in 1st dimension (row) of img_filt_lo
size(img_filt_lo,1)
Rd
Rd on 24 Jul 2020
i understood.Thank you for your brief explanation.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!