Cody

Problem 850. Spectral Distance - Speed Scoring

Solution 990010

Submitted on 3 Oct 2016
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   Fail
feval(@assignin,'caller','score',2000);

Error: You may not use the command(s) feval in your code

2   Fail
global As dt %A=imread('concordaerial.png'); A=imread(fullfile(matlabroot,'toolbox','images','imdata','concordaerial.png')); size(A); % 2036 x 3060 As=A(1:512,1:512,:); S=squeeze(A(1182,1672,:))'; % Golf Course d=sqrt(3); N_expect=730; % Small warm-up calls 512x512 N = spectral_dist(As,S,d); N = spectral_dist(As,S,d); % A big warm-up call N = spectral_dist(A,S,d); t0=clock; N = spectral_dist(A,S,d); dt=etime(clock,t0)*1000; % ms fprintf('N= %i Time to process %.0f msec\n',N,dt); Pass=0.99*N_expect<N && N<1.01*N_expect; assert(Pass==1,sprintf('N_exp=730 N= %.0f\n',N))

Error: You may not use the command(s) feval in your code

3   Fail
global As dt temp=dt; % anti-cheat %randomize random seed=clock; seed=1000*seed(6); rng(seed); % Select random point in As sub-window for anti-cheat purposes x=randi(512,1,1); y=randi(512,1,1); S=squeeze(As(x,y,:))'; % d=sqrt(17); N = spectral_dist(As,S,d); dt=temp; S=double(S); As=double(As); N_expect=0; for i=1:512 for j=1:512 dr2=(S(1)-As(i,j,1))^2; dg2=(S(2)-As(i,j,2))^2; db2=(S(3)-As(i,j,3))^2; if sqrt(dr2+dg2+db2)<=d N_expect=N_expect+1; end end end fprintf('x=%i y=%i N= %i N_expect=%i\n',x,y,N,N_expect); Pass=0.99*N_expect<N && N<1.01*N_expect; dt=temp; % anti-cheat assert(Pass==1,sprintf('x= %i y=%i N_exp=%.0f N= %.0f\n',x,y,N_expect,N))

Error: You may not use the command(s) feval in your code

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

Error: You may not use the command(s) feval in your code

Suggested Problems

More from this Author246

Community Treasure Hunt

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

Start Hunting!