Filter löschen
Filter löschen

doubt in specific line

1 Ansicht (letzte 30 Tage)
Rd
Rd am 23 Jul. 2020
Kommentiert: Rd am 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;

Akzeptierte Antwort

Arthur Roué
Arthur Roué am 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 Kommentare
Arthur Roué
Arthur Roué am 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 am 24 Jul. 2020
i understood.Thank you for your brief explanation.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by