is there any alternative way ?

1 次查看(过去 30 天)
Niki
Niki 2014-2-18
I want to remove those part of my data which are higher than 0.75 and those that lower than 0.30 I am using the following way, do you have any other idea?
[X Y Z] = size(H_cube);
avg_spec = zeros(X,Y);
specular_mask = zeros(X,Y);
data_mask = zeros(X,Y);
counter = 1;
for i=1:X
for j=1:Y
avg_spec(i,j) = mean(H_cube(i,j,:));
for k=1:Z
if(H_cube(i,j,k)>0.75 || avg_spec(i,j) >0.30)
specular_mask(i,j) = 1;
end
if(H_cube(i,j,k)>0.40)
data_mask(i,j) = 1;
end
end
end
end

回答(1 个)

Sean de Wolski
Sean de Wolski 2014-2-18
Do the whole avg_spec calculation at once:
avg_spec = mean(H_cube,3); % mean along third dimension
Use logical indexing to create data_mask and specular_mask
specular_mask = bsxfun(@or,H_cube>0.75, avg_spec>0.30); % apply or with avg_spec to every page of H_cube
data_mask = H_cube > 0.40; % logical indexing directly

类别

Help CenterFile Exchange 中查找有关 Motion Planning 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by