Effacer les filtres
Effacer les filtres

help regarding indexing matrix in image processing

3 vues (au cours des 30 derniers jours)
SUJATA MOURYA
SUJATA MOURYA le 31 Mar 2015
Modifié(e) : Image Analyst le 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]

Réponse acceptée

Michael Haderlein
Michael Haderlein le 31 Mar 2015
Modifié(e) : Michael Haderlein le 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.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by