is there any alternative way ?

조회 수: 3 (최근 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 CenterFile Exchange에서 Downloads에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by