当前位置: 首页>>代码示例>>Python>>正文


Python numpy.rot90方法代码示例

本文整理汇总了Python中numpy.rot90方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.rot90方法的具体用法?Python numpy.rot90怎么用?Python numpy.rot90使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numpy的用法示例。


在下文中一共展示了numpy.rot90方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: show

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import rot90 [as 别名]
def show():
    """Output the contents of the buffer to Unicorn HAT HD."""
    setup()
    if _addressing_enabled:
        for address in range(8):
            display = _displays[address]
            if display.enabled:
                if _buffer_width == _buffer_height or _rotation in [0, 2]:
                    window = display.get_buffer_window(numpy.rot90(_buf, _rotation))
                else:
                    window = display.get_buffer_window(numpy.rot90(_buf, _rotation))

                _spi.xfer2([_SOF + 1 + address] + (window.reshape(768) * _brightness).astype(numpy.uint8).tolist())
                time.sleep(_DELAY)
    else:
        _spi.xfer2([_SOF] + (numpy.rot90(_buf, _rotation).reshape(768) * _brightness).astype(numpy.uint8).tolist())

    time.sleep(_DELAY) 
开发者ID:pimoroni,项目名称:unicorn-hat-hd,代码行数:20,代码来源:__init__.py

示例2: augment_img

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import rot90 [as 别名]
def augment_img(img, mode=0):
    '''Kai Zhang (github: https://github.com/cszn)
    '''
    if mode == 0:
        return img
    elif mode == 1:
        return np.flipud(np.rot90(img))
    elif mode == 2:
        return np.flipud(img)
    elif mode == 3:
        return np.rot90(img, k=3)
    elif mode == 4:
        return np.flipud(np.rot90(img, k=2))
    elif mode == 5:
        return np.rot90(img)
    elif mode == 6:
        return np.rot90(img, k=2)
    elif mode == 7:
        return np.flipud(np.rot90(img, k=3)) 
开发者ID:cszn,项目名称:KAIR,代码行数:21,代码来源:utils_image.py

示例3: augment_img_tensor4

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import rot90 [as 别名]
def augment_img_tensor4(img, mode=0):
    '''Kai Zhang (github: https://github.com/cszn)
    '''
    if mode == 0:
        return img
    elif mode == 1:
        return img.rot90(1, [2, 3]).flip([2])
    elif mode == 2:
        return img.flip([2])
    elif mode == 3:
        return img.rot90(3, [2, 3])
    elif mode == 4:
        return img.rot90(2, [2, 3]).flip([2])
    elif mode == 5:
        return img.rot90(1, [2, 3])
    elif mode == 6:
        return img.rot90(2, [2, 3])
    elif mode == 7:
        return img.rot90(3, [2, 3]).flip([2]) 
开发者ID:cszn,项目名称:KAIR,代码行数:21,代码来源:utils_image.py

示例4: augment_imgs

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import rot90 [as 别名]
def augment_imgs(img_list, hflip=True, rot=True):
    # horizontal flip OR rotate
    hflip = hflip and random.random() < 0.5
    vflip = rot and random.random() < 0.5
    rot90 = rot and random.random() < 0.5

    def _augment(img):
        if hflip:
            img = img[:, ::-1, :]
        if vflip:
            img = img[::-1, :, :]
        if rot90:
            img = img.transpose(1, 0, 2)
        return img

    return [_augment(img) for img in img_list] 
开发者ID:cszn,项目名称:KAIR,代码行数:18,代码来源:utils_image.py

