• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python draw.line函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: drawBounds

def drawBounds(img, boxes):
    outimg = np.zeros((img.shape[0], img.shape[1], 3))
    outimg[:,:]=[255,255,255]
    outimg[~img]=[0,0,0]
    
    for box in boxes:
        if abs(box.x1-box.x2) < 10 or abs(box.y1-box.y2) < 15:
            continue
        
        rr,cc = line(box.x1, box.y1, box.x1, box.y2)
        try:
            outimg[cc,rr]=[255,0,0]
        except IndexError:
            pass
        rr,cc = line(box.x1, box.y1, box.x2, box.y1)
        try:
            outimg[cc,rr]=[255,0,0]
        except IndexError:
            pass
        rr,cc = line(box.x1, box.y2, box.x2, box.y2)
        try:
            outimg[cc,rr]=[255,0,0]
        except IndexError:
            pass
        rr,cc = line(box.x2, box.y1, box.x2, box.y2)
        try:
            outimg[cc,rr]=[255,0,0]
        except IndexError:
            pass
    return outimg
开发者ID:vzaguskin,项目名称:sampleprojects,代码行数:30,代码来源:digitrec.py


示例2: test_skeletonize_num_neighbours

def test_skeletonize_num_neighbours():
    # an empty image
    image = np.zeros((300, 300))

    # foreground object 1
    image[10:-10, 10:100] = 1
    image[-100:-10, 10:-10] = 1
    image[10:-10, -100:-10] = 1

    # foreground object 2
    rs, cs = draw.line(250, 150, 10, 280)
    for i in range(10):
        image[rs + i, cs] = 1
    rs, cs = draw.line(10, 150, 250, 280)
    for i in range(20):
        image[rs + i, cs] = 1

    # foreground object 3
    ir, ic = np.indices(image.shape)
    circle1 = (ic - 135)**2 + (ir - 150)**2 < 30**2
    circle2 = (ic - 135)**2 + (ir - 150)**2 < 20**2
    image[circle1] = 1
    image[circle2] = 0
    result = skeletonize_3d(image)

    # there should never be a 2x2 block of foreground pixels in a skeleton
    mask = np.array([[1,  1],
                     [1,  1]], np.uint8)
    blocks = ndi.correlate(result, mask, mode='constant')
    assert_(not np.any(blocks == 4))
开发者ID:AbdealiJK,项目名称:scikit-image,代码行数:30,代码来源:test_skeletonize_3d.py


示例3: setUp

    def setUp(self):
        # We create an artificial lf
        imgs = np.zeros((50,100,150), dtype=np.uint8)
        for i in range(50):
            for j in range(2):
                rr, cc = line(0, 10+j+i, 99, 10+j+i)
                imgs[i, rr, cc] = 75
            for j in range(5):
                rr, cc = line(0, 12+j+i, 99, 12+j+i)
                imgs[i, rr, cc] = 125
            for j in range(2):
                rr, cc = line(0, 17+j+i, 99, 17+j+i)
                imgs[i, rr, cc] = 75
            for j in range(5):
                rr, cc = line(0, 20+j+2*i, 99, 20+j+2*i)
                imgs[i, rr, cc] = 175
            for j in range(10):
                rr, cc = line(0, 35+j+2*i, 99, 35+j+2*i)
                imgs[i, rr, cc] = 250
            #ski.io.imsave("img_{i}.png".format(i=i), imgs[i])

        # We create epis out of it
        self.epis = np.zeros((100,50,150), dtype=np.uint8)
        for i in range(100):
            self.epis[i] = np.reshape(imgs[:,i], (50,150))
            #ski.io.imsave("epi_{i}.png".format(i=i), epis[i])
        self.epi = self.epis[25]
开发者ID:manuSrep,项目名称:DisneyDispPy,代码行数:27,代码来源:TestEdgeConfidence.py


示例4: add_rectangle

