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


Python numpy.rot90函数代码示例

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


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

示例1: generate_image

def generate_image(data, is_partial=False, content_range=None):
    fig = plt.figure()
    if data.ndim == 1:
        plt.plot(data)
    elif data.ndim == 2:
        data = np.asarray(data).real
        mat = plt.matshow(np.rot90(data), cmap=plt.cm.viridis)
        mat.axes.get_xaxis().set_visible(False)
        mat.axes.get_yaxis().set_visible(False)
    elif data.ndim == 3 and data.shape[-1] in (3, 4):
        data = np.array(data)
        mat = plt.imshow(np.rot90(data))
        mat.axes.get_xaxis().set_visible(False)
        mat.axes.get_yaxis().set_visible(False)
    else:
        raise ValueError('cannot handle dimensions > 3')
    bio = BytesIO()
    plt.savefig(bio, bbox_inches='tight', pad_inches=0, format='png')
    bio.seek(0)
    fig.clf()
    plt.close('all')
    return TempResult(
            bio.read(),
            'image/png',
            is_partial=is_partial,
            content_range=content_range)
开发者ID:JohnVinyard,项目名称:zounds,代码行数:26,代码来源:serializer.py

示例2: displayFrame

    def displayFrame(self, update_locs):
        if self.movie_file:

            # Get the current frame.
            frame = self.movie_file.loadAFrame(self.cur_frame).astype(numpy.float)
            if self.ui.oriCheckBox.isChecked():
                frame = numpy.rot90(numpy.rot90(frame))
            else:
                frame = numpy.transpose(frame)


            # Create the 3D-DAOSTORM molecule items.
            nm_per_pixel = self.ui.nmPerPixelSpinBox.value()
            multi_mols = []
            if update_locs and self.multi_list:
                multi_mols = self.multi_list.createMolItems(self.cur_frame+1, nm_per_pixel)

            # Create the Insight3 molecule items.
            i3_mols = []
            if update_locs and self.i3_list:
                i3_mols = self.i3_list.createMolItems(self.cur_frame+1, nm_per_pixel)

            self.movie_view.newFrame(frame,
                                     multi_mols,
                                     i3_mols,
                                     self.ui.minSpinBox.value(),
                                     self.ui.maxSpinBox.value())
开发者ID:fnzhanghao,项目名称:storm-analysis,代码行数:27,代码来源:visualizer.py

示例3: rotate_data

def rotate_data(bg, overlay, slices_list, axis_name, shape):
    # Rotate the data as required
    # Return the rotated data, and an updated slice list if necessary
    if axis_name == 'axial':
        # Align so that right is right
        overlay = np.rot90(overlay)
        overlay = np.fliplr(overlay)
        bg = np.rot90(bg)
        bg = np.fliplr(bg)
    
    elif axis_name == 'coronal':
        overlay = np.rot90(overlay)
        bg = np.rot90(bg)
        overlay = np.flipud(np.swapaxes(overlay, 0, 2))
        bg = np.flipud(np.swapaxes(bg, 0, 2))
        slices_list[1] = [ shape - n - 3 for n in slices_list[1] ] 
        
    elif axis_name == 'sagittal':
        overlay = np.flipud(np.swapaxes(overlay, 0, 2))
        bg = np.flipud(np.swapaxes(bg, 0, 2))
    
    else:
        print '\n************************'
        print 'ERROR: data could not be rotated\n'
        parser.print_help()
        sys.exit()
    
    return bg, overlay, slices_list
开发者ID:KirstieJane,项目名称:DESCRIBING_DATA,代码行数:28,代码来源:MakePngs_DTI.py

示例4: modulatePF_unwrapped

    def modulatePF_unwrapped(self):
        #geometry = self._control.slm.getGeometry()
        geometry = self._getGeo()
        MOD = -1*self.unwrap()
        MOD = np.flipud(MOD)
        MOD = np.rot90(MOD)
        cx,cy,d = geometry.cx, geometry.cy, geometry.d
        # Diameter of phase retrieval output [pxl]:
        dPhRt = (self._pupil.k_max/self._pupil.kx.max())*self._pupil.nx
        # Zoom needed to fit onto SLM map:
        zoom = d/dPhRt
        MOD = interpolation.zoom(MOD,zoom,order=0,mode='nearest')
        # Flip up down:
        #MOD = np.flipud(MOD)
        # Flip left right:
        #MOD = np.fliplr(MOD)
        #MOD = np.rot90(MOD)
        MOD = np.rot90(-1.0*MOD) #Invert and rot90
        # Shift center:
        MOD = interpolation.shift(MOD,(cy-255.5,cx-255.5),order=0,
                                                       mode='nearest')
        # Cut out center 512x512:
        c = MOD.shape[0]/2
        MOD = MOD[c-256:c+256,c-256:c+256]

        
        # Add an 'Other' modulation using the SLM API. Store the index in _modulations:
        #index = self._control.slm.addOther(MOD)
        index = self._addMOD(MOD)
        self._modulations.append(index)
        return index
开发者ID:coder-guy22296,项目名称:Device_manager,代码行数:31,代码来源:adaptiveOptics_v0.py

示例5: do_cut

    def do_cut(self, map, affine):
        """ Cut the 3D volume into a 2D slice

            Parameters
            ==========
            map: 3D ndarray
                The 3D volume to cut
            affine: 4x4 ndarray
                The affine of the volume
        """
        coords = [0, 0, 0]
        coords['yxz'.index(self.direction)] = self.coord
        x_map, y_map, z_map = [int(round(c)) for c in
                               coord_transform(coords[0],
                                               coords[1],
                                               coords[2],
                                               np.linalg.inv(affine))]
        if self.direction == 'x':
            cut = np.rot90(map[:, y_map, :])
        elif self.direction == 'y':
            cut = np.rot90(map[x_map, :, :])
        elif self.direction == 'z':
            cut = np.rot90(map[:, :, z_map])
        else:
            raise ValueError('Invalid value for direction %s' %
                             self.direction)
        return cut
开发者ID:chrisfilo,项目名称:nipy,代码行数:27,代码来源:slicers.py

示例6: findRotationScaleTranslation

def findRotationScaleTranslation(image1, image2, window=None, highpass=None):
        image1 = normalize(image1)
        image2 = normalize(image2)

        rotation, scale, rsvalue = findRotationScale(image1, image2, window, highpass)

        shape = image2.shape[0]*2, image2.shape[1]*2

        r = rotateScaleOffset(image2, -rotation, 1.0/scale, (0.0, 0.0), shape)

        o = ((shape[0] - image1.shape[0])/2, (shape[1] - image1.shape[1])/2)
        i = numpy.zeros(shape, image1.dtype)
        i[o[0]:o[0] + image1.shape[0], o[1]:o[1] + image1.shape[1]] = image1

        fft1 = numpy.fft.rfft2(i)
        fft2 = numpy.fft.rfft2(r)
        pc = phaseCorrelate(fft1, fft2, fft=True)
        peak, value = findPeak(pc)

        r180 = numpy.rot90(numpy.rot90(r))
        fft2 = numpy.fft.rfft2(r180)
        pc = phaseCorrelate(fft1, fft2, fft=True)
        peak180, value180 = findPeak(pc)

        if value < value180:
                peak = peak180
                value = value180
                rotation = (rotation + 180.0) % 360.0
                r = r180

        return rotation, scale, peak, rsvalue, value
开发者ID:kraftp,项目名称:Leginon-Feature-Detection-Modification,代码行数:31,代码来源:align.py

示例7: plot_spectrogram

def plot_spectrogram(pred_spectrogram, path, info=None, split_title=False, target_spectrogram=None, max_len=None):
	if max_len is not None:
		target_spectrogram = target_spectrogram[:max_len]
		pred_spectrogram = pred_spectrogram[:max_len]

	if info is not None:
		if split_title:
			title = split_title_line(info)
		else:
			title = info

	fig = plt.figure(figsize=(10, 8))
	# Set common labels
	fig.text(0.5, 0.18, title, horizontalalignment='center', fontsize=16)

	#target spectrogram subplot
	if target_spectrogram is not None:
		ax1 = fig.add_subplot(311)
		ax2 = fig.add_subplot(312)

		im = ax1.imshow(np.rot90(target_spectrogram), interpolation='none')
		ax1.set_title('Target Mel-Spectrogram')
		fig.colorbar(mappable=im, shrink=0.65, orientation='horizontal', ax=ax1)
		ax2.set_title('Predicted Mel-Spectrogram')
	else:
		ax2 = fig.add_subplot(211)

	im = ax2.imshow(np.rot90(pred_spectrogram), interpolation='none')
	fig.colorbar(mappable=im, shrink=0.65, orientation='horizontal', ax=ax2)

	plt.tight_layout()
	plt.savefig(path, format='png')
	plt.close()
开发者ID:duvtedudug,项目名称:Tacotron-2,代码行数:33,代码来源:plot.py

示例8: _axialShow

def _axialShow(data, slice, overlay = False,
        surface = None):
    """
    similar to _coronalshow
    """
    if not overlay:
        plt.imshow(np.rot90(data[:, slice, :], k=1),
                    cmap = plt.cm.gray ,  aspect = 'auto', 
                    interpolation = 'nearest')

    if overlay: 
        overlayD = np.ma.masked_array(data, data == 0)
        if surface =='wm':
            plt.imshow(np.rot90(overlayD[:, slice, :], k=1),
                           cmap = plt.cm.Reds, vmax = 1.2, vmin = 0,
                           aspect = 'auto', 
                           interpolation = 'nearest')

        if surface == 'pial':
            plt.imshow(np.rot90(overlayD[:, slice, :], k=1),
                           cmap = plt.cm.hot, vmax = 1.2, vmin = 0,
                           aspect = 'auto', 
                           interpolation = 'nearest')


    return None
开发者ID:armaneshaghi,项目名称:DCMPy,代码行数:26,代码来源:mri.py

示例9: strel

def strel(l,d):
	print 'strel(',l,',',d,')'
	def _get_rect_shape(l):
		if l % 2 == 0:
			l+=1
		return l,l
	w,h = _get_rect_shape(l)

	d = float(d)
	m = math.tan(math.radians(d))
	if d <= 45.0:
		x1 = w
		y1 = m*x1
		_line = line
	elif d <= 90.0:
		y1 = h
		x1 = y1 / m
		_line = line2
	elif d <= 180.0:
		output = strel(l, d-90.0)
		return np.rot90(output)

	m = np.zeros((w,h))
	x1,y1 = int(math.ceil(x1)), int(math.ceil(y1))
	for x,y in _line(0,0,x1,y1):
		m[x][y] = 1
	m = np.rot90(m)
	output = np.zeros(m.shape, dtype=np.uint8)
	output[0:w/2+1, h/2:h] = m[w/2:w+1, 0:h/2+1]
	output[w/2:w+1, 0:h/2+1] = np.rot90(output[0:w/2+1, h/2:h],2)

	return output
开发者ID:felipeblassioli,项目名称:MAC0499,代码行数:32,代码来源:grabed.py

示例10: _load_textures

    def _load_textures(self):
        marker_one_textures = {}
        marker_two_textures = {}

        # load images
        image_green = cv2.imread('{}green.png'.format(self.FILE_PATH))
        image_yellow = cv2.imread('{}yellow.png'.format(self.FILE_PATH))
        image_blue = cv2.imread('{}blue.png'.format(self.FILE_PATH))
        image_pink = cv2.imread('{}pink.png'.format(self.FILE_PATH))
        image_saltwash = np.rot90(cv2.imread('{}saltwash.jpg'.format(self.FILE_PATH)), 2)
        image_halo = np.rot90(cv2.imread('{}halo.jpg'.format(self.FILE_PATH)), 2)

        # load textures for marker one
        marker_one_textures[TEXTURE_FRONT] = None
        marker_one_textures[TEXTURE_RIGHT] = image_green
        marker_one_textures[TEXTURE_BACK] = image_yellow
        marker_one_textures[TEXTURE_LEFT] = image_blue
        marker_one_textures[TEXTURE_TOP] = image_pink

        # load textures for marker two
        marker_two_textures[TEXTURE_FRONT] = image_saltwash
        marker_two_textures[TEXTURE_RIGHT] = image_green
        marker_two_textures[TEXTURE_BACK] = image_halo
        marker_two_textures[TEXTURE_LEFT] = image_blue
        marker_two_textures[TEXTURE_TOP] = image_pink

        return (marker_one_textures, marker_two_textures)
开发者ID:dash-ak,项目名称:ArkwoodAR,代码行数:27,代码来源:mediacube.py

示例11: _coronalShow

def _coronalShow(data, slice, overlay = False,
        surface = None):
    
    """
    function to plot T1 volume and pial/WM surfaces
    data: nibabel loaded numpy array
    slice: integer indicating number of the desired slice
    overlay: boolean indicating whether the data is an overlay or not
    surface: string indicating what kind of surface is overlay (wm or pial)

    """

    if not overlay:
        plt.imshow(np.rot90(data[:, :, slice], k=3),
                        cmap = plt.cm.gray ,  aspect = 'auto', 
                        interpolation = 'nearest')


    if overlay:
        overlayD = np.ma.masked_array(data, data == 0)
        if surface =='wm':
                plt.imshow(np.rot90(overlayD[:,:, slice], k=3),
                           cmap = plt.cm.Reds, vmax = 1.2, vmin = 0,
                           aspect = 'auto', 
                           interpolation = 'nearest')
        if surface == 'pial':
                plt.imshow(np.rot90(overlayD[:, :, slice], k=3),
                           cmap = plt.cm.hot, vmax = 1.2, vmin = 0,
                           aspect = 'auto', 
                           interpolation = 'nearest')
    return None
开发者ID:armaneshaghi,项目名称:DCMPy,代码行数:31,代码来源:mri.py

示例12: get_chunk_info

    def get_chunk_info(self,closeFile = True):
        """Preloads region header information."""
        
        if self._locations:
            return
        
        self.openfile()

        self._chunks = None
        self._locations = [0]*32*32
        self._timestamps = []
        
        # go to the beginning of the file
        self._file.seek(0)        
        
        # read chunk location table
        locations_index = numpy.reshape(numpy.rot90(numpy.reshape(range(32*32),
                (32, 32)), -self.get_north_rotations()), -1)
        for i in locations_index:
            self._locations[i] = self._read_chunk_location()
        
        # read chunk timestamp table
        timestamp_append = self._timestamps.append
        for _ in xrange(32*32): 
            timestamp_append(self._read_chunk_timestamp())
        self._timestamps = numpy.reshape(numpy.rot90(numpy.reshape(
                self._timestamps, (32,32)),self.get_north_rotations()), -1)
 
        if closeFile:        
            self.closefile()
        return
开发者ID:Psykar,项目名称:Minecraft-Overviewer,代码行数:31,代码来源:nbt.py

示例13: get_boundry

def get_boundry(pix, width, height):
        start = True
        finished = False
        north = True
        xVar = 0
        initialCoord = [1, 1]
	coord = initialCoord
        boundryArr = []
        var = 5  # number of pixels to jump accross when filtering
        while finished < 4:
        	coord = search_north_border(pix, width, height, coord, boundryArr) #starting from the north direction
               	if coord == [0,0]:
                	xVar += var
                        coord = [1, xVar]
                else:
                        boundryArr.append(coord) #if it wasn't in a bad position append it
                        pix[coord[0]][coord[1]] = 500

                if xVar >= width:
			finished += 1 #completes one more rotation
			coord = initialCoord #start from the beginning again
			np.rot90(pix) #rotate the image by 90 degrees to begin searching again
		        nextDir = 'NE' # reinitialise directions
			prevDir = ['NE', 'NE', 'NE'] # want the border to search up and away from edge first
       			temp = height
			height = width
			width = temp #change the orientation of height and width
       	pix = process_boundry(pix, width, height, boundryArr)
#	print boundryArr
	return pix