示例5: rotate_patches

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import rot90 [as 别名]
def rotate_patches(patches_vol, patches_seg):
    # Initialize lists for rotated patches
    rotated_vol = []
    rotated_seg = []
    # Iterate over 90,180,270 degree (1*90, 2*90, 3*90)
    for times in range(1,4):
        # Iterate over each patch
        for i in range(len(patches_vol)):
            # Rotate volume & segmentation and cache rotated patches
            patch_vol_rotated = np.rot90(patches_vol[i], k=times, axes=(2,3))
            rotated_vol.append(patch_vol_rotated)
            patch_seg_rotated = np.rot90(patches_seg[i], k=times, axes=(2,3))
            rotated_seg.append(patch_seg_rotated)
    # Add rotated patches to the original patches lists
    patches_vol.extend(rotated_vol)
    patches_seg.extend(rotated_seg)
    # Return processed patches lists
    return patches_vol, patches_seg

# Flip patches at the provided axes 
开发者ID:muellerdo,项目名称:kits19.MIScnn,代码行数:22,代码来源:preprocessing.py

示例6: data_aug

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import rot90 [as 别名]
def data_aug(img, mode=0):
    # data augmentation
    if mode == 0:
        return img
    elif mode == 1:
        return np.flipud(img)
    elif mode == 2:
        return np.rot90(img)
    elif mode == 3:
        return np.flipud(np.rot90(img))
    elif mode == 4:
        return np.rot90(img, k=2)
    elif mode == 5:
        return np.flipud(np.rot90(img, k=2))
    elif mode == 6:
        return np.rot90(img, k=3)
    elif mode == 7:
        return np.flipud(np.rot90(img, k=3)) 
开发者ID:guochengqian,项目名称:TENet,代码行数:20,代码来源:Prepro.py

示例7: rot90

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import rot90 [as 别名]
def rot90(m, k=1, axes=(0, 1)):  # pylint: disable=missing-docstring
  m_rank = tf.rank(m)
  ax1, ax2 = utils._canonicalize_axes(axes, m_rank)  # pylint: disable=protected-access

  k = k % 4
  if k == 0:
    return m
  elif k == 2:
    return flip(flip(m, ax1), ax2)
  else:
    perm = tf.range(m_rank)
    perm = tf.tensor_scatter_nd_update(perm, [[ax1], [ax2]], [ax2, ax1])

    if k == 1:
      return transpose(flip(m, ax2), perm)
    else:
      return flip(transpose(m, perm), ax2) 
开发者ID:google,项目名称:trax,代码行数:19,代码来源:array_ops.py

示例8: _create_bowl

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import rot90 [as 别名]
def _create_bowl(self, altitude_changes):
        half_width = len(altitude_changes)
        height = sum(altitude_changes) + 1

        half_bowl = np.zeros((height, half_width))

        row = 0
        for idx, ac in enumerate(altitude_changes):
            half_bowl[row, idx] = 1
            for i in xrange(ac):
                row += 1
                half_bowl[row, idx] = 1

        assert row == height-1

        bowl = np.concatenate([half_bowl, np.fliplr(half_bowl)], axis=1)

        for _ in range(self.rotations):
            bowl = np.rot90(bowl)

        return bowl 
开发者ID:vicariousinc,项目名称:pixelworld,代码行数:23,代码来源:pattern_generator.py

示例9: rot180

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import rot90 [as 别名]
def rot180(images):
    """
    旋转图片180度。
    支持HW/CHW/NCHW三种格式的images。
    """
    out = np.empty(shape=images.shape, dtype=images.dtype)
    if images.ndim == 2:
        out = np.rot90(images, k=2)
    elif images.ndim == 3:
        for c in xrange(images.shape[0]):
            out[c] = np.rot90(images[c], k=2)
    elif images.ndim == 4:
        for n in xrange(images.shape[0]):
            for c in xrange(images.shape[1]):
                out[n][c] = np.rot90(images[n][c], k=2)
    else:
        raise Exception('Invalid ndim: ' + str(images.ndim) +
                        ', only support ndim between 2 and 4.')
    return out


# 给定函数f,自变量x以及对f的梯度df,求对x的梯度 
开发者ID:monitor1379,项目名称:hamaa,代码行数:24,代码来源:np_utils.py

