我正在寻找一种从二进制图像(只有黑色和白色像素)创建类似 svg 的路径的方法。图像本身将是一个形状不规则的斑点,其中可能有孔。
如果没有洞,我只需要一个边界路径来重新创建斑点的边界。当斑点中有洞时,我可以使用额外的路径(我猜,单独一条路径无法重新创建它)。最后我只需要知道哪条路径是外部路径,哪些是洞。
我已经找到了这些:
另外我需要检测漏洞。结果是多边形还是路径对我来说并不重要。我只需要精度足够高的点,使曲线保持弯曲:)
如果有人有一个想法甚至一些进一步的来源,那就太好了。
PS:如果这有什么区别的话,我正在使用canvas和javascript(fabricJS)。
javascript canvas image-processing edge-detection html5-canvas
我正在使用Aforge对图像进行边缘检测,如何获得检测到的边缘点的x,y?除了循环通过图像位图的明显方式.
这是Aforge样本的代码,但我如何获得边缘点?
// On Filters->Sobel edge detector
private void sobelEdgesFiltersItem_Click( object sender, System.EventArgs e )
{
// save original image
Bitmap originalImage = sourceImage;
// get grayscale image
sourceImage = Grayscale.CommonAlgorithms.RMY.Apply( sourceImage );
// apply edge filter
ApplyFilter( new SobelEdgeDetector( ) );
// delete grayscale image and restore original
sourceImage.Dispose( );
sourceImage = originalImage;
// this is the part where the source image is now edge detected. How to get the x,y for //each point of the edge?
sobelEdgesFiltersItem.Checked = …Run Code Online (Sandbox Code Playgroud) 我有一个RGB图像.我扫描了图像.因此,图像占据了A4尺寸的一小部分.
我想找到图像的边框并裁剪它.我可以使用像'Sobel'等边缘检测算子,但它们会检测图像中存在的所有边缘.我想要的只是图像的边界.此外,许多边缘检测功能(包括"bwbound")仅适用于二进制或灰度图像.我的图像是RGB.
我尝试使用'imcrop',但这更像是交互式裁剪.我很想自动这样做.
上传测试图像: 
我需要在图像上应用这两个内核.
+1 0 0 0 0 0 0 0 -1
和0 0 +1 0 0 0 -1 0 0
然后组合两个输出图像.但我不知道如何将循环/应用滤镜写入一般的图像.
我试图使用OpenCV计算屏幕截图中的标签数量.我首先裁剪我的图像以限制镀铬标签.然后我使用边缘检测,Canny算法来查找chrome中的边缘.然后我使用Houghlines查找选项卡的数量,但我没有通过Houghlines获得所需的输出.下面是我的代码和输出.
import cv2
import numpy as np
import math
from matplotlib import pyplot as plt
img = cv2.imread('1.png')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray,50,200,apertureSize = 3)
cv2.imwrite('result.png',edges)
lines = cv2.HoughLines(edges,1,np.pi/180,50)
for rho,theta in lines[0]:
slope = 180*theta*1.0/np.pi
if slope > 110 and slope <148: # for identifying chrome tab angle (right slope line of each tab)
a = np.cos(theta)
b = np.sin(theta)
x0 = a*rho
y0 = b*rho
x1 = int(x0 + 1000*(-b))
y1 = int(y0 + 1000*(a))
x2 = …Run Code Online (Sandbox Code Playgroud) python opencv image-processing edge-detection hough-transform
我正在寻找一种算法,可以对仅包含两个不同RGB值的理想图像进行外部和内部轮廓检测。
下面是我要处理的图像的典型示例(第一个),下一个图像是我自己显示的图像,该图像显示了我期望的结果。
最后一个是从通过在现有的演示软件制作OpenCV的坎尼检测结果OpenCV的演示软件。
canny算法不能令人满意,因为它使形状(尤其是角)变得过于平滑。
是否有任何优雅的算法可以提供与第二张图片相同的结果?
我正在尝试设计一个类似于camscanner的应用程序.为此,我必须拍摄一张图片然后找到该文件.我从这里描述的代码开始 - http://opencvpython.blogspot.in/2012/06/sudoku-solver-part-2.html
我发现轮廓和最大面积的矩形轮廓应该是必需的文件.对于每个轮廓,我发现一个近似封闭的PolyDP.在所有大小为4的polyDP中,具有最大面积的polyDP应该是所需的文档.但是,这种方法不起作用.
我尝试用最大面积打印轮廓,这导致了这个(轮廓里面的字母'C')

码:
img = cv2.imread('bounce.jpeg')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray,(5,5),0)
thresh = cv2.adaptiveThreshold(gray,255,1,1,11,2)
_, contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
def biggestRectangle(contours):
biggest = None
max_area = 0
indexReturn = -1
for index in range(len(contours)):
i = contours[index]
area = cv2.contourArea(i)
if area > 100:
peri = cv2.arcLength(i,True)
approx = cv2.approxPolyDP(i,0.1*peri,True)
if area > max_area: #and len(approx)==4:
biggest = approx
max_area = area
indexReturn = index
return indexReturn
indexReturn = biggestRectangle(contours)
cv2.imwrite('hola.png',cv2.drawContours(img, contours, indexReturn, …Run Code Online (Sandbox Code Playgroud) 我想请您提供有关线宽定义的帮助。我有二进制曲线。我需要找出曲线骨架的每个点到法线方向上的线边缘的距离。因此,我首先计算了二进制曲线的骨架。因此,对于骨骼的每个像素,我都计算了法线。图中描绘了这种情况,显示了每个像素的骨架和法线向量图。在这一点上,我不知道如何计算每个骨架像素在法线方向上弯曲边缘的距离。实际上,我需要计算从骨架像素到法线方向上线条边缘的像素数量(逻辑1)。这意味着我需要获取向量,其中包含每个骨架点的距离。在此先感谢您的帮助。
用法线生成骨架的代码:
clc;clear all;close all
i=rgb2gray(imread('Bin_Lines.bmp'));
BW=bwskel(logical(i));
% BW = image sceleton
Orientations = skeletonOrientation(BW,5); %5x5 box
Onormal = Orientations+90; %easier to view normals
Onr = sind(Onormal); %vv
Onc = cosd(Onormal); %uu
[r,c] = find(BW); %row/cols
idx = find(BW); %Linear indices into Onr/Onc
figure()
imshow(BW,[]);
%Plotting normals of binary skeleton
hold on
quiver(c,r,-Onc(idx),Onr(idx));
Run Code Online (Sandbox Code Playgroud)
这是我存储源代码和二进制行图像的链接:
https://www.dropbox.com/sh/j84ep3k1604hsza/AABm92TUBX6yIp29Gc0v_PHHa?dl=0
![]()
matlab image-processing computer-vision edge-detection image-segmentation
edge-detection ×10
opencv ×6
c++ ×2
matlab ×2
python ×2
.net ×1
aforge ×1
canvas ×1
crop ×1
html5-canvas ×1
image ×1
javascript ×1