Cody

# Problem 908. AVIRIS Inscribed Rectangle Bit Mask - Speed Test

Solution 483700

Submitted on 6 Aug 2014 by Jean-Marie Sainthillier
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
global dt dt=0; m=ones(5); m(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>=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 = 736.9110 Time to process 737 msec idx=3 x=3 y=1 rect_nr=3 rect_nc=5

2   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 = 3.2980 Time to process 3 msec idx=3 x=3 y=1 rect_nr=3 rect_nc=5

3   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 = 4.4550 Time to process 4 msec idx=15 x=3 y=3 rect_nr=1 rect_nc=1

### Community Treasure Hunt

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

Start Hunting!