필터 지우기
필터 지우기

doubt in the specific lines

조회 수: 2 (최근 30일)
Rd
Rd 2020년 7월 23일
댓글: Rd 2020년 7월 23일
could you explain this line
mask_h=4;
mask_w=20
mask = zeros(mask_h,mask_w);
mask(1:mask_h/2,:) = -1;
mask(mask_h/2 + 1:end,:) = 1;
img_filt = imfilter(img, mask,'replicate');
img_filt_up = img_filt(1:floor(img_h/2),:);
i cant understand what it means in general (,:,:,).

채택된 답변

Deepak Gupta
Deepak Gupta 2020년 7월 23일
':' means 'All'.
For example in your code you have created a mask of size 4*20 and initialized it with zeros. i.e.
mask = zeros(mask_h,mask_w);
In the next line you are assigning some perticular values to your mask. i.e.
mask(1:mask_h/2,:) = -1;
Here, 1: mask_h/2 = 1:2, because mask_h has value 4
and then ':' means 'All'. First index represents rows and second one column. So this line of code will assign value -1 to rows from 1 to 2 and in all columns. You can verify it by printing the mask value.
Same is for next line, where value of 1 is assigned for rest of the rows (3 to 4) in all columns.
If you don't want to assign values in all columns, then you will write something like:
mask(1:2, 1:10) = -1. Here value -1 will be assigned for rows 1 to 2 and columns 1 to 10 only.
  댓글 수: 1
Rd
Rd 2020년 7월 23일
i understood. thank you so much for your explanation

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by