Cody

Problem 908. AVIRIS Inscribed Rectangle Bit Mask - Speed Test

Solution 1686512

Submitted on 5 Dec 2018
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
m=ones(5); m(7)=0; m(11)=0; t0=clock; [idxtlc rmnr rmnc]=rect_mask(m); dt=etime(clock,t0)*1000; % ms dt [x y]=ind2sub(size(m),idxtlc); pass=~any(any(m(x:x+rmnr-1,y:y+rmnc-1)==0)); assert(rmnr*rmnc>=15,sprintf('Expected 15 pixels, only have %i\n',rmnr*rmnc)) assert(isequal(pass,1),sprintf('Not all non-zero [%i,%i] [%i,%i]\n',x,y,x+rmnr-1,y+rmnc-1)) fprintf('Time to process %.0f msec\n',dt); fprintf('idx=%i x=%i y=%i rect_nr=%i rect_nc=%i\n',idxtlc,x,y,rmnr,rmnc)

dt = 2.5210 Time to process 3 msec idx= x= y= rect_nr=5 rect_nc=5

2   Pass
m=zeros(6);m(15)=1; t0=clock; [idxtlc rmnr rmnc]=rect_mask(m); dt=etime(clock,t0)*1000; % ms dt [x y]=ind2sub(size(m),idxtlc); pass=~any(any(m(x:x+rmnr-1,y:y+rmnc-1)==0)); assert(rmnr*rmnc>=1,sprintf('Expected 1 pixel, only have %i\n',rmnr*rmnc)) assert(isequal(pass,1),sprintf('Not all non-zero [%i,%i] [%i,%i]\n',x,y,x+rmnr-1,y+rmnc-1)) fprintf('Time to process %.0f msec\n',dt); fprintf('idx=%i x=%i y=%i rect_nr=%i rect_nc=%i\n',idxtlc,x,y,rmnr,rmnc)

dt = 1.8060 Time to process 2 msec idx= x= y= rect_nr=6 rect_nc=6

3   Pass
m=ones(8); m(2,:)=0; m(7,:)=0; m(4,2)=0; m(5,7)=0; t0=clock; [idxtlc rmnr rmnc]=rect_mask(m); dt=etime(clock,t0)*1000; % ms dt [x y]=ind2sub(size(m),idxtlc); pass=~any(any(m(x:x+rmnr-1,y:y+rmnc-1)==0)); assert(rmnr*rmnc>=16,sprintf('Expected 16 pixels, only have %i\n',rmnr*rmnc)) assert(isequal(pass,1),sprintf('Not all non-zero [%i,%i] [%i,%i]\n',x,y,x+rmnr-1,y+rmnc-1)) fprintf('Time to process %.0f msec\n',dt); fprintf('idx=%i x=%i y=%i rect_nr=%i rect_nc=%i\n',idxtlc,x,y,rmnr,rmnc)

dt = 0.8020 Time to process 1 msec idx= x= y= rect_nr=8 rect_nc=8

4   Fail
% Load aviris file Layer 1 ; 1.8MB mat file global dt 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 % Time Trial File 1924 x 753 t0=clock; [idxtlc rmnr rmnc]=rect_mask(L001); dt=etime(clock,t0)*1000; % ms [x y]=ind2sub(size(L001),idxtlc); pass=~any(any(L001(x:x+rmnr-1,y:y+rmnc-1)==0)); assert(rmnr*rmnc>=1282281,sprintf('Expected 1282281 pixels, only have %i\n',rmnr*rmnc)) assert(isequal(pass,1),sprintf('Not all non-zero [%i,%i] [%i,%i]\n',x,y,x+rmnr-1,y+rmnc-1)) fprintf('Time to process %.0f msec\n',dt); fprintf('idx=%i x=%i y=%i rect_nr=%i rect_nc=%i\n',idxtlc,x,y,rmnr,rmnc)

[Warning: The value of local variables may have been changed to match the globals. Future versions of MATLAB will require that you declare a variable to be global before you use that variable.] [> In ScoringEngineTestPoint4 (line 2) In solutionTest (line 11)] Elapsed time is 1.880494 seconds.

Error using load Unable to read MAT-file /users/mss.system.D0SaeN/aviris_moffett_L001.mat. Not a binary MAT-file. Try load -ASCII to read as text. Error in Test4 (line 6) load('aviris_moffett_L001.mat');

5   Pass
global dt %Write file based on time in test 1 net_time=uint32(dt); % net_time in ms % Create graph data net_time=min(4000,net_time); % Limit graph y-axis fh=fopen('rect_mask.m','wt'); feval(@assignin,'caller','score',net_time) fprintf(fh,'%s\n',repmat('1;',[1,round(net_time/2)])); fclose(fh);

[Warning: The value of local variables may have been changed to match the globals. Future versions of MATLAB will require that you declare a variable to be global before you use that variable.] [> In ScoringEngineTestPoint5 (line 1) In solutionTest (line 13)]