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

Python transform.hough_ellipse函数代码示例

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

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



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

示例1: test_hough_ellipse_non_zero_angle

def test_hough_ellipse_non_zero_angle():
    img = np.zeros((20, 20), dtype=int)
    a = 6
    b = 9
    x0 = 10
    y0 = 10
    angle = np.pi / 1.35
    rr, cc = ellipse_perimeter(x0, x0, b, a, orientation=angle)
    img[rr, cc] = 1
    result = tf.hough_ellipse(img, threshold=15, accuracy=3)
    assert_almost_equal(result[0][0] / 100., x0 / 100., decimal=1)
    assert_almost_equal(result[0][1] / 100., y0 / 100., decimal=1)
    assert_almost_equal(result[0][2] / 100., b / 100., decimal=1)
    assert_almost_equal(result[0][3] / 100., a / 100., decimal=1)
    assert_almost_equal(result[0][4], angle, decimal=1)
开发者ID:Autodidact24,项目名称:scikit-image,代码行数:15,代码来源:test_hough_transform.py


示例2: test_hough_ellipse_zero_angle

def test_hough_ellipse_zero_angle():
    img = np.zeros((25, 25), dtype=int)
    a = 6
    b = 8
    x0 = 12
    y0 = 12
    angle = 0
    rr, cc = ellipse_perimeter(x0, x0, b, a)
    img[rr, cc] = 1
    result = tf.hough_ellipse(img, threshold=9)
    assert_equal(result[0][0], x0)
    assert_equal(result[0][1], y0)
    assert_almost_equal(result[0][2], b, decimal=1)
    assert_almost_equal(result[0][3], a, decimal=1)
    assert_equal(result[0][4], angle)
开发者ID:Autodidact24,项目名称:scikit-image,代码行数:15,代码来源:test_hough_transform.py


示例3: test_hough_ellipse_non_zero_negangle4

def test_hough_ellipse_non_zero_negangle4():
    # ry < rx, angle in [-pi:-3pi/4]
    img = np.zeros((30, 24), dtype=int)
    rx = 12
    ry = 6
    x0 = 10
    y0 = 15
    angle = -np.pi / 1.35 - np.pi
    rr, cc = ellipse_perimeter(y0, x0, ry, rx, orientation=angle)
    img[rr, cc] = 1
    result = tf.hough_ellipse(img, threshold=15, accuracy=3)
    result.sort(order="accumulator")
    best = result[-1]
    # Check if I re-draw the ellipse, points are the same!
    # ie check API compatibility between hough_ellipse and ellipse_perimeter
    rr2, cc2 = ellipse_perimeter(y0, x0, int(best[3]), int(best[4]), orientation=best[5])
    assert_equal(rr, rr2)
    assert_equal(cc, cc2)
开发者ID:jjhelmus,项目名称:scikit-image,代码行数:18,代码来源:test_hough_transform.py


示例4: extract_hough_ellipse

def extract_hough_ellipse(image_gray):
    edges = canny(image_gray, sigma=3.0, low_threshold=0.55, high_threshold=0.8)

    # Perform a Hough Transform
    # The accuracy corresponds to the bin size of a major axis.
    # The value is chosen in order to get a single high accumulator.
    # The threshold eliminates low accumulators
    print 'hough_ellipse'
    result = hough_ellipse(edges, accuracy=20, threshold=250,
                           min_size=100, max_size=120)
    result.sort(order='accumulator')
    print len(result)

    # Estimated parameters for the ellipse
    best = result[-1]
    yc = int(best[1])
    xc = int(best[2])
    a = int(best[3])
    b = int(best[4])
    orientation = best[5]
开发者ID:daprastya,项目名称:csipb-jamu-prj,代码行数:20,代码来源:extract_mix.py


示例5: main

def main():
    # Load picture, convert to grayscale and detect edges
    camera = cv2.VideoCapture(0)
    (ret, img) = camera.read()
    cv2.imshow("blah",img)
    gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
    cp = gray.copy()
    edges = cv2.Canny(gray,50,150,apertureSize = 3)
    print "hi"
    edges = img_as_float(edges)
    print "hi"

    # Perform a Hough Transform
    # The accuracy corresponds to the bin size of a major axis.
    # The value is chosen in order to get a single high accumulator.
    # The threshold eliminates low accumulators
    result = hough_ellipse(edges, accuracy=20, threshold=250, min_size=100, max_size=120)
    print "hi"
    result.sort(order='accumulator')
    print result

    # Estimated parameters for the ellipse
    if (len(result) > 0):
        print "apple"
        best = list(result[-1])
        yc, xc, a, b = [int(round(x)) for x in best[1:5]]
        orientation = best[5]

        # Draw the ellipse on the original image
        cy, cx = ellipse_perimeter(yc, xc, a, b, orientation)
        image_rgb[cy, cx] = (0, 0, 255)
        # Draw the edge (white) and the resulting ellipse (red)
        edges = color.gray2rgb(edges)
        edges[cy, cx] = (25, 0, 255)

    # fig2, (ax1, ax2) = plt.subplots(ncols=2, nrows=1, figsize=(8, 4), sharex=True,
    #                                 sharey=True,
    #                                 subplot_kw={'adjustable':'box-forced'})

    # ax1.set_title('Original picture')
    cv2.imshow("apple",img_as_ubyte(edges))
