从二进制转换为原始数组值

baa*_*aal 3 arrays matlab

给定已转换为二进制的2D数组,对于二进制数组的某些索引值,如何在原始数据中找到相应的值?

也许使用ind2sub的东西?

Jon*_*nas 5

不,你可以直接索引.

%# create some test data
m = magic(4);
%# make binary image
bw = m>10;

%# read values from m
values = m(bw);

%# alternatively, if you have linear indices (as found via find)...
linIdx = find(bw);
%# ...you can use that instead
values = m(linIdx);
Run Code Online (Sandbox Code Playgroud)