help regarding indexing matrix in image processing
1 view (last 30 days)
Show older comments
SUJATA MOURYA
on 31 Mar 2015
Edited: Image Analyst
on 31 Mar 2015
i am working on quincux matrix for image sampling. i want to make the alternate elements zero of rows of a given matrix such that for each odd row the row starts with zero and for each even rows the second starting element is zero.
example:- given matrix is
[1 2 3 4 5;
6 7 8 9 1;
1 3 6 7 4;
2 9 7 8 5;
5 6 7 8 3]
result required is:-
[0 2 0 4 0;
6 0 8 0 1;
0 3 0 7 0;
2 0 7 0 5;
0 6 0 8 0]
0 Comments
Accepted Answer
Michael Haderlein
on 31 Mar 2015
Edited: Michael Haderlein
on 31 Mar 2015
I think there are dozens of possibilities, I just thought about this particular one:
if mod(size(m,1),2)==0
m=[m;nan(1,size(m,2))];
end
m(1:2:end)=0;
if isnan(m(end,2))
m=m(1:end-1,:);
end
Please note that there must not be NaNs in the matrix. If there are NaNs, this code must be little modified. Tell me in this case.
0 Comments
More Answers (0)
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!