def tran(): # basedir = os.path.join('.', 'examples/banklogo') # the TEMPLATE # im0 = sp.misc.imread(os.path.join(basedir, "moban.jpg"), True) # float32 # the image to be transformed # im1 = sp.misc.imread(os.path.join(basedir, "bxz1.jpg"), True) # im3 = cv2.imread(os.path.join(basedir, "moban.jpg")) # im3 = cv2.cvtColor(im3,cv2.COLOR_BGR2GRAY) # unit8 # # im4 = im0.astype(dtype=np.uint8) # cv2.imshow('im0', im4) # cv2.waitKey(0) result = ird.translation(im0, im1) tvec = result["tvec"].round(4) # the Transformed IMaGe. timg = ird.transform_img(im1, tvec=tvec) # Maybe we don't want to show plots all the time ird.imshow(im0, im1, timg) plt.show() print("Translation is {}, success rate {:.4g}".format( tuple(tvec), result["success"]))
def xuanzhuan(): # the TEMPLATE # the image to be transformed im3 = sp.misc.imrotate(im1, 0.0) ct = {'angle': (2, 5)} # ct = None result = ird.similarity(im0, im3, numiter=3, constraints=ct) assert "timg" in result # Maybe we don't want to show plots all the time ird.imshow(im0, im3, result['timg']) plt.show()
import os import scipy as sp import imageio import imreg_dft as ird basedir = os.path.join('..', 'examples') # the TEMPLATE im0 = imageio.imread(os.path.join(basedir, "sample1.png"), as_gray=True) # the image to be transformed im1 = imageio.imread(os.path.join(basedir, "sample3.png"), as_gray=True) result = ird.similarity(im0, im1, numiter=3) assert "timg" in result # Maybe we don't want to show plots all the time if os.environ.get("IMSHOW", "yes") == "yes": import matplotlib.pyplot as plt ird.imshow(im0, im1, result['timg']) plt.show()
import os import scipy as sp import scipy.misc import matplotlib.pyplot as plt import imreg_dft as ird basedir = os.path.join('..', 'examples') # the TEMPLATE im0 = sp.misc.imread(os.path.join(basedir, "sample1.png"), True) # the image to be transformed im1 = sp.misc.imread(os.path.join(basedir, "sample2.png"), True) t0, t1 = ird.translation(im0, im1) # the Transformed IMaGe. timg = ird.transform_img(im1, tvec=(t0, t1)) ird.imshow(im0, im1, timg) plt.show() print(t0, t1)
import scipy.misc import matplotlib.pyplot as plt import imreg_dft as ird # import imreg_dft.utils as utils import imreg_dft.tiles as tiles datadir = '/Users/michielk/oxdata/P01/EM/M3/stitch_example' # dst = sp.misc.imread(os.path.join(datadir, "0000_m000.tif"), True) # src = sp.misc.imread(os.path.join(datadir, "0001_m000.tif"), True) full_im1, full_im2 = subsample_images(p, imgs, subsample_factor) dst, src = select_imregions(p[2], full_im1, full_im2, overlap_pixels) constraints = {'angle': [0,5], 'scale': [1,0]} result = ird.similarity(dst, src, numiter=3, constraints=constraints) ird.imshow(dst, src, result['timg']) plt.show() # subpixel ird sample1.png sample3.png --resample 3 --iter 4 --lowpass 0.9,1.1 --extend 10 --print-result
import os import scipy as sp import scipy.misc import matplotlib.pyplot as plt import imreg_dft as ird basedir = os.path.join('..', 'examples') # the TEMPLATE im0 = sp.misc.imread(os.path.join(basedir, "sample1.png"), True) # the image to be transformed im1 = sp.misc.imread(os.path.join(basedir, "sample3.png"), True) result = ird.similarity(im0, im1, numiter=3) ird.imshow(im0, im1, result['timg']) plt.show()