Skip to content

Instantly share code, notes, and snippets.

@tinesubic
Created April 10, 2018 20:50
Show Gist options
  • Save tinesubic/18299992b29a42e0d2351781d111d263 to your computer and use it in GitHub Desktop.
Save tinesubic/18299992b29a42e0d2351781d111d263 to your computer and use it in GitHub Desktop.
vaja5
def naloga5():
maxIter = 10
planes = np.load('letala.npy')
step = 20
fig, pltarr = rv.plt.subplots(2,2)
errors = []
for unalignedPlane in planes[1:5]:
reg = pc.rigid_registration(planes[0][::step,:], unalignedPlane[::step,:], maxIterations=maxIter)
reg.register(False)
alignedPlane = reg.TY
pltarr[0,0].plot(alignedPlane[:, 0], alignedPlane[:, 1], 'r-', markersize=1)
ptsRef, ptsMov = rv.findCorrespondingPoints(planes[0], alignedPlane)
print('Processing next image')
errors.append(
np.sum(np.sqrt((ptsRef[:, 0] - ptsMov[:, 0]) ** 2 + (ptsRef[:, 1] - ptsMov[:, 1]) ** 2)) / np.size(
ptsRef.shape[0]))
pltarr[0,0].set_title('Aligned - rigid')
pltarr[0,0].plot(planes[0][:, 0], planes[0][:, 1], 'b-', linewidth=3)
pltarr[0,1].hist(errors, edgecolor='black')
pltarr[0,1].set_title('Errors')
errors = []
for unalignedPlane in planes[1:5]:
reg = pc.affine_registration(planes[0][::step, :], unalignedPlane[::step, :], maxIterations=maxIter)
reg.register(False)
alignedPlane = reg.TY
pltarr[1,0].plot(alignedPlane[:, 0], alignedPlane[:, 1], 'r-', markersize=1)
ptsRef, ptsMov = rv.findCorrespondingPoints(planes[0], alignedPlane)
print('Processing next image')
errors.append(
np.sum(np.sqrt((ptsRef[:, 0] - ptsMov[:, 0]) ** 2 + (ptsRef[:, 1] - ptsMov[:, 1]) ** 2)) / np.size(
ptsRef.shape[0]))
pltarr[1, 0].set_title('Aligned - affine')
pltarr[1, 0].plot(planes[0][:, 0], planes[0][:, 1], 'b-', linewidth=3)
pltarr[1, 1].hist(errors, edgecolor='black')
pltarr[1, 1].set_title('Errors')
rv.plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment