Change shape of this region to match the given ``Region`` object
3916
def morphTo(self, region):
        
        if not region or not isinstance(region, Region):
            raise TypeError("morphTo expected a Region object")
        self.setROI(region)
        return self
478513
def border(self):
        

        border_array = self.bitmap - self.inner.bitmap
        return Region(border_array)
44639
def expand_region(tuple_of_s, a, b, start=0, stop=None):
    ''''''
    return tuple(expand_slice(s, a, b, start=start, stop=stop)
                 for s in tuple_of_s)
87450
function adjustRange(w, bisect) {
  var r0 = w.i0,
      r1 = w.i1 - 1,
      c = w.compare,
      d = w.data,
      n = d.length - 1;

  if (r0 > 0 && !c(d[r0], d[r0-1])) w.i0 = bisect.left(d, d[r0]);
  if (r1 < n && !c(d[r1], d[r1+1])) w.i1 = bisect.right(d, d[r1]);
}
938555
def _reorder_shape(input_shape, output=None):  # pylint: disable=invalid-name
  """"""
  if output is None:
    return input_shape
  return base.nested_map(output, lambda i: input_shape[i])
1235645
private static Region skew(Region t) {
    if (t.left.level == t.level) {
      t = rotateWithLeftChild(t);
    }
    return t;
  }
691015
def offset(self, location, dy=0):
        
        if not isinstance(location, Location):
            # Assume variables passed were dx,dy
            location = Location(location, dy)
        r = Region(self.x+location.x, self.y+location.y, self.w, self.h).clipRegionToScreen()
        if r is None:
            raise ValueError("Specified region is not visible on any screen")
            return None
        return r
1122410
def region(self, rect):
        
        box = (int(rect[0]), int(rect[1]), int(rect[0]) + int(rect[2]),
               int(rect[1]) + int(rect[3]))
        if box[2] > self.img.size[0] or box[3] > self.img.size[1]:
            raise errors.RectangleError("Region out-of-bounds")
        self.img = self.img.crop(box)
        return self
1056362
def region_from_segment(image, segment):
    """"""
    x, y, w, h = segment
    return image[y:y + h, x:x + w]
1223724
def change_attributes(self, bounds, radii, colors):
        
        
        self.n_cylinders = len(bounds)
        self.is_empty = True if self.n_cylinders == 0 else False
        
        if self.is_empty:
            self.bounds = bounds
            self.radii = radii
            self.colors = colors
            return # Do nothing
        
        # We pass the starting position 8 times, and each of these has
        # a mapping to the bounding box corner.
        self.bounds = np.array(bounds, dtype='float32')
        vertices, directions = self._gen_bounds(self.bounds) 
        
        self.radii = np.array(radii, dtype='float32')
        prim_radii = self._gen_radii(self.radii)

        self.colors = np.array(colors, dtype='uint8')
        prim_colors = self._gen_colors(self.colors)
       
        local = np.array([
           # First face -- front
          0.0, 0.0, 0.0,
          0.0, 1.0, 0.0, 
          1.0, 1.0, 0.0,
        
          0.0, 0.0, 0.0,
          1.0, 1.0, 0.0,
          1.0, 0.0, 0.0,

          # Second face -- back
          0.0, 0.0, 1.0,
          0.0, 1.0, 1.0, 
          1.0, 1.0, 1.0,

          0.0, 0.0, 1.0,
          1.0, 1.0, 1.0,
          1.0, 0.0, 1.0,
          
          # Third face -- left
          0.0, 0.0, 0.0,
          0.0, 0.0, 1.0, 
          0.0, 1.0, 1.0,

          0.0, 0.0, 0.0,
          0.0, 1.0, 1.0,
          0.0, 1.0, 0.0,

          # Fourth face -- right
          1.0, 0.0, 0.0,
          1.0, 0.0, 1.0, 
          1.0, 1.0, 1.0,

          1.0, 0.0, 0.0,
          1.0, 1.0, 1.0,
          1.0, 1.0, 0.0,

          # Fifth face -- up
          0.0, 1.0, 0.0,
          0.0, 1.0, 1.0,
          1.0, 1.0, 1.0,

          0.0, 1.0, 0.0,
          1.0, 1.0, 1.0,
          1.0, 1.0, 0.0,
          
          # Sixth face -- down
          0.0, 0.0, 0.0,
          0.0, 0.0, 1.0,
          1.0, 0.0, 1.0,

          0.0, 0.0, 0.0,
          1.0, 0.0, 1.0,
          1.0, 0.0, 0.0,
          
        ]).astype('float32')
        
        local = np.tile(local, self.n_cylinders)
        
        self._verts_vbo = VertexBuffer(vertices,GL_DYNAMIC_DRAW)
        self._directions_vbo = VertexBuffer(directions, GL_DYNAMIC_DRAW)
        
        self._local_vbo = VertexBuffer(local,GL_DYNAMIC_DRAW)
        self._color_vbo = VertexBuffer(prim_colors, GL_DYNAMIC_DRAW)
        self._radii_vbo = VertexBuffer(prim_radii, GL_DYNAMIC_DRAW)
