Skip to content

Instantly share code, notes, and snippets.

@YaronBlinder
Created August 9, 2016 18:24
Show Gist options
  • Save YaronBlinder/08d596078fcf2faac3509966f571b142 to your computer and use it in GitHub Desktop.
Save YaronBlinder/08d596078fcf2faac3509966f571b142 to your computer and use it in GitHub Desktop.
test_Zhang_Suen_ported
def test_Zhang_Suen_ported():
I = np.random.randn(10,10)
yield Zhang_Suen_ported, I
$ nosetests test_calculateFVD.py:test_Zhang_Suen_ported
E
======================================================================
ERROR: test_calculateFVD.test_Zhang_Suen_ported(array([[ 0.47107946, -0.97497669, 1.07764687, -0.04557485, -1.05282552,
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\mrbli_000\Desktop\Python\Anaconda\lib\site-packages\nose\case.py", line 198, in runTest
self.test(*self.arg)
File "<decorator-gen-2>", line 2, in Zhang_Suen_ported
File "C:\Users\mrbli_000\Desktop\f0cl\edenis-confidential\testrepo\edenis-v4msti\tests\calculateFVD\rt_insert.py", line 8, in _wrapper
return self.callback(wrapped, _args, _dargs, args, dargs)
File "C:\Users\mrbli_000\Desktop\f0cl\edenis-confidential\testrepo\edenis-v4msti\tests\calculateFVD\test_calculateFVD.py", line 22, in callback
mfunc_result = getattr(engine, mfunc_name)(*func_args)
File "C:\Users\mrbli_000\Desktop\Python\Anaconda\lib\site-packages\oct2py\core.py", line 408, in octave_command
return self._call(name, *args, **kwargs)
File "C:\Users\mrbli_000\Desktop\Python\Anaconda\lib\site-packages\oct2py\core.py", line 515, in _call
data = self.eval(cmd, temp_dir=temp_dir, **eval_kwargs)
File "C:\Users\mrbli_000\Desktop\Python\Anaconda\lib\site-packages\oct2py\core.py", line 285, in eval
post_call=post_call)
File "C:\Users\mrbli_000\Desktop\Python\Anaconda\lib\site-packages\oct2py\core.py", line 859, in evaluate
raise Oct2PyError(msg)
oct2py.utils.Oct2PyError: Oct2Py tried to run:
"""
load C:\Users\MRBLI_~1\AppData\Local\Temp\tmp7szdx883\writer.mat "A__"
[a__] = Zhang_Suen(A__);
save -v6 -mat-binary C:\Users\MRBLI_~1\AppData\Local\Temp\tmp7szdx883\reader.mat a__
"""
Octave returned:
subscript indices must be either positive integers less than 2^31 or logicals
----------------------------------------------------------------------
Ran 1 test in 0.229s
FAILED (errors=1)
function out=Zhang_Suen(I); % Zhang-Suen method is used for binary image skeletonization
luteven = makelut('Zhang_Suen_Even',3); % Create lookup table for odd and even iterations of the Zhang Suen method
lutodd = makelut('Zhang_Suen_Odd',3);
finish_condition = 0; % Set condition to stop iterations
N = 2;
last = I; % Initialize last as original image. 'Last' will then be passed onto 'previous'
previous = applylut(last,lutodd); % Run odd iteration of Zhang Suen method on 'last'
current = applylut(previous,luteven); % Run even interation of Zhang Suen method on 'previous'
while finish_condition == 0; % Iterate so long as finish condition stays at 0
if all(current(:)==last(:)); % If current iteration is the same as the last...
finish_condition = 1; % End iterations
end
N = N + 1; % Add 1 to N for each iteration
last = previous; % Transfer 'previous' to last
previous = current; % Transfer 'current' to previous
if mod(N,2)==0 % mod(N,2) continually changes between 1 and 0 for each iteration. This is used to change between using odd and even iterations of the Zhang Suen method
current = applylut(current,luteven);
else
current = applylut(current,luteven);
end
end
out = current; % Output is result of final interation. Returns 'current' after no more changes occur
@mimic('Zhang_Suen')
def Zhang_Suen_ported(I) : # Zhang-Suen method is used for binary image skeletonization
luteven = makelut_m('Zhang_Suen_Even',3) # Create lookup table for odd and even iterations of the Zhang Suen method
lutodd = makelut_m('Zhang_Suen_Odd',3) #
finish_condition = 0 # Set condition to stop iterations
N = 2
last = I # Initialize last as original image. 'Last' will then be passed onto 'previous'
previous = applylut_m(last,lutodd) # Run odd iteration of Zhang Suen method on 'last'
current = applylut_m(previous,luteven) # Run even interation of Zhang Suen method on 'previous'
while finish_condition == 0: # Iterate so long as finish condition stays at 0
if (current==last).all: # If current iteration is the same as the last...
finish_condition = 1 # End iterations
N = N + 1 # Add 1 to N for each iteration
last = previous # Transfer 'previous' to last
previous = current # Transfer 'current' to previous
if (N%2 == 0):
current = applylut_m(current, luteven) # *** there is a bug here!!!
else:
current = applylut_m(current, luteven) # *** there is a bug here!!! one of these should be using lutodd
return current # Output is result of final interation. Returns 'current' after no more changes occur
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment