What does this mean in MATLAB?

I have came about a MATLAB code like the following:
xyz = imfilter(A,B);
xyz_subsample = xyz(1:2:size(xyz, 1), 1:2:size(xyz, 2));
The code is related to subsampling. But, what does the second line mean?
Thanks.

댓글 수: 1

Jan
Jan 2013년 11월 10일
@med-sweng: Your questions have a very low acceptance rate. This usually means, that there is a problem in the way you ask. In long term, this can discourage contributors to spend the time for answering your questions. So it is in your own interest to clarify your questions until they can be answered successfully, and accept this answer then.

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

답변 (2개)

Jan
Jan 2013년 11월 10일
편집: Jan 2013년 11월 10일

1 개 추천

It crops every 2nd line and column out of the matrix xyz.
Simply try it:
xyz = randi(99, 10, 10)
xyzS = xyz(1:2:size(xyz, 1), 1:2:size(xyz, 2))
the cyclist
the cyclist 2013년 11월 10일

1 개 추천

Suppose xyz is a 256x512 matrix. Then
size(xyz,1)
is 256 and
size(xyz,2)
is 512.
The code
1:2:size(xyz,1)
is a vector counting by 2's:
[1 3 5 7 ... 255]
and likewise for the second dimension.
So, the whole code is subsampling by only selecting every 2nd element of both the x and y dimensions.

댓글 수: 2

med-sweng
med-sweng 2013년 11월 10일
Thanks for your nice answer. So, the code will choose the following values from "x" for instance: 1, 3, 5, ..., 255, right?
the cyclist
the cyclist 2013년 11월 11일
As Jan also describes, your code keeps rows 1,3,5,... and columns 1,3,5 ... .

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

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2013년 11월 10일

댓글:

2013년 11월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by