238649
function reShape(object, radius, orientation, options, slicer) {
  options = options || {};
  var b = object.getBounds();
  // var s = util.size(b);
  var ar = Math.abs(radius);
  var si = util.sliceParams(orientation, radius, b);

  if (si.axis !== "z")
    throw new Error(
      'util.reShape error: CAG._toPlanePolytons only uses the "z" axis.  You must use the "z" axis for now.'
    );

  var cutplane = CSG$1.OrthoNormalBasis.GetCartesian(
    si.orthoNormalCartesian[0],
    si.orthoNormalCartesian[1]
  ).translate(si.cutDelta);

  var slice = object.sectionCut(cutplane);

  var first = util.axisApply(si.axis, function() {
    return si.positive ? 0 : ar;
  });

  var last = util.axisApply(si.axis, function() {
    return si.positive ? ar : 0;
  });

  var plane = si.positive ? cutplane.plane : cutplane.plane.flipped();

  var slices = slicer(first, last, slice);

  var delta = util
    .slices2poly(
      slices,
      Object.assign(options, {
        si: si
      }),
      si.axis
    )
    .color(options.color);

  var remainder = object.cutByPlane(plane);
  return union([
    options.unionOriginal ? object : remainder,
    delta.translate(si.moveDelta)
  ]);
}
820197
private static Region rotateWithLeftChild(Region k2) {
    Region k1 = k2.left;
    k2.left(k1.right);
    k1.right(k2);
    return k1;
  }
519696
def get_region_mask(z, delta, xy=None):
    """"""

    if xy is None:
        ix, iy = np.unravel_index(np.argmax(z), z.shape)
    else:
        ix, iy = xy

    mz = (z > z[ix, iy] - delta)
    labels = label(mz)[0]
    mz &= labels == labels[ix, iy]
    return mz
1200142
public void process(GrayU8 input , GrayU8 output ) {
		InputSanityCheck.checkSameShape(input, output);

		regionWidth = regionWidthLength.computeI(Math.min(input.width,input.height));

		if (input.width < regionWidth || input.height < regionWidth) {
			regionWidth = Math.min(input.width,input.height);
		}

		numPixels = regionWidth*regionWidth;

		int y0 = regionWidth/2;
		int y1 = input.height-(regionWidth-y0);
		int x0 = regionWidth/2;
		int x1 = input.width-(regionWidth-x0);

		final byte a,b;
		if( down ) {
			a = 1; b = 0;
		} else {
			a = 0; b = 1;
		}

		process(input, output, x0, y0, x1, y1, a, b);
	}
113929
def _find_matching_algo(self, region):
        """'"""
        for algo in self._info.algos:
            # Both start and size are required attributes.
            algoStart = int(algo.attrib['start'], base=0)
            algoSize = int(algo.attrib['size'], base=0)
            algoEnd = algoStart + algoSize - 1
        
            # Check if the region indicated by start..size fits within the algo.
            if (algoStart <= region.start <= algoEnd) and (algoStart <= region.end <= algoEnd):
                return algo
        return None
470221
def setImgShape(self, shape):
        '''
        
        '''
        self.img = type('Dummy', (object,), {})
#         if imgProcessor.ARRAYS_ORDER_IS_XY:
#             self.img.shape = shape[::-1]
#         else:
        self.img.shape = shape
196678
def _kernel_shape(self, input_shape):
    """"""
    kernel_size_iter = iter(self._kernel_size)
    return [self._filters if c == 'O' else
            input_shape[self._lhs_spec.index('C')] if c == 'I' else
            next(kernel_size_iter) for c in self._rhs_spec]