Cody

# Problem 898. AVIRIS Hyperspectral Bit Mask

Solution 131379

Submitted on 27 Aug 2012 by Carsten
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, log in.

### Test Suite

Test Status Code Input and Output
1   Pass
%% m=ones(4,'uint16'); bmv = bitmask(m); assert(isinteger(bmv),sprintf('Non-Integer return')) assert(isequal(bmv,[255 255]))

ans = 255 255

2   Pass
%% m=zeros(4,'uint16'); m(1)=1; m(16)=1; bmv = bitmask(m); assert(isequal(bmv,[128 1]),[sprintf('Expected [128 1] saw: ') sprintf('%i ',bmv)])

ans = 128 1

3   Pass
%% m=zeros(3,'uint16'); m(8)=1; m(9)=1; bmv = bitmask(m); assert(isequal(bmv,[1 128]))

ans = 1 128

4   Pass
%% %Duplicity test m=randi(65535,[8 4],'uint16'); for i=1:12 m(randi(32))=0; end bmv = bitmask(m); mb=m>0; bmv_exp=[128 64 32 16 8 4 2 1]*mb; assert(isequal(bmv,bmv_exp))

ans = 248 190 143 239

5   Pass
%% % Load aviris file Layer 1 ; 1.8MB mat file tic % approx 2.5 sec to write and load urlwrite('http://tinyurl.com/matlab-avmofL001','aviris_moffett_L001.mat'); toc load('aviris_moffett_L001.mat'); toc % Array variable is L001 %Files also posted are L010,L023,L157, and L158 with same tinyurl format % L010 and L023 have high contrast L157 and L158 are in atmospheric notch bmv=bitmask(L001); % L001 (1:8) [1271 1259 1271 0 0 0 0 0] assert(isequal(bmv(1),224),sprintf('Expected 224 saw: %i',bmv(1))) assert(isequal(bmv(181097),0),sprintf('Expected 0 saw: %i',bmv(181097))) assert(isequal(bmv(90800),255),sprintf('Expected 255 saw: %i',bmv(90800)))