开发者ID:jburns20,项目名称:humanoids-project,代码行数:41,代码来源:tttt.py


示例6: test_hough_ellipse_zero_angle

def test_hough_ellipse_zero_angle():
    img = np.zeros((25, 25), dtype=int)
    rx = 6
    ry = 8
    x0 = 12
    y0 = 15
    angle = 0
    rr, cc = ellipse_perimeter(y0, x0, ry, rx)
    img[rr, cc] = 1
    result = tf.hough_ellipse(img, threshold=9)
    best = result[-1]
    assert_equal(best[1], y0)
    assert_equal(best[2], x0)
    assert_almost_equal(best[3], ry, decimal=1)
    assert_almost_equal(best[4], rx, decimal=1)
    assert_equal(best[5], angle)
    # Check if I re-draw the ellipse, points are the same!
    # ie check API compatibility between hough_ellipse and ellipse_perimeter
    rr2, cc2 = ellipse_perimeter(y0, x0, int(best[3]), int(best[4]), orientation=best[5])
    assert_equal(rr, rr2)
    assert_equal(cc, cc2)
开发者ID:jjhelmus,项目名称:scikit-image,代码行数:21,代码来源:test_hough_transform.py


示例7: test_hough_ellipse_non_zero_posangle2

def test_hough_ellipse_non_zero_posangle2():
    # ry < rx, angle in [0:pi/2]
    img = np.zeros((30, 24), dtype=int)
    rx = 12
    ry = 6
    x0 = 10
    y0 = 15
    angle = np.pi / 1.35
    rr, cc = ellipse_perimeter(y0, x0, ry, rx, orientation=angle)
    img[rr, cc] = 1
    result = tf.hough_ellipse(img, threshold=15, accuracy=3)
    result.sort(order="accumulator")
    best = result[-1]
    assert_almost_equal(best[1] / 100.0, y0 / 100.0, decimal=1)
    assert_almost_equal(best[2] / 100.0, x0 / 100.0, decimal=1)
    assert_almost_equal(best[3] / 10.0, ry / 10.0, decimal=1)
    assert_almost_equal(best[4] / 100.0, rx / 100.0, decimal=1)
    assert_almost_equal(best[5], angle, decimal=1)
    # Check if I re-draw the ellipse, points are the same!
    # ie check API compatibility between hough_ellipse and ellipse_perimeter
    rr2, cc2 = ellipse_perimeter(y0, x0, int(best[3]), int(best[4]), orientation=best[5])
    assert_equal(rr, rr2)
    assert_equal(cc, cc2)
开发者ID:jjhelmus,项目名称:scikit-image,代码行数:23,代码来源:test_hough_transform.py


示例8: test_canny

def test_canny():
    data = np.memmap("E:\\guts_tracking\\data\\fish202_aligned_masked_8bit_150x200x440.raw", dtype='uint8', shape=(440,200,150)).copy()

    data_slice = data[150]

    sigmas = np.linspace(1,5,5)
    low_thresholds = np.linspace(0.1,0.55,5)

    thresholds = np.linspace(5,10,5)
    accuracies = np.linspace(5,25,5)

    edges = feature.canny(data_slice, sigma=3.0, low_threshold=0.4, high_threshold=0.8)
    ellipses = hough_ellipse(edges, threshold=4, accuracy=1, min_size=15, max_size=300)
    print ellipses
    ellipses.sort(order='accumulator')
    new_slice = draw_esllipse(edges, ellipses)
    plt.imshow(new_slice, cmap='gray')


    #fig, axes = plt.subplots(5, 5)

    #for i,sigma in enumerate(sigmas):
        #for j,low_threshold in enumerate(low_thresholds):
    # for i,threshold in enumerate(thresholds):
    #     for j,accuracy in enumerate(accuracies):
    #         edges = feature.canny(data_slice, sigma=3.0, low_threshold=0.4, high_threshold=0.8)
    #         ellipses = hough_ellipse(edges, threshold=threshold, accuracy=accuracy, min_size=15, max_size=300)
    #         ellipses.sort(order='accumulator')
    #         new_slice = draw_esllipse(data_slice, ellipses)
    #
    #         axes[i,j].imshow(new_slice, cmap='gray')
    #         #axes[i,j].set_title('sigma=%f, low_th=%f' % (sigma, low_threshold))
    #         axes[i,j].set_title('threshold=%f, accuracy=%f' % (threshold, accuracy))
    #         axes[i,j].get_xaxis().set_visible(False)
    #         axes[i,j].get_yaxis().set_visible(False)

    plt.show()
开发者ID:rshkarin,项目名称:guts-tracking,代码行数:37,代码来源:main.py


示例9: img_as_float

# Load picture, convert to grayscale and detect edges
camera = cv2.VideoCapture(0)
(ret, img_frame) = camera.read()

