Set image direction

        Arguments
        ---------
        new_direction : numpy.ndarray or tuple or list
            updated direction for the image.
            should have one value for each dimension

        Returns
        -------
        None
17082
def set_direction(self, new_direction):
        
        if isinstance(new_direction, (tuple,list)):
            new_direction = np.asarray(new_direction)

        if not isinstance(new_direction, np.ndarray):
            raise ValueError('arg must be np.ndarray or tuple or list')
        if len(new_direction) != self.dimension:
            raise ValueError('must give a origin value for each dimension (%i)' % self.dimension)

        libfn = utils.get_lib_fn('setDirection%s'%self._libsuffix)
        libfn(self.pointer, new_direction)
722857
def check_num_slices(num_slices, img_shape=None, num_dims=3):
    

    if not isinstance(num_slices, Iterable) or len(num_slices) == 1:
        num_slices = np.repeat(num_slices, num_dims)

    if img_shape is not None:
        if len(num_slices) != len(img_shape):
            raise ValueError('The number of dimensions requested is different from image.'
                             ' Must be either 1 or equal to {}'.format(len(img_shape) + 1))
        # upper bounding them to image shape
        num_slices = np.minimum(img_shape, num_slices)

    # lower bounding it to 1
    return np.maximum(1, num_slices)
1590
def set_origin(self, new_origin):
        
        if not isinstance(new_origin, (tuple, list)):
            raise ValueError('arg must be tuple or list')
        if len(new_origin) != self.dimension:
            raise ValueError('must give a origin value for each dimension (%i)' % self.dimension)

        libfn = utils.get_lib_fn('setOrigin%s'%self._libsuffix)
        libfn(self.pointer, new_origin)
782815
def moves_in_direction(self, direction, position):
        
        current_square = self.location

        while True:
            try:
                current_square = direction(current_square)
            except IndexError:
                return

            if self.contains_opposite_color_piece(current_square, position):
                yield self.create_move(current_square, notation_const.CAPTURE)

            if not position.is_square_empty(current_square):
                return

            yield self.create_move(current_square, notation_const.MOVEMENT)
1373161
def add_orientation(self, orientation):
        """"""
        if not orientation in range(1, 9):
            print_error(
                "Error value for orientation, value must be in range(1,9), setting to default 1")
            self._ef['0th'][piexif.ImageIFD.Orientation] = 1
        else:
            self._ef['0th'][piexif.ImageIFD.Orientation] = orientation
710885
def update_image(self, data):
        
        if 1 in data.shape:
            data = data.squeeze()
        if self.conf.contrast_level is not None:
            clevels = [self.conf.contrast_level, 100.0-self.conf.contrast_level]
            imin, imax = np.percentile(data, clevels)
            data = np.clip((data - imin)/(imax - imin + 1.e-8), 0, 1)
        self.axes.images[0].set_data(data)
        self.canvas.draw()
477443
def update_image(self):
        
        if self._image:
            self._image.set_cmap(self.get_cmap())
            _pylab.draw()
174524
public void setDirectionArrow(final Bitmap image){
		this.DIRECTION_ARROW = image;
		this.DIRECTION_ARROW_CENTER_X = this.DIRECTION_ARROW.getWidth() / 2 - 0.5f;
		this.DIRECTION_ARROW_CENTER_Y = this.DIRECTION_ARROW.getHeight() / 2 - 0.5f;
		this.DIRECTION_ARROW_HEIGHT = this.DIRECTION_ARROW.getHeight();
		this.DIRECTION_ARROW_WIDTH = this.DIRECTION_ARROW.getWidth();
	}
852946
def reorient_image2(image, orientation='RAS'):
    
    if image.dimension != 3:
        raise ValueError('image must have 3 dimensions')

    inpixeltype = image.pixeltype
    ndim = image.dimension
    if image.pixeltype != 'float':
        image = image.clone('float')

    libfn = utils.get_lib_fn('reorientImage2')
    itkimage = libfn(image.pointer, orientation)

    new_img = iio.ANTsImage(pixeltype='float', dimension=ndim, 
                         components=image.components, pointer=itkimage)#.clone(inpixeltype)
    if inpixeltype != 'float':
        new_img = new_img.clone(inpixeltype)
    return new_img
