is there any alternative way ?

1 view (last 30 days)
Niki
Niki on 18 Feb 2014
Answered: Sean de Wolski on 18 Feb 2014
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

Answers (1)

Sean de Wolski
Sean de Wolski on 18 Feb 2014
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

Categories

Find more on Geographic Plots 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!