我试图使用Python下载网站的HTML源代码,但我收到此错误.
回溯(最近通话最后一个):
文件"C:\用户\ Sergio.Tapia \文档\的NetBeansProjects\DICParser的\ src\WebDownload.py",3号线,在文件=了urllib.urlopen(" HTTP://www.python .ORG ")AttributeError的:'模块’对象没有属性'的urlopen’
我在这里以下指南:http://www.boddie.org.uk/python/HTML.html
Traceback (most recent call last):
File "C:\Users\Sergio.Tapia\Documents\NetBeansProjects\DICParser\src\WebDownload.py", line 3, in <module>
file = urllib.urlopen("http://www.python.org")
AttributeError: 'module' object has no attribute 'urlopen'
Run Code Online (Sandbox Code Playgroud)
我正在使用Python 3,感谢您的帮助!
我正在开发一个应用程序来检测病变区域,为此我使用抓取来检测 ROI 并从图像中删除背景。但是,在某些图像中,它运行不佳。他最终没有很好地确定感兴趣区域的边界。分水岭可以更好地识别此类工作的边缘,但是我在从抓地到分水岭的过渡过程中遇到了困难。在处理抓取之前,用户使用 touchevent 在感兴趣的图像(伤口区域)周围标记一个矩形,以方便算法的工作。如下图。

但是,使用其他伤口图像,分割效果不佳,显示出 ROI 检测的缺陷。
在应用程序中使用抓取的图像
在桌面中使用分水岭的图像

这是代码:
private fun extractForegroundFromBackground(coordinates: Coordinates, currentPhotoPath: String): String {
// TODO: Provide complex object that has both path and extension
val width = bitmap?.getWidth()!!
val height = bitmap?.getHeight()!!
val rgba = Mat()
val gray_mat = Mat()
val threeChannel = Mat()
Utils.bitmapToMat(bitmap, gray_mat)
cvtColor(gray_mat, rgba, COLOR_RGBA2RGB)
cvtColor(rgba, threeChannel, COLOR_RGB2GRAY)
threshold(threeChannel, threeChannel, 100.0, 255.0, THRESH_OTSU)
val rect = Rect(coordinates.first, coordinates.second)
val fg = Mat(rect.size(), CvType.CV_8U)
erode(threeChannel, fg, Mat(), Point(-1.0, -1.0), 10)
val …Run Code Online (Sandbox Code Playgroud) 我使用mahotas将图片加载到一个numpy数组中.
import mahotas
img = mahotas.imread('test.jpg')
Run Code Online (Sandbox Code Playgroud)
每个像素img由RGB值数组表示:
img[1,1] = [254, 200, 189]
Run Code Online (Sandbox Code Playgroud)
我在一个轴上制作了R值的3D散点图,在第二个轴上制作了G值,在第三个轴上制作了B值.这没问题:
fig = plt.figure()
ax = fig.add_subplot(111, projection = '3d')
for i in range(1,img.shape[1]+1):
xs = img[i,1][0]
ys = img[i,1][1]
zs = img[i,1][2]
ax.scatter(xs, ys, zs, c='0.5', marker='o')
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
plt.show()
Run Code Online (Sandbox Code Playgroud)
(我只是暂时绘制图像的第一列).
如何根据每个图像像素的颜色为每个散点图点着色?即我想我想用RGB值对点进行着色,但我不确定这是否可行?
我将图片的颜色转换为 LAB,如下所示:
import cv2
imbgr=cv2.imread('photo.jpg')
imlab=cv2.cvtColor(imbgr,cv2.COLOR_BGR2LAB)
cv2.imwrite('lab.jpg',imlab)
Run Code Online (Sandbox Code Playgroud)
用 imlab [x, y] 返回像素,如何用这些值绘制图形?
python ×3
opencv ×2
python-3.x ×2
histogram ×1
image ×1
java ×1
kotlin ×1
matplotlib ×1
mobile ×1
scatter-plot ×1
urllib ×1