当前位置:网站首页>AttributeError: module ‘skimage. draw‘ has no attribute ‘circle‘
AttributeError: module ‘skimage. draw‘ has no attribute ‘circle‘
2022-06-22 10:06:00 【Evergreen cypress】
Project scenario and problem description :
Tips : Here is a brief introduction to the background of the project : I wrote a function myself , To draw a list of key positions in the image , A circle . The code originally passed the test , But I can't use it on the server today , Report errors :AttributeError: module 'skimage.draw' has no attribute 'circle'
Locate the error code location :
def showImageAndCoor(img, coords):
for coor in coords:
if coor[2] == -1:
pass
else:
# print(coor)
rr, cc = draw.circle(coor[1], coor[0], 4)
draw.set_color(img, [rr, cc], [255, 0, 0])
io.imshow(img)
io.show()
Cause analysis :
Tips : Fill in the analysis of the problem here : Mainly caused by version changes .
I reverse position , Find the specific location :rr, cc = draw.circle(coor[1], coor[0], 4) Find out circle Function cannot be connected . Find the source code of the package , Find out __init__.py and draw.py It's all gone from the file circle function :
My version is different , original scikit-image 0.15.0 Of draw.py There are also... In the document circle function , Currently in use scikit-image 0.19.3 Has deleted circle function .
This is a lower version :
Solution :
Tips : Fill in the specific solution to the problem here :
1. Since it is caused by the version upgrade , Of course, you can return the version , Install the old version :pip install scikit-image==0.15.0, This is a more earthy way .
2. Method 2 Well , We should have such a sense , It can't be upgraded and lose the ability to draw circles , therefore , We found the source code of the old version , You'll find that ,circle The essence of a function is an elliptic function .
def circle(r, c, radius, shape=None):
"""Generate coordinates of pixels within circle. Parameters ---------- r, c : double Centre coordinate of circle. radius : double Radius of circle. shape : tuple, optional Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for circles that exceed the image size. If None, the full extent of the circle is used. Returns ------- rr, cc : ndarray of int Pixel coordinates of circle. May be used to directly index into an array, e.g. ``img[rr, cc] = 1``. Examples -------- >>> from skimage.draw import circle >>> img = np.zeros((10, 10), dtype=np.uint8) >>> rr, cc = circle(4, 4, 5) >>> img[rr, cc] = 1 >>> img array([[0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8) """
return ellipse(r, c, radius, radius, shape)
It looks like a lot of content , Are all notes. , There is only one useful sentence :return ellipse(r, c, radius, radius, shape).
therefore , We modify the code :draw.circle(r, c, radius, shape=None) by draw.ellipse(r, c, radius,radius, shape=None). The parameters of the function are also changed from the original 4 A into 5 individual .
radius,radius = a, b
A circle is also a special ellipse , Round a=b.
The modified code :rr, cc = draw.ellipse(coor[1], coor[0], 4, 4)
def showImageAndCoor(img, coords):
for coor in coords:
if coor[2] == -1:
pass
else:
# print(coor)
rr, cc = draw.ellipse(coor[1], coor[0], 4, 4)
draw.set_color(img, [rr, cc], [255, 0, 0])
io.imshow(img)
io.show()
It works perfectly :
边栏推荐
- day260:只出现一次的数字 III
- 搭建OpenPGP Key server
- 【无标题】#修复日志#
- 中年失业是一种什么体验
- Tiktok practice ~ personal Center
- The ruby code in logstash converts the @timestamp timestamp format
- 一口气读懂 IT发展史
- 6-8 integer array shift
- Attack and defense world web practice area beginner level
- Ctfshow web realizes killing through one question
猜你喜欢

Bloom filter optimization - crimsondb series of papers (I)

【无标题】#修复日志#

Basic knowledge of AI Internet of things | community essay solicitation

The future of Dao: an organization primitive for building Web3

VS2022连接sqlserver数据库教程

IPO配置指南

快速掌握 ASP.NET 身份认证框架 Identity - 登录与登出

扎克伯格最新VR原型机来了,要让人混淆虚拟与现实的那种

HMS core news industry solution: let technology add humanistic temperature

信息系统项目典型生命周期模型
随机推荐
6-7 average the surrounding elements of a two-dimensional array
软件工程 大题
快速掌握 ASP.NET 身份认证框架 Identity - 登录与登出
C语言编写一个双向链表
Kali uses the command ifconfig to query the solution that the IP address is always 127.0.0.1
CISP教材更新:2019年八大知识域新知识体系介绍
Record a time when Kali encounters vmtools button gray install vmtools
TCP Congestion Identification
Error in PHP installation of Pagoda: libcares so. 2: cannot open shared object file: No such file or directory
Aliyun OS上证书签发过程(certbot)
Quickly master asp Net authentication framework identity - login and logout
Catch up with this big guy
The ruby code in logstash converts the @timestamp timestamp format
神经网络训练trick总结
《网络安全等级保护基本要求》(GBT 22239-2019)标准解读
Read the history of it development in one breath
秋招秘籍B
加密市场暴跌,stETH引发新一轮担忧
Zuckerberg's latest VR prototype is coming. It is necessary to confuse virtual reality with reality
西电AI专业排名超清北,南大蝉联全国第一 | 2022软科中国大学专业排名