Last time I've tried on skimage I think that I didn't do really understand
how it works. As you seem pretty confident, I take a little time to study
it. As I often switch between OpenCV and skimage I've performed the
coordinate interpolation using both methods. I've also used the
scipy.interpolation.griddata which is the only one that I figure out to
make work.
As usual OpenCV is 6x faster but skimage perform good even with 4096x4096
images.
I just create a disk and transform it in ellipse using warping function.
For Ndimage, you can find an example of geometric_transform, but it doesn't
work for me, map_coordinate is not suited for a full image mapping.
I'm pretty sure both ndimage and scikit-image can handle larger images than
> that. Did you see these fail in practice?
>
> Stéfan
>
>
>
--
You received this message because you are subscribed to the Google Groups
"scikit-image" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send an email to [email protected].
To view this discussion on the web, visit
https://groups.google.com/d/msgid/scikit-image/c59117bc-4415-41db-be69-7ac3ce52a424%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
import numpy as np
import scipy.interpolate as ip
import scipy.ndimage as nd
import time
from skimage.transform import warp
import cv2
Size_x=1024
Size_y=1024
radius=100
Y,X = np.meshgrid(range(0,Size_x), range(0,Size_y))
Img=np.zeros(Y.shape)
# Creation of a dummy image
Img[((X-X.max()/2)**2+(Y-Y.max()/2)**2)**0.5<radius]=255
# Displacement and transformation creation
U=-0.2*(X-X.max()/2)
V=0.1*(Y-Y.max()/2)
Xi=X+U # compression
Yi=Y+V # elongation
# griddata from interpolate
## Need delaunay triangulation that consume a lot of memory don't go over 1024x1024 ...
points=(X.reshape(X.shape[0]*X.shape[1],1)[:,0],Y.reshape(X.shape[0]*X.shape[1],1)[:,0])
value=Img.reshape(X.shape[0]*X.shape[1],1)[:,0]
t0=time.time()
Imgi_griddata = ip.griddata(points,value , (Xi,Yi), method='linear')
print("Griddata time : %f"%(time.time()-t0))
Trans=np.zeros((2,Img.shape[0],Img.shape[1]))
Trans[0,::,::]=Xi
Trans[1,::,::]=Yi
t0=time.time()
Imgi_skimage=warp(Img,Trans)
print("Skimage warp time : %f"%(time.time()-t0))
t0=time.time()
Imgi_cv2=cv2.remap(Img.astype('float32'),Yi.astype('float32'),Xi.astype('float32'),cv2.INTER_LINEAR)
print("OpenCV remap time : %f"%(time.time()-t0))
## ndimage interpolation tools
# Does not work on my PC
#def shift_func(output_coordinates, s0, s1):
#return (output_coordinates[0] + s0, output_coordinates[1] + s1)
#t0=time.time()
#imgi_nd=nd.geometric_transform(Img,shift_func,extra_arguments = (U, V))
#print("Ndimage time : %d"%(time.time()-t0))