787246
public void setPath(List<? extends S> path, Direction1D direction) {
		this.path = path == null || path.isEmpty() ? null : new ArrayList<>(path);
		this.firstSegmentDirection = detectFirstSegmentDirection(direction);
	}
347770
def _nav_naxis(self, viewer, axis, direction, msg=True):
        
        image = viewer.get_image()
        if image is None:
            return
        mddata = image.get_mddata()
        if len(mddata.shape) < (axis + 1):
            # image dimensions < 3D
            return

        naxispath = list(image.naxispath)
        axis_lim = mddata.shape[axis]
        m = axis - 2

        idx = naxispath[m]
        if direction == 'down':
            idx = (idx + 1) % axis_lim
        else:
            idx = idx - 1
            if idx < 0:
                idx = axis_lim - 1

        naxispath[m] = idx
        image.set_naxispath(naxispath)
625114
function(direction) {
			var self = this;
			var this_gallery = $('#' + self.scope.id);
			var this_gallery_item = this_gallery.find('.modaal-gallery-item');
			var this_gallery_total = this_gallery_item.length - 1;

			// if single item, don't proceed
			if ( this_gallery_total == 0 ) {
				return false;
			}

			var prev_btn = this_gallery.find('.modaal-gallery-prev'),
				next_btn = this_gallery.find('.modaal-gallery-next');

			var duration = 250;

			var new_img_w = 0,
				new_img_h = 0;

			// CB: Before image change
			var current_item = this_gallery.find( '.modaal-gallery-item.' + self.private_options.active_class ),
				incoming_item = ( direction == 'next' ? current_item.next( '.modaal-gallery-item' ) : current_item.prev( '.modaal-gallery-item' ) );
			self.options.before_image_change.call(self, current_item, incoming_item);

			// stop change if at start of end
			if ( direction == 'prev' && this_gallery.find('.gallery-item-0').hasClass('is_active') ) {
				return false;
			} else if ( direction == 'next' && this_gallery.find('.gallery-item-' + this_gallery_total).hasClass('is_active') ) {
				return false;
			}


			// lock dimensions
			current_item.stop().animate({
				opacity: 0
			}, duration, function(){
				// Move to appropriate image
				incoming_item.addClass('is_next').css({
					'position': 'absolute',
					'display': 'block',
					'opacity': 0
				});

				// Collect doc width
				var doc_width = $(document).width();
				var width_threshold = doc_width > 1140 ? 280 : 50;

				// start toggle to 'is_next'
				new_img_w = this_gallery.find('.modaal-gallery-item.is_next').width();
				new_img_h = this_gallery.find('.modaal-gallery-item.is_next').height();

				var new_natural_w = this_gallery.find('.modaal-gallery-item.is_next img').prop('naturalWidth');
				var new_natural_h = this_gallery.find('.modaal-gallery-item.is_next img').prop('naturalHeight');

				// if new image is wider than doc width
				if ( new_natural_w > (doc_width - width_threshold) ) {
					// set new width just below doc width
					new_img_w = doc_width - width_threshold;

					// Set temp widths so we can calulate the correct height;
					this_gallery.find('.modaal-gallery-item.is_next').css({ 'width': new_img_w });
					this_gallery.find('.modaal-gallery-item.is_next img').css({ 'width': new_img_w });

					// Set new height variable
					new_img_h = this_gallery.find('.modaal-gallery-item.is_next').find('img').height();
				} else {
					// new img is not wider than screen, so let's set the new dimensions
					new_img_w = new_natural_w;
					new_img_h = new_natural_h;
				}

				// resize gallery region
				this_gallery.find('.modaal-gallery-item-wrap').stop().animate({
					'width': new_img_w,
					'height': new_img_h
				}, duration, function() {
					// hide old active image
					current_item.removeClass(self.private_options.active_class + ' ' + self.options.gallery_active_class).removeAttr('style');
					current_item.find('img').removeAttr('style');

					// show new image
					incoming_item.addClass(self.private_options.active_class + ' ' + self.options.gallery_active_class).removeClass('is_next').css('position','');

					// animate in new image (now has the normal is_active class
					incoming_item.stop().animate({
						opacity: 1
					}, duration, function(){
						$(this).removeAttr('style').css({
							'width': '100%'
						});
						$(this).find('img').css('width', '100%');

						// remove dimension lock
						this_gallery.find('.modaal-gallery-item-wrap').removeAttr('style');

						// CB: After image change
						self.options.after_image_change.call( self, incoming_item );
					});

					// Focus on the new gallery item
					this_gallery.find('.modaal-gallery-item').removeAttr('tabindex');
					this_gallery.find('.modaal-gallery-item.' + self.private_options.active_class + '').attr('tabindex', '0').focus();

					// hide/show next/prev
					if ( this_gallery.find('.modaal-gallery-item.' + self.private_options.active_class).is('.gallery-item-0') ) {
						prev_btn.stop().animate({
							opacity: 0
						}, 150, function(){
							$(this).hide();
						});
					} else {
						prev_btn.stop().css({
							'display': 'block',
							'opacity': prev_btn.css('opacity')
						}).animate({
							opacity: 1
						}, 150);
					}
					if ( this_gallery.find('.modaal-gallery-item.' + self.private_options.active_class).is('.gallery-item-' + this_gallery_total) ) {
						next_btn.stop().animate({
							opacity: 0
						}, 150, function(){
							$(this).hide();
						});
					} else {
						next_btn.stop().css({
							'display': 'block',
							'opacity': prev_btn.css('opacity')
						}).animate({
							opacity: 1
						}, 150);
					}
				});
			});
		}