time.sleep(1)
(ret, img_frame) = camera.read()
cv2.imshow("other", img_frame) 
image_rgb = img_as_float(img_frame)
image_gray = color.rgb2gray(image_rgb)
edges = canny(image_gray, sigma=2.0,
              low_threshold=0.55, high_threshold=0.8)
# Perform a Hough Transform
# The accuracy corresponds to the bin size of a major axis.
# The value is chosen in order to get a single high accumulator.
# The threshold eliminates low accumulators
result = hough_ellipse(edges, accuracy=20, threshold=250,
                       min_size=100, max_size=120)
result.sort(order='accumulator')

# Estimated parameters for the ellipse
best = list(result[-1])
yc, xc, a, b = [int(round(x)) for x in best[1:5]]
orientation = best[5]

# Draw the ellipse on the original image
cy, cx = ellipse_perimeter(yc, xc, a, b, orientation)
image_rgb[cy, cx] = (0, 0, 255)
# Draw the edge (white) and the resulting ellipse (red)
edges = color.gray2rgb(edges)
edges[cy, cx] = (250, 0, 0)

fig2, (ax1, ax2) = plt.subplots(ncols=2, nrows=1, figsize=(8, 4), sharex=True,
开发者ID:jburns20,项目名称:humanoids-project,代码行数:32,代码来源:asfasd.py


示例10: get_ellipses

def get_ellipses(data):
    edges = feature.canny(data, sigma=3.0, low_threshold=0.55, high_threshold=0.8)
    result = hough_ellipse(edges, threshold=4, accuracy=5, min_size=20, max_size=300)
    result.sort(order='accumulator')
    return result
开发者ID:rshkarin,项目名称:guts-tracking,代码行数:5,代码来源:main.py


示例11: test_hough_ellipse_all_black_img

def test_hough_ellipse_all_black_img():
    assert(transform.hough_ellipse(np.zeros((100, 100))).shape == (0, 6))
开发者ID:Cadair,项目名称:scikit-image,代码行数:2,代码来源:test_hough_transform.py


示例12: hough_ellipse

from skimage import data, filter, color
from skimage.transform import hough_ellipse
from skimage.draw import ellipse_perimeter

# Load picture, convert to grayscale and detect edges
image_rgb = data.load('coffee.png')[0:220, 100:450]
image_gray = color.rgb2gray(image_rgb)
edges = filter.canny(image_gray, sigma=2.0,
                     low_threshold=0.55, high_threshold=0.8)

# Perform a Hough Transform
# The accuracy corresponds to the bin size of a major axis.
# The value is chosen in order to get a single high accumulator.
# The threshold eliminates low accumulators
accum = hough_ellipse(edges, accuracy=10, threshold=170, min_size=50)
accum.sort(key=lambda x:x[5])
# Estimated parameters for the ellipse
center_y = int(accum[-1][0])
center_x = int(accum[-1][1])
xradius = int(accum[-1][2])
yradius = int(accum[-1][3])
angle = np.pi - accum[-1][4]

# Draw the ellipse on the original image
cx, cy = ellipse_perimeter(center_y, center_x,
                           yradius, xradius, orientation=angle)
image_rgb[cy, cx] = (0, 0, 1)
# Draw the edge (white) and the resulting ellipse (red)
edges = color.gray2rgb(edges)
edges[cy, cx] = (250, 0, 0)
开发者ID:Autodidact24,项目名称:scikit-image,代码行数:30,代码来源:plot_circular_elliptical_hough_transform.py


示例13: canny

# Load picture, convert to grayscale and detect edges
# image_rgb = data.coffee()[0:220, 160:420]
image_rgb = im
# image_gray = color.rgb2gray(image_rgb)
image_gray = image_gray
# edges = canny(image_gray, sigma=2.0, low_threshold=0.55, high_threshold=0.8)
edges = canny(image_gray, sigma=0.1)
# edges = canny(image_gray)
plt.imshow(edges)
plt.show()
# Perform a Hough Transform
# The accuracy corresponds to the bin size of a major axis.
# The value is chosen in order to get a single high accumulator.
# The threshold eliminates low accumulators
# result = hough_ellipse(edges, accuracy=20, threshold=250, min_size=10, max_size=20)
result = hough_ellipse(edges, threshold=250, min_size=10, max_size=20)
result.sort(order='accumulator')

# Estimated parameters for the ellipse
best = list(result[-1])
yc, xc, a, b = [int(round(x)) for x in best[1:5]]
orientation = best[5]

# Draw the ellipse on the original image
cy, cx = ellipse_perimeter(yc, xc, a, b, orientation)
image_rgb[cy, cx] = (0, 0, 255)
# Draw the edge (white) and the resulting ellipse (red)
edges = color.gray2rgb(edges)
edges[cy, cx] = (250, 0, 0)

fig2, (ax1, ax2) = plt.subplots(ncols=2, nrows=1, figsize=(8, 4), sharex=True,
开发者ID:PestBusters,项目名称:WheatClassifier,代码行数:31,代码来源:elliptical.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python transform.hough_line函数代码示例发布时间:2022-05-27
下一篇:
Python transform.hough_circle函数代码示例发布时间: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