help regarding indexing matrix in image processing
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
SUJATA MOURYA
il 31 Mar 2015
Modificato: Image Analyst
il 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 Commenti
Risposta accettata
Michael Haderlein
il 31 Mar 2015
Modificato: Michael Haderlein
il 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrices and Arrays in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!