过滤高于特定阈值的 3D 矩阵?
Filtering 3D matrix above certain threshold?
我有两个相同大小的 3D 矩阵。比方说,A 包含从 0 到 1 的值,B 包含某些离散值。
我想从 B 矩阵中提取高于 A 中特定阈值的值?
谁能帮帮我?
像这样?看看 logical indexing.
% Input.
B = reshape(1:18, 2, 3, 3)
A = rand(size(B))
% Threshold.
thr = 0.75
% Output.
output = B(A > thr)
B =
ans(:,:,1) =
1 3 5
2 4 6
ans(:,:,2) =
7 9 11
8 10 12
ans(:,:,3) =
13 15 17
14 16 18
A =
ans(:,:,1) =
0.80533 0.24370 0.89180
0.90358 0.22422 0.69243
ans(:,:,2) =
0.119366 0.168337 0.771999
0.206004 0.065481 0.979772
ans(:,:,3) =
0.0057303 0.1469925 0.0556628
0.0454038 0.4122576 0.9847027
thr = 0.75000
output =
1
2
5
11
12
18
我有两个相同大小的 3D 矩阵。比方说,A 包含从 0 到 1 的值,B 包含某些离散值。
我想从 B 矩阵中提取高于 A 中特定阈值的值?
谁能帮帮我?
像这样?看看 logical indexing.
% Input.
B = reshape(1:18, 2, 3, 3)
A = rand(size(B))
% Threshold.
thr = 0.75
% Output.
output = B(A > thr)
B =
ans(:,:,1) =
1 3 5
2 4 6
ans(:,:,2) =
7 9 11
8 10 12
ans(:,:,3) =
13 15 17
14 16 18
A =
ans(:,:,1) =
0.80533 0.24370 0.89180
0.90358 0.22422 0.69243
ans(:,:,2) =
0.119366 0.168337 0.771999
0.206004 0.065481 0.979772
ans(:,:,3) =
0.0057303 0.1469925 0.0556628
0.0454038 0.4122576 0.9847027
thr = 0.75000
output =
1
2
5
11
12
18