Matrix Standard Deviation in 3D neighborhood
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi
I have a 3D matrix (NxNxM) and I want to compute standard deviation in a sliding window of, say, 3x3xM which means a square window going across all the matrices (or slices) but sliding in 2D only? Can anyone help me on this.
stdfilt() does not do what I want. It computes a 3x3x(odd number) window standard deviation which is perhaps sliding in depth or 3rd dimension as well.
Best Regards
Wajahat
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 10 Apr. 2012
% I - your 3D matrix - array(NxNxM)
k = padarray(I,[1 1],'symmetric');
s = size(I);
out = zeros(s(1),s(2));
for j1 = 1:size(I,1)
for j2 = 1:size(I,2)
out(j1,j2) = std2(k(j1 + (0:2),j2 + (0:2),:));
end
end
0 Kommentare
Weitere Antworten (1)
Sean de Wolski
am 10 Apr. 2012
stdfilt() will ignore the three-dimensional component if you tell it to:
x3 = stdfilt(repmat(magic(10),[1 1 3]),ones(3,3,1)) %three-d array, all slices equal
x1 = stdfilt(magic(10),ones(3,3,1)) %two-d array
all equal?
all(all(all(bsxfun(@eq,x3,x1))))
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!