is there any alternative way ?

1 回表示 (過去 30 日間)
Niki
Niki 2014 年 2 月 18 日
回答済み: Sean de Wolski 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 Center および File ExchangeMotion Planning についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by