开发者ID:ArianeMora,项目名称:gusto-mri-noise-filter,代码行数:30,代码来源:filter.py

示例14: random_rotation_90

def random_rotation_90(channels, gt_lbls, probs_rot_90=None):
    # Rotate by 0/90/180/270 degrees.
    # channels: list (x pathways) of np arrays [channels, x, y, z]. Whole volumes, channels of a case.
    # gt_lbls: np array of shape [x,y,z]
    # probs_rot_90: {'xy': {'0': fl, '90': fl, '180': fl, '270': fl},
    #                'yz': {'0': fl, '90': fl, '180': fl, '270': fl},
    #                'xz': {'0': fl, '90': fl, '180': fl, '270': fl} }
    if probs_rot_90 is None:
        return channels, gt_lbls
        
    for key, plane_axes in zip( ['xy', 'yz', 'xz'], [(0,1), (1,2), (0,2)] ) :
        probs_plane = probs_rot_90[key]
        
        if probs_plane is None:
            continue
        
        assert len(probs_plane) == 4 # rotation 0, rotation 90 degrees, 180, 270.
        assert channels[0].shape[1+plane_axes[0]] == channels[0].shape[1+plane_axes[1]] # +1 cause [0] is channel. Image/patch must be isotropic.
        
        # Normalize probs
        sum_p = probs_plane['0'] + probs_plane['90'] + probs_plane['180'] + probs_plane['270']
        if sum_p == 0:
            continue
        for rot_k in probs_plane:
            probs_plane[rot_k] /= sum_p # normalize p to 1.
            
        p_rot_90_x0123 = ( probs_plane['0'], probs_plane['90'], probs_plane['180'], probs_plane['270'] )
        rot_90_xtimes = np.random.choice(a=(0,1,2,3), size=1, p=p_rot_90_x0123)
        for path_idx in range(len(channels)):
            channels[path_idx] = np.rot90(channels[path_idx], k=rot_90_xtimes, axes = [axis+1 for axis in plane_axes]) # + 1 cause [0] is channels.
        gt_lbls = np.rot90(gt_lbls, k=rot_90_xtimes, axes = plane_axes)
        
    return channels, gt_lbls
开发者ID:Kamnitsask,项目名称:deepmedic,代码行数:33,代码来源:augmentation.py

示例15: save_3plane_vertical

    def save_3plane_vertical(self, X_cut, Y_cut, Z_cut, savefile):
        fig = pylab.figure(figsize=(4,3))
        for image in self.image_list:
            fig.add_subplot(3,1,1) ##### AXIAL
            plt.imshow(np.rot90(image[0][self.xmin:self.xmax,self.ymin:self.ymax, Z_cut],3),
                    cmap=image[1], vmax=image[2], vmin=image[3], alpha=image[4],
                    extent=[0, self.x_trans*(self.xmax - self.xmin),
                            0, self.y_trans*(self.ymax - self.ymin)],
                    origin='lower')
            plt.axis('off')

            fig.add_subplot(3,1,2) ##### COR
            plt.imshow(np.rot90(image[0][self.xmin:self.xmax, Y_cut,self.zmin:self.zmax],3),
                    cmap=image[1], vmax=image[2], vmin=image[3], alpha=image[4],
                    extent=[0, self.x_trans*(self.xmax - self.xmin),
                            0, self.z_trans*(self.zmax - self.zmin)],
                    origin='lower')
            plt.axis('off')

            fig.add_subplot(3,1,3) #### SAG
            plt.imshow(np.rot90(image[0][X_cut,self.ymin:self.ymax,self.zmin:self.zmax],3),
                    cmap=image[1], vmax=image[2], vmin=image[3], alpha=image[4],
                    extent=[0,self.y_trans*(self.ymax - self.ymin),
                            0, self.z_trans*(self.zmax - self.zmin)],
                    origin='lower')
            plt.axis('off')

        plt.savefig(savefile, dpi=500, facecolor=[0,0,0], bbox_inches=None,
                    pad_inches=0)
        plt.close()
开发者ID:PIRCImagingTools,项目名称:sfDM,代码行数:30,代码来源:map_maker.py


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