示例10: _apply_transformations

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import rot90 [as 别名]
def _apply_transformations(plot_config, data_slice):
    """Rotate, flip and zoom the data slice.

    Depending on the plot configuration, this will apply some transformations to the given data slice.

    Args:
        plot_config (mdt.visualization.maps.base.MapPlotConfig): the plot configuration
        data_slice (ndarray): the 2d slice of data to transform

    Returns:
        ndarray: the transformed 2d slice of data
    """
    if plot_config.rotate:
        data_slice = np.rot90(data_slice, plot_config.rotate // 90)

    if not plot_config.flipud:
        # by default we flipud to correct for matplotlib lower origin. If the user
        # sets flipud, we do not need to to it
        data_slice = np.flipud(data_slice)

    data_slice = plot_config.zoom.apply(data_slice)
    return data_slice 
开发者ID:robbert-harms,项目名称:MDT,代码行数:24,代码来源:matplotlib_renderer.py

示例11: get_buffer_window

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import rot90 [as 别名]
def get_buffer_window(self, source):
        """Grab the correct portion of the supplied buffer for this display.

        :param source: source buffer, should be a numpy array

        """
        view = source[self.x:self.x + PANEL_SHAPE[0], self.y:self.y + PANEL_SHAPE[1]]
        return numpy.rot90(view, self.rotation + 1) 
开发者ID:pimoroni,项目名称:unicorn-hat-hd,代码行数:10,代码来源:__init__.py

示例12: cce2full

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import rot90 [as 别名]
def cce2full(A):

    # Assume all square for now

    N = A.shape
    N_half = N[0]//2 + 1
    out = np.empty((A.shape[0], A.shape[0]), dtype=A.dtype)
    out[:, :N_half] = A

    out[1:, N_half:] = np.rot90(A[1:, 1:-1], 2).conj()

    # Complete the first row
    out[0, N_half:] = A[0, -2:0:-1].conj()

    return out 
开发者ID:LCAV,项目名称:FRIDA,代码行数:17,代码来源:mkl_fft.py

示例13: augment_data

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import rot90 [as 别名]
def augment_data(self, game_state, training_data, row, column):
        """Loop for each self-play game.

        Runs MCTS for each game state and plays a move based on the MCTS output.
        Stops when the game is over and prints out a winner.

        Args:
            game_state: An object containing the state, pis and value.
            training_data: A list to store self play states, pis and vs.
            row: An integer indicating the length of the board row.
            column: An integer indicating the length of the board column.
        """
        state = deepcopy(game_state[0])
        psa_vector = deepcopy(game_state[1])

        if CFG.game == 2 or CFG.game == 1:
            training_data.append([state, psa_vector, game_state[2]])
        else:
            psa_vector = np.reshape(psa_vector, (row, column))

            # Augment data by rotating and flipping the game state.
            for i in range(4):
                training_data.append([np.rot90(state, i),
                                      np.rot90(psa_vector, i).flatten(),
                                      game_state[2]])

                training_data.append([np.fliplr(np.rot90(state, i)),
                                      np.fliplr(
                                          np.rot90(psa_vector, i)).flatten(),
                                      game_state[2]]) 
开发者ID:blanyal,项目名称:alpha-zero,代码行数:32,代码来源:train.py

示例14: rotate

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import rot90 [as 别名]
def rotate(images):
    images = np.append(images, [np.fliplr(image) for image in images], axis=0)  # 180 degree
    images = np.append(images, [np.rot90(image) for image in images], axis=0)   # 90 degree
    return images 
开发者ID:kozistr,项目名称:rcan-tensorflow,代码行数:6,代码来源:util.py

示例15: rotate

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import rot90 [as 别名]
def rotate(image, angle, axes=(0, 1)):
    if angle % 90 != 0:
        raise Exception('Angle must be a multiple of 90.')
    k = angle // 90
    return np.rot90(image, k, axes=axes) 
开发者ID:neptune-ai,项目名称:open-solution-salt-identification,代码行数:7,代码来源:augmentation.py


注:本文中的numpy.rot90方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。