Exemplo n.º 1
0
 def plot_pyramid(pyr, start=0, end=0, **kwargs):
     """
     @ src  : 影像金字塔
     @ start: 從第幾層開始
     @ end  : 到弟幾層
     @ figx,figy: 影像大小
     """
     layers = np.size(pyr)
     # 金字塔有幾層
     if end == 0:
         end = layers
         # 最後第幾層
     if pyr[0].ndim == 2:
         pages = 1
         # 每一層有幾個分頁
     if pyr[0].ndim == 3: pages = pyr[0].shape[2]
     ymax = 0
     xmax = 0
     ys = np.zeros(end - start)
     # 每一層的起始位置Y
     #---- ----
     for octv in range(start, end):  #-- 計算位置
         ys[octv - start] = ymax
         ymax += pyr[octv].shape[0]
         xmax = np.maximum(xmax, pyr[octv].shape[1] * pages)
     dest = np.zeros((ymax, xmax))
     #---- ----
     for octv in range(start, end):  #-- 填入資料
         base = pyr[octv]
         rows = base.shape[0]
         cols = base.shape[1]
         for page in range(0, pages):
             if pages > 1: img = base[:, :, page]
             if pages == 1: img = base[:, :]
             y1 = ymax - (ys[octv - start]).astype(int) - rows
             x0 = page * cols
             dest[y1:y1 + rows, x0:x0 + cols] = img
     if kwargs.get('normalize'):  #-- 調整動態範微
         dmax = np.max(dest)
         dmin = np.min(dest)
         dest = (dest - dmin) / (dmax - dmin)
         dmax = np.max(dest)
         dmin = np.min(dest)
     CVP.imshow(dest, **kwargs)
     plt.show()
Exemplo n.º 2
0
    PAN.upload(plt.imread('taipei_03.jpg') / 256)
    PAN.upload(plt.imread('taipei_04.jpg') / 256)
    PAN.upload(plt.imread('taipei_05.jpg') / 256)
    pano_tools.plot_source_images(PAN)
    # plot source images
#=================================================== Auto execution
if 1 == 0:
    pano_tools.focal_correct(PAN)
    pano_tools.extract_features(PAN)
    # extract features
    pano_tools.pairing(PAN, th=None)
    # pairing feature points
    pano_tools.floorplan(PAN, tilt1=3.5)
    pano_tools.transform(PAN)
    pano_tools.registry(PAN, bw=25, box_th=None)
    CVP.imshow(PAN.result, figy=8, ticks='off')

#=================================================== Step 1: focal length correct
if 1 == 0:
    pano_tools.focal_correct(PAN)
    pano_tools.plot_focal_correct(PAN)
    # plot source images
#=================================================== Step 2: extract features
if 1 == 0:
    pano_tools.extract_features(PAN)
    # extract features
    pano_tools.plot_features(PAN)
    # plot keypoints for image 0
#=================================================== Step 3: Pairing
if 1 == 0:
    pano_tools.pairing(PAN, th=None)
Exemplo n.º 3
0
 def plot_transform(PAN):                        #---- plot registry images
   for k in range(0, np.shape(PAN.imgt)[0]):
     CVP.imshow(PAN.imgt[k],figy=6,ticks='off');
     print('image no:',k);
Exemplo n.º 4
0
 def plot_focal_correct(PAN):                    #---- plot source image base      
   for k in range(0, np.shape(PAN.imgc)[0]): 
     CVP.imshow(PAN.imgc[k],figy=6,ticks='off');
     print('image no:',k);
Exemplo n.º 5
0
 def plot_source_images(PAN) :                   #---- plot source image base
   for k in range(0, np.shape(PAN.imgs)[0]): 
     CVP.imshow(PAN.imgs[k],figy=6,ticks='off');
     print('image no:',k);