Elapsed time is 2.115806 seconds. Elapsed time is 2.803083 seconds. ans = Columns 1 through 12 224 0 0 0 0 0 0 0 0 0 0 0 Columns 13 through 24 0 0 0 0 0 0 0 0 0 0 0 0 Columns 25 through 36 0 0 0 0 0 0 0 0 0 0 0 0 Columns 37 through 48 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 Columns 61 through 72 0 0 0 0 0 0 0 0 0 0 0 0 Columns 73 through 84 0 0 0 0 0 0 0 0 0 0 0 0 Columns 85 through 96 0 0 0 0 0 0 0 0 0 0 0 0 Columns 97 through 108 0 0 0 0 0 0 0 0 0 0 0 0 Columns 109 through 120 0 0 0 0 0 0 0 0 0 0 0 0 Columns 121 through 132 0 0 0 0 0 0 0 0 0 0 0 0 Columns 133 through 144 0 0 0 0 0 0 0 0 0 0 0 0 Columns 145 through 156 0 0 0 0 0 0 0 0 0 0 0 0 Columns 157 through 168 0 0 0 0 0 0 0 0 0 0 0 0 Columns 169 through 180 0 0 0 0 0 0 0 0 0 0 0 0 Columns 181 through 192 0 0 0 0 0 0 0 0 0 0 0 0 Columns 193 through 204 0 0 0 0 0 0 0 0 0 0 0 0 Columns 205 through 216 0 0 0 0 0 0 0 0 0 0 0 0 Columns 217 through 228 0 0 0 0 0 0 0 0 0 0 0 0 Columns 229 through 240 0 0 0 0 0 0 0 0 0 0 0 0 Columns 241 through 252 13 128 0 63 160 0 0 0 0 0 0 0 Columns 253 through 264 0 0 0 0 0 0 0 0 0 0 0 0 Columns 265 through 276 0 0 0 0 0 0 0 0 0 0 0 0 Columns 277 through 288 0 0 0 0 0 0 0 0 0 0 0 0 Columns 289 through 300 0 0 0 0 0 0 0 0 0 0 0 0 Columns 301 through 312 0 0 0 0 0 0 0 0 0 0 0 0 Columns 313 through 324 0 0 0 0 0 0 0 0 0 0 0 0 Columns 325 through 336 0 0 0 0 0 0 0 0 0 0 0 0 Columns 337 through 348 0 0 0 0 0 0 0 0 0 0 0 0 Columns 349 through 360 0 0 0 0 0 0 0 0 0 0 0 0 Columns 361 through 372 0 0 0 0 0 0 0 0 0 0 0 0 Columns 373 through 384 0 0 0 0 0 0 0 0 0 0 0 0 Columns 385 through 396 0 0 0 0 0 0 0 0 0 0 0 0 Columns 397 through 408 0 0 0 0 0 0 0 0 0 0 0 0 Columns 409 through 420 0 0 0 0 0 0 0 0 0 0 0 0 Columns 421 through 432 0 0 0 0 0 0 0 0 0 0 0 0 Columns 433 through 444 0 0 0 0 0 0 0 0 0 0 0 0 Columns 445 through 456 0 0 0 0 0 0 0 0 0 0 0 0 Columns 457 through 468 0 0 0 0 0 0 0 0 0 0 0 0 Columns 469 through 480 0 0 0 0 0 0 0 0 0 0 0 0 Columns 481 through 492 0 255 0 29 251 192 0 0 0 0 0 0 Columns 493 through 504 0 0 0 0 0 0 0 0 0 0 0 0 Columns 505 through 516 0 0 0 0 0 0 0 0 0 0 0 0 Columns 517 through 528 0 0 0 0 0 0 0 0 0 0 0 0 Columns 529 through 540 0 0 0 0 0 0 0 0 0 0 0 0 Columns 541 through 552 0 0 0 0 0 0 0 0 0 0 0 0 Columns 553 through 564 0 0 0 0 0 0 0 0 0 0 0 0 Columns 565 through 576 0 0 0 0 0 0 0 0 0 0 0 0 Columns 577 through 588 0 0 0 0 0 0 0 0 0 0 0 0 Columns 589 through 600 0 0 0 0 0 0 0 0 0 0 0 0 Columns 601 through 612 0 0 0 0 0 0 0 0 0 0 0 0 Columns 613 through 624 0 0 0 0 0 0 0 0 0 0 0 0 Columns 625 through 636 0 0 0 0 0 0 0 0 0 0 0 0 Columns 637 through 648 0 0 0 0 0 0 0 0 0 0 0 0 Columns 649 through 660 0 0 0 0 0 0 0 0 0 0 0 0 Columns 661 through 672 0 0 0 0 0 0 0 0 0 0 0 0 Columns 673 through 684 0 0 0 0 0 0 0 0 0 0 0 0 Columns 685 through 696 0 0 0 0 0 0 0 0 0 0 0 0 Columns 697 through 708 0 0 0 0 0 0 0 0 0 0 0 0 Columns 709 through 720 0 0 0 0 0 0 0 0 0 0 0 0 Columns 721 through 732 0 15 239 251 255 255 0 0 0 0 0 0 Columns 733 through 744 0 0 0 0 0 0 0 0 0 0 0 0 Columns 745 through 756 0 0 0 0 0 0 0 0 0 0 0 0 Columns 757 through 768 0 0 0 0 0 0 0 0 0 0 0 0 Columns 769 through 780 0 0 0 0 0 0 0 0 0 0 0 0 Columns 781 through 792 0 0 0 0 0 0 0 0 0 0 0 0 Columns 793 through 804 0 0 0 0 0 0 0 0 0 0 0 0 Columns 805 through 816 0 0 0 0 0 0 0 0 0 0 0 0 Columns 817 through 828 0 0 0 0 0 0 0 0 0 0 0 0 Columns 829 through 840 0 0 0 0 0 0 0 0 0 0 0 0 Columns 841 through 852 0 0 0 0 0 0 0 0 0 0 0 0 Columns 853 through 864 0 0 0 0 0 0 0 0 0 0 0 0 Columns 865 through 876 0 0 0 0 0 0 0 0 0 0 0 0 Columns 877 through 888 0 0 0 0 0 0 0 0 0 0 0 0 Columns 889 through 900 0 0 0 0 0 0 0 0 0 0 0 0 Columns 901 through 912 0 0 0 0 0 0 0 0 0 0 0 0 Columns 913 through 924 0 0 0 0 0 0 0 0 0 0 0 0 Columns 925 through 936 0 0 0 0 0 0 0 0 0 0 0 0 Columns 937 through 948 0 0 0 0 0 0 0 0 0 0 0 0 Columns 949 through 960 0 0 0 0 0 0 0 0 0 0 0 0 Columns 961 through 972 0 0 255 255 255 255 246 0 0 0 0 0 Columns 973 through 984 0 0 0 0 0 0 0 0 0 0 0 0 Columns 985 through 996 0 0 0 0 0 0 0 0 0 0 0 0 Columns 997 through 1008 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1009 through 1020 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1021 through 1032 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1033 through 1044 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1045 through 1056 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1057 through 1068 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1069 through 1080 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1081 through 1092 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1093 through 1104 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1105 through 1116 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1117 through 1128 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1129 through 1140 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1141 through 1152 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1153 through 1164 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1165 through 1176 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1177 through 1188 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1189 through 1200 0 0 0 0 20 0 1 192 0 0 0 0 Columns 1201 through 1212 0 0 15 255 255 255 255 248 0 0 0 0 Columns 1213 through 1224 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1225 through 1236 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1237 through 1248 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1249 through 1260 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1261 through 1272 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1273 through 1284 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1285 through 1296 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1297 through 1308 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1309 through 1320 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1321 through 1332 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1333 through 1344 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1345 through 1356 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1357 through 1368 0 0 0 0 0 ...