304854
private void applyDirection() {
		String imgUrl = "";
		switch (direction) {
			case NORTH:
				panVector = new Coordinate(0, 1);
				imgUrl = northImage;
				break;
			case EAST:
				panVector = new Coordinate(1, 0);
				imgUrl = eastImage;
				break;
			case SOUTH:
				panVector = new Coordinate(0, -1);
				imgUrl = southImage;
				break;
			case WEST:
				panVector = new Coordinate(-1, 0);
				imgUrl = westImage;
				break;
		}
		controller = new PanArrowController(map, panVector);
		image = new Image(getId());
		image.setHref(imgUrl);
		image.setStyle(style);
		image.setBounds(new Bbox(0, 0, getWidth(), getHeight()));
	}
129312
def new_image(cols, rows, *fill, &info_blk)
      self << Magick::Image.new(cols, rows, *fill, &info_blk)
    end
8382
def save_direction(self, rootpath, raw=False, as_int=False):
        
        self.save_array(self.direction, None, 'ang', rootpath, raw, as_int=as_int)
1018209
def set_image(self, img, bgr=False):
        ''''''
        if not self.is_alive():
            return
        if not hasattr(img, 'shape'):
            img = np.asarray(img[:,:])
        if bgr:
            img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
        self.in_queue.put(MPImageData(img))
654000
def set_data(self, vol, clim=None):
        
        # Check volume
        if not isinstance(vol, np.ndarray):
            raise ValueError('Volume visual needs a numpy array.')
        if not ((vol.ndim == 3) or (vol.ndim == 4 and vol.shape[-1] <= 4)):
            raise ValueError('Volume visual needs a 3D image.')
        
        # Handle clim
        if clim is not None:
            clim = np.array(clim, float)
            if not (clim.ndim == 1 and clim.size == 2):
                raise ValueError('clim must be a 2-element array-like')
            self._clim = tuple(clim)
        if self._clim is None:
            self._clim = vol.min(), vol.max()
        
        # Apply clim
        vol = np.array(vol, dtype='float32', copy=False)
        if self._clim[1] == self._clim[0]:
            if self._clim[0] != 0.:
                vol *= 1.0 / self._clim[0]
        else:
            vol -= self._clim[0]
            vol /= self._clim[1] - self._clim[0]
        
        # Apply to texture
        self._tex.set_data(vol)  # will be efficient if vol is same shape
        self.shared_program['u_shape'] = (vol.shape[2], vol.shape[1], 
                                          vol.shape[0])
        
        shape = vol.shape[:3]
        if self._vol_shape != shape:
            self._vol_shape = shape
            self._need_vertex_update = True
        self._vol_shape = shape
        
        # Get some stats
        self._kb_for_texture = np.prod(self._vol_shape) / 1024