问题描述
我有一张图片,图片中有一条偏线。它们一直是水平或垂直线。我不知道线的颜色,也不知道线的宽度。
I have an image and I have a partial line in the image. They are all the time horizontal or vertical lines. I don't know the color of the line, neither the width of the line.
我如何使用PHP来检测这样的线?
How can I use PHP to detect such a line?
正如您在上传的图片中看到的,我需要切片3x3个部分。我需要3个垂直和3个水平部分来切片。请注意,内容区域周围有一个带有一些标记的矩形,这是图像的一部分。
As you see in the uploaded image, there are 3x3 sections I need to slice. I need the 3 vertical, and 3 horizantal sections to slice the parts. Please note there is a rectangle with some markes around the content area, that is part of the images.
我们可以使用这些标记来获取坐标。
We can use those markers to get the coordinates.
推荐答案
你最好使用这些标记通过比较每条线的第一个和最后一个N个像素,如果它们具有相同的颜色/长度。它比解析每一行上的所有像素更有效。
You're better off using the markers by comparing the first and last N pixels of each line if they have the same color/length. It will be more efficient that way than parsing all pixels on each line.
这篇关于如何检测图像中的部分垂直/水平线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!