def add_rectangle(img, y0, x0, y1, x1, color="r", width=1):
    """Colors: 'r', 'g', 'b', 'w', 'k'"""
    im = np.copy(img)
    if im.ndim == 2:
        im = gray2rgb(im)
    max_val = 1
    if np.max(img) > 1:
        max_val = 255

    channel = 3  # Bogus value when color = 'w' or 'k'
    if color == "r":
        channel = 0
    if color == "g":
        channel = 1
    if color == "b":
        channel = 2

    for i in range(width):
        yy0 = y0 + i
        xx0 = x0 + i
        yy1 = y1 - i
        xx1 = x1 - i
        rr, cc = line(yy0, xx0, yy1, xx0)  # left
        im = paint_line(im, rr, cc, color, channel, max_val)
        rr, cc = line(yy1, xx0, yy1, xx1)  # bottom
        im = paint_line(im, rr, cc, color, channel, max_val)
        rr, cc = line(yy1, xx1, yy0, xx1)  # right
        im = paint_line(im, rr, cc, color, channel, max_val)
        rr, cc = line(yy0, xx1, yy0, xx0)  # top
        im = paint_line(im, rr, cc, color, channel, max_val)

    return im
开发者ID:robertmcanany,项目名称:coursera_image_processing_duke,代码行数:32,代码来源:inpaint_functions.py


示例5: houghLines

def houghLines(img):
    w,h = img.shape
    acc=[]
    for i in range(h):
        rr,cc = line(0, i, w-1, h-i-1)
        acc.append(np.sum(img[rr, cc]))
        #print acc[i]
    mi = np.argmax(acc)
    ret = np.zeros(img.shape, dtype=np.bool)
    rr,cc = line(0, mi, w-1, h-mi-1)
    ret[rr,cc]=True
    return ret
开发者ID:vzaguskin,项目名称:sampleprojects,代码行数:12,代码来源:digitrec.py


示例6: display_triangle

def display_triangle(im, tr, col):
    rows, cols = im.shape
    rr, cc = line(*map(int, tr[0]), *map(int, tr[1]))
    ind = logical_and.reduce((rr >= 0, rr < rows, cc >= 0, cc < cols))
    rr, cc = rr[ind], cc[ind]
    im[rr, cc] = col
    rr, cc = line(*map(int, tr[1]), *map(int, tr[2]))
    ind = logical_and.reduce((rr >= 0, rr < rows, cc >= 0, cc < cols))
    rr, cc = rr[ind], cc[ind]
    im[rr, cc] = col
    rr, cc = line(*map(int, tr[2]), *map(int, tr[0]))
    ind = logical_and.reduce((rr >= 0, rr < rows, cc >= 0, cc < cols))
    rr, cc = rr[ind], cc[ind]
    im[rr, cc] = col
开发者ID:lgarcin,项目名称:TIPE,代码行数:14,代码来源:my_own_private_hough.py


示例7: draw_keypoints

def draw_keypoints(img, keypoints, draw_prob):
    """Draws for each keypoint a circle (roughly matching the sigma of the scale)
    with a line for the orientation.
    Args:
        img    The image to which to add the keypoints (gets copied)
        keypoints The keypoints to draw
        draw_prob Probability of drawing a keypoint (the lower the less keypoints are drawn)
    Returns:
        Image with keypoints"""
    height, width = img.shape
    img = np.copy(img)

    # convert from grayscale image to RGB so that keypoints can be drawn in red
    img = img[:, :, np.newaxis]
    img = np.repeat(img, 3, axis=2)

    for (y, x), orientation, scale_idx, scale_size, kp_type in keypoints:
        if draw_prob < 1.0 and random.random() <= draw_prob:
            # draw the circle
            radius = int(scale_size)
            rr, cc = draw.circle_perimeter(y, x, radius, shape=img.shape)
            img[rr, cc, 0] = 1.0
            img[rr, cc, 1:] = 0

            # draw orientation
            orientation = util.quantize(orientation, [-135, -90, -45, 0, 45, 90, 135, 180])
            x_start = x
            y_start = y
            if orientation == 0:
                x_end = x + radius
                y_end = y
            elif orientation == 45:
                x_end = x + radius*(1/math.sqrt(2))
                y_end = y + radius*(1/math.sqrt(2))
            elif orientation == 90:
                x_end = x
                y_end = y + radius
            elif orientation == 135:
                x_end = x - radius*(1/math.sqrt(2))
                y_end = y - radius*(1/math.sqrt(2))
            elif orientation == 180:
                x_end = x - radius
                y_end = y
            elif orientation == -135:
                x_end = x - radius*(1/math.sqrt(2))
                y_end = y - radius*(1/math.sqrt(2))
            elif orientation == -90:
                x_end = x
                y_end = y - radius
            elif orientation == -45:
                x_end = x + radius*(1/math.sqrt(2))
                y_end = y - radius*(1/math.sqrt(2))
            x_end = np.clip(x_end, 0, width-1)
            y_end = np.clip(y_end, 0, height-1)
            rr, cc = draw.line(int(y_start), int(x_start), int(y_end), int(x_end))
            img[rr, cc, 0] = 1.0
            img[rr, cc, 1:] = 0
    img = np.clip(img, 0, 1.0)

    return img
开发者ID:aleju,项目名称:computer-vision-algorithms,代码行数:60,代码来源:sift.py


示例8: lines

def lines(end_points, shape):
    """
    Parameters
    ----------
    end_points : iterable
        coordinates of the starting point and the ending point of each
        line: e.g., [(start_x, start_y, end_x, end_y), (x1, y1, x2, y2)]
    shape : tuple
        Image shape which is used to determine the maximum extent of output
        pixel coordinates. Order is (rr, cc).

    Returns
    -------
    label_array : array
        Elements not inside any ROI are zero; elements inside each
        ROI are 1, 2, 3, corresponding to the order they are specified
        in coords. Order is (rr, cc).

    """
    label_array = np.zeros(shape, dtype=np.int64)
    label = 0
    for points in end_points:
        if len(points) != 4:
            raise ValueError("end points should have four number of"
                             " elements, giving starting co-ordinates,"
                             " ending co-ordinates for each line")
        rr, cc = line(np.max([points[0], 0]), np.max([points[1], 0]),
                      np.min([points[2], shape[0]-1]),
                      np.min([points[3], shape[1]-1]))
        label += 1
        label_array[rr, cc] = label
    return label_array
开发者ID:ericdill,项目名称:scikit-beam,代码行数:32,代码来源:roi.py


示例9: output

    def output(self):
        """Return the drawn line and the resulting scan.

        Returns
        -------
        line_image : (M, N) uint8 array, same shape as image
            An array of 0s with the scanned line set to 255.
            If the linewidth of the line tool is greater than 1,
            sets the values within the profiled polygon to 128.
        scan : (P,) or (P, 3) array of int or float
            The line scan values across the image.
        """
        end_points = self.line_tool.end_points
        line_image = np.zeros(self.image_viewer.image.shape[:2],
                              np.uint8)
        width = self.line_tool.linewidth
        if width > 1:
            rp, cp = measure.profile._line_profile_coordinates(
                *end_points[:, ::-1], linewidth=width)
            # the points are aliased, so create a polygon using the corners
            yp = np.rint(rp[[0, 0, -1, -1],[0, -1, -1, 0]]).astype(int)
            xp = np.rint(cp[[0, 0, -1, -1],[0, -1, -1, 0]]).astype(int)
            rp, cp = draw.polygon(yp, xp, line_image.shape)
            line_image[rp, cp] = 128
        (x1, y1), (x2, y2) = end_points.astype(int)
        rr, cc = draw.line(y1, x1, y2, x2)
        line_image[rr, cc] = 255
        return line_image, self.scan_data
开发者ID:SamHames,项目名称:scikit-image,代码行数:28,代码来源:lineprofile.py


示例10: polygon_perimeter

def polygon_perimeter(polygon, img_side=28):
    """
    Generate the perimeter of a polygon including the vertices.
    """
    # Create empty image
    img_shape = [img_side, img_side]
    img = np.zeros(img_shape, dtype=np.float32)

    prev_idx, cur_idx = -1, 0
    poly_len = len(polygon)
    while cur_idx < poly_len:
        # Get vertices
        prev_vertex = polygon[prev_idx]
        cur_vertex = polygon[cur_idx]

        # Get line pixels
        prev_rr, prev_cc = draw.line(
            prev_vertex[1], prev_vertex[0],
            cur_vertex[1], cur_vertex[0]
        )
        # Draw lines
        img[prev_rr, prev_cc] = 1.

        # Increment prev_idx and cur_idx
        prev_idx += 1
        cur_idx += 1

    return img
开发者ID:zhouleidcc,项目名称:polyrnn-pp,代码行数:28,代码来源:poly_utils.py


示例11: remove_deep_points

	def remove_deep_points(self, CIRCLE_RADIUS = 5, MINIMUM_BOUNDARY = 70):
		for point in self.POINTS_initial:
			segments = []
			circle_x, circle_y = circle_perimeter(point[0],point[1],CIRCLE_RADIUS)
			circle_points = np.array(list(sorted(set(zip(circle_x,circle_y)))))

			sortedpoints = np.empty([len(circle_points), 2], dtype=int)

			test1 = circle_points[circle_points[:,0] == point[0] - CIRCLE_RADIUS]
			start = len(test1)
			end = len_cpoints = len(sortedpoints)
			sortedpoints[0:start] = test1

			for x in xrange(point[0] - CIRCLE_RADIUS + 1, point[0] + CIRCLE_RADIUS):
				test1 = circle_points[circle_points[:,0] == x]
				testlen = len(test1)
				if x <= point[0]:
					sortedpoints[start:start+testlen/2] = test1[testlen/2:]
					sortedpoints[end-testlen/2:end] = test1[:testlen/2]
				else:
					sortedpoints[start:start+testlen/2] = test1[testlen/2:][::-1]
					sortedpoints[end-testlen/2:end] = test1[:testlen/2][::-1]
				start += testlen/2
				end -= testlen/2

			test1 = circle_points[circle_points[:,0] == point[0] + CIRCLE_RADIUS]
			sortedpoints[start:start + len(test1)] = test1[::-1]

			for c_perimeter in sortedpoints:
				segments.append(True)
				line_x, line_y = line(point[0], point[1], c_perimeter[0], c_perimeter[1])
				for line_points in zip(line_x,line_y)[1:]:
					# if original_image[line_points[0]][line_points[1]] != 0:
					if self.FOOTPRINT_cleaned_opening[line_points[0]][line_points[1]] != 0:
						segments[-1] = False
						break

			min_boundpoints = (MINIMUM_BOUNDARY / 360.0) * len_cpoints

			seg_sizes = []
			new_segment = True
			for segment in segments:
				if segment:
					if new_segment:
						seg_sizes.append(1)
						new_segment = False
					else:
						seg_sizes[-1] += 1
				else:
					new_segment = True

			if segments[0] == True and segments[-1] == True and len(seg_sizes) > 1:
				seg_sizes[0] = seg_sizes[0] + seg_sizes[-1]
				seg_sizes.pop()
			
			if(len(seg_sizes) == 0 or max(seg_sizes) < min_boundpoints):
				# boundary_image[point[0]][point[1]] = 0							#TAMA BANG TANGGALIN?

				if (point[0],point[1]) in self.POINTS_ordered:  ## IDENTIFY KUNG BAKIT NAGKA-ERRROR, EXAMPLE pt000120_merged4.py obj 1301
					self.POINTS_ordered.remove((point[0],point[1]))
开发者ID:ivancheesecake,项目名称:Bertud,代码行数:60,代码来源:Building.py


示例12: footprint_fitness_error

	def footprint_fitness_error(self, points):
		temp_footprint = np.zeros(self.FOOTPRINT_added_boundary.shape, dtype=np.uint8)
		len_points = len(points)

		for idx1 in xrange(0, len_points):
			rr,cc = line(points[idx1][0], points[idx1][1], points[idx1-1][0],points[idx1-1][1])
			temp_footprint[rr,cc] = 1

		temp_footprint = ndimage.binary_fill_holes(temp_footprint)
		temp_footprint = temp_footprint * 1

		rr,cc = np.nonzero(temp_footprint)
		
		#RATIO OF ZEROS AND ONES SA LOOB
		zero_counter = 0.0
		nonzero_counter = 0.0
		for point in zip(rr,cc):
			if self.FOOTPRINT_added_boundary[point[0]][point[1]] == 0:
				zero_counter += 1.0
			else:
				nonzero_counter += 1.0

		footprint_copy = copy.deepcopy(self.FOOTPRINT_added_boundary)
		footprint_copy[rr,cc] = 0

		nonzero = len(footprint_copy[footprint_copy != 0])
		total = (len(footprint_copy[footprint_copy == 0]) + nonzero) * 1.0

		return (nonzero / total) + (zero_counter / (nonzero_counter + zero_counter))
开发者ID:ivancheesecake,项目名称:Bertud,代码行数:29,代码来源:Building.py


示例13: draw_hough_line

def draw_hough_line(image, dist, theta, color=0):
    """
    Draws a line described by the hough transform to an image

    :param image: Image to draw on
    :param dist: Hough transform distance
    :param theta: Hough transform angle
    :param color: intensity to draw line
    """

    rows, cols = image.shape

    if abs(theta) < pi/4:
        # Find the x (col) intercepts
        x0 = int_(dist/cos(theta))
        x1 = int_(x0 - rows * sin(theta))
        intercepts = (0, x0, rows, x1)

    else:
        # Find the y (row) intercepts
        y0 = int_(dist/sin(theta))
        y1 = int_(y0 + cols * cos(theta))
        intercepts = (y0, 0, y1, cols)

    r, c = line(*intercepts)

    # Check to make sure each point stays in the image bounds and draw it
    for n in range(r.size):
        if r[n] >= 0 and c[n] >= 0:
            if r[n] < rows and c[n] < cols:
                image[r[n], c[n]] = color
开发者ID:danlopez00,项目名称:crop_predict,代码行数:31,代码来源:segmentation.py


示例14: display_edges

def display_edges(image, g, threshold):
    """Draw edges of a RAG on its image
 
    Returns a modified image with the edges drawn.Edges are drawn in green
    and nodes are drawn in yellow.
 
    Parameters
    ----------
    image : ndarray
        The image to be drawn on.
    g : RAG
        The Region Adjacency Graph.
    threshold : float
        Only edges in `g` below `threshold` are drawn.
 
    Returns:
    out: ndarray
        Image with the edges drawn.
    """
    image = image.copy()
    for edge in g.edges_iter():
        n1, n2 = edge
 
        r1, c1 = map(int, rag.node[n1]['centroid'])
        r2, c2 = map(int, rag.node[n2]['centroid'])
 
        line  = draw.line(r1, c1, r2, c2)
        circle = draw.circle(r1,c1,2)
 
        if g[n1][n2]['weight'] < threshold :
            image[line] = 0,1,0
        image[circle] = 1,1,0

    return image
开发者ID:adamsteer,项目名称:python-opencv-image-projection,代码行数:34,代码来源:scikit_im_segtest.py


示例15: line_image

def line_image(shape, lines):
    image = np.zeros(shape, dtype=bool)
    for end_points in lines:
        # hough lines returns (x, y) points, draw.line wants (row, columns)
        end_points = np.asarray(end_points)[:, ::-1]
        image[draw.line(*np.ravel(end_points))] = 1
    return image
开发者ID:A-0-,项目名称:scikit-image,代码行数:7,代码来源:probabilistic_hough.py


示例16: getRandomMotionBlurMask

def getRandomMotionBlurMask(extent):
    X = makeRandomWalkCurve(40, 20, 2)
    Y = smoothCurve(X, 20)
    Y = Y - np.mean(Y, 0)[None, :]
    Y = Y/np.max(Y, 0)
    Y = Y*extent
    theta = np.random.rand()*2*np.pi
    Y[:, 0] = Y[:, 0] + np.cos(theta)*np.linspace(0, extent, Y.shape[0])
    Y[:, 1] = Y[:, 1] + np.sin(theta)*np.linspace(0, extent, Y.shape[0])
    D = np.sum(Y**2, 1)[:, None]
    D = D + D.T - 2*Y.dot(Y.T)
    D[D < 0] = 0
    D = 0.5*(D + D.T)
    D = np.sqrt(D)
    Y = Y*extent/np.max(D)
    Y = Y - np.mean(Y, 0)[None, :]
    Y = Y - np.min(Y)
    I = np.zeros((extent, extent))
    for i in range(Y.shape[0]-1):
        c = [Y[i, 0], Y[i, 1], Y[i+1, 0], Y[i+1, 1]]
        c = [int(np.round(cc)) for cc in c]
        rr, cc = line(c[0], c[1], c[2], c[3])
        rr = [min(max(rrr, 0), extent-1) for rrr in rr]
        cc = [min(max(ccc, 0), extent-1) for ccc in cc]
        I[rr, cc] += 1.0
    I = I/np.sum(I)
    return (Y, I)
开发者ID:ctralie,项目名称:TUMTopoTimeSeries2016,代码行数:27,代码来源:SyntheticCurves.py


示例17: draw_tile_layout

def draw_tile_layout(image, tiles, color=1):
    """
    Draw the tile edges on a copy of image. Make a dot at each tile center.

    This is a utility for inspecting a tile layout, not a necessary step in
    the mosaic-building process.

    Parameters
    ----------
    image : array
    tiles : list
        list of pairs of slices, as generated by :func:`partition`
    color : int or array
        value to "draw" onto ``image`` at tile boundaries

    Returns
    -------
    annotated_image : array
    """
    annotated_image = copy.deepcopy(image)
    for y, x in tqdm(tiles):
        edges = (
            (y.start, x.start, y.stop - 1, x.start),
            (y.stop - 1, x.start, y.stop - 1, x.stop - 1),
            (y.stop - 1, x.stop - 1, y.start, x.stop - 1),
            (y.start, x.stop - 1, y.start, x.start),
        )
        for edge in edges:
            rr, cc = draw.line(*edge)
            annotated_image[rr, cc] = color  # tile edges
            annotated_image[_tile_center((y, x))] = color  # dot at center
    return annotated_image
开发者ID:danielballan,项目名称:photomosaic,代码行数:32,代码来源:photomosaic.py


示例18: removeChessboard

def removeChessboard(img):

    # Get the major lines in the image
    edges, dilatedEdges, (h, theta, d) = findLines(img)

    # Create image with ones to fill inn lines
    lines = np.ones(img.shape[:2])

    # Add lines to image as zeroes
    for _, angle, dist in zip(*hough_line_peaks(h, theta, d)):
        y0 = (dist - 0 * np.cos(angle)) / np.sin(angle)
        y1 = (dist - img.shape[1] * np.cos(angle)) / np.sin(angle)
        x, y = line(int(y1), 0, int(y0), img.shape[1] - 1)
        x = np.clip(x, 0, img.shape[0] - 1)
        y = np.clip(y, 0, img.shape[1] - 1)
        lines[x, y] = 0

    # Remove border edges from image with all edges
    w = 4
    edges = np.pad(edges[w:img.shape[0] - w, w:img.shape[1] - w], w, mode='constant')

    # Erode the lines bigger, such that they cover the original lines
    lines = erosion(lines, square(13))

    # Remove major lines and close shape paths
    removedChessboard = closing(edges * lines, square(8))

    return removedChessboard
开发者ID:niklasmh,项目名称:ntnu,代码行数:28,代码来源:task5a.py


示例19: _calculate_spacing

    def _calculate_spacing(self, im):
        h, w, d = im.shape
#         cw, ch = 600, 600
        cw, ch = 300, 300
        cx = (w - cw) / 2
        cy = (h - ch) / 2
        im = crop(im, cx, cy, cw, ch)
#         d = self.test_image.plotdata.get_data('imagedata000')
        d = grayspace(im)
#         d /= 255.
#         edges = filter.canny(d, sigma=3,
# #                              low_threshold=0,
# #                              high_threshold=
#                              )
#         edges = edges.astype('uint8')
#         edges = vsobel(d)
        edges = sobel(d)

        nim = zeros_like(edges)
        nim[edges > 0.1] = 255
        edges = nim
        self.test_image.set_image(edges)


        hspace, angles, dists = hough_line(edges)

        self.test_image.set_image(hspace, 1)

        _hspace, angles, dists = hough_peaks(hspace, angles, dists,

                                             )
        nim = zeros_like(edges)
        h, w, d = im.shape
        xs = []

        for ti, di in zip(angles, dists):
            ai = math.degrees(ti) + 180
            di = abs(int(round(di)))
            aa = abs(ai - 90) < 1
            bb = abs(ai - 270) < 1
            if aa or bb :
                adi = abs(di)
                coords = line(0, adi, h - 1, adi)
                nim[coords] = 200
                xs.append(di)

        self.test_image.set_image(nim, 2)
        xs.sort()
        # compute difference between each pair
        dxs = diff(xs)
        print dxs
        dd = sorted(dxs)[1:]
        print dd
        while len(dd):
            if std(dd) < 3:
                print dd
                return mean(dd) * 4  # each bar =0.25mm
            else:
                dd = dd[:-1]
开发者ID:UManPychron,项目名称:pychron,代码行数:59,代码来源:zoom_calibration.py


示例20: p7

def p7(img, hough_img, hough_threshold):

    hough_img[hough_img < hough_threshold] = 0

    img_height, img_width = thresholded_edge_img.shape

    theta_ind = np.linspace(-pi/2, pi/2, AMOUNT_OF_BINS_THETA)
    ro_ind, step = np.linspace(0, np.sqrt(img_height**2 + img_width**2), AMOUNT_OF_BINS_RO, retstep=True)

    theta_ar, ro_ar = hough_img.nonzero()

    plt.imshow(thresholded_edge_img)
    plt.autoscale(False)

    for line_num in xrange(len(theta_ar)):

        theta = theta_ind[theta_ar[line_num]]
        ro = ro_ind[ro_ar[line_num]]

        tang = sin(theta) / cos(theta)

        b = ro / cos(theta)

        y_pos = img_width*tang + b
        y_neg = b

        try:
            coords_one, coords_two = line(0, int(y_neg), img_width, int(y_pos))
        except:
            continue
        pairs = zip(coords_two, coords_one)

        line_started = False

        for r, c in pairs:

            #print line_started

            smaller_check = r >= 0 and c >= 0
            bigger_check = r < img_height and c < img_width

            if not (smaller_check and bigger_check):
                continue

            if thresholded_edge_img[r, c] and (not line_started):
                line_started = True
                thresholded_edge_img[r, c] = 10000
                plt.plot(c, r, 'ro')
                continue

            if (not thresholded_edge_img[r, c]) and line_started:
                line_started = False
                thresholded_edge_img[r, c] = 10000
                plt.plot(c, r, 'ro')
                continue

        plt.plot([0, img_width], [y_neg, y_pos], color='r', linestyle='-', linewidth=1)

    plt.show()
开发者ID:warmspringwinds,项目名称:jhu_cv_homeworks,代码行数:59,代码来源:task_2.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python draw.line_aa函数代码示例发布时间:2022-05-27
下一篇:
Python draw.ellipsoid函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap