配穴图案填充矩形 [英] Filling rectangle with points pattern

查看:150
本文介绍了配穴图案填充矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在图片下面有一些特定的模式。它在第一张图像的最佳可见。我有标有小circes点,用线连接起来。他们让一些网络格局。有些点是错误的,不适合的模式(标注在第一个图像)。 其目的是,以填补用红色标出整个矩形(矩形从极值点创建 - 个图案与极值坐标的坐标系统)。

On images below there is some specific pattern. Its best visible on first image. I have points marked with small circes and connected with lines. They make some net pattern. Some points are wrong and does not fit to pattern (marked on first image). The objective is to fill whole rectangle marked with red (rectangle is created from extremal points - points with extremal coordinates in pattern coordinate system).

的问题是什么方法应采取以填补矩形点,并消除错误之分。形势在第二图像极值,但主要是案件与更多的积分。

图片仅用于可视化。我得配点坐标的载体。没有必要检测点。

Images are only for visualization. I've got vectors with points coordinates. There is no need to detect points.

我会尽快为我找出之一添加我的解决方案。

I will add my solution as soon as I figure out one.

我目前的做法是创建平行的长矩形边线与已知的图案偏移。然后找点线附近的一些增量的距离,并填写其余点。

My current approach is to create lines parallel to longer rectangle sides with known pattern offset. Then to look for points with some delta distance near lines, and fill the rest points.

推荐答案

总的来说,我会做的是先确定网格,然后很容易检查,如果事情是在该网格。

Overall, what I would do is first determine the grid, and then it's easy to check if something is on that grid or not.

这些步骤如下:

  • 旋转一切,让你只得到了水平线和垂直线。

  • rotate everything so that you've only got horizontal and vertical lines.

每x值算你多少分。

伪code:

xcount is array of int
ycount is array of int

for x=0 to width-1 do
  for y=0 to height-1 do
    foreach point do
      if point.x = x then
        xcount[x]++
      if point.y = y then
        ycount[y]++ 

有关你的最后一个图像,其结果必然是这样的:

For your last image, the result would be something like this:

x-count:1,0,0,0,3,0,2,0,1,0,0,0,4,0,0,0,3,0,0,0,4
y-count:2,0,0,0,6,0,0,0,4,0,1,0,3,0,1,0,1

  • 现在检测网格尺寸:

    • Now to detect the grid size:

      匹配= 0 对于i = 1〜10做   的foreach XCOUNT做     如果XCOUNT MOD I = 0,则       火柴[I] ++

      match = 0 for i=1 to 10 do foreach xcount do if xcount mod i=0 then matches[i]++

      现在我们有一个包含10个不同的栅格尺寸的得分(相匹配的点数)的数组。它可能是这个样子:

      Now we have an array that contains the score (number of points that match) for 10 different grid sizes. It could look something like this:

      gridscores[] = 5,5,0,5,34,5,0,5
      
      XgridSize = index of greatest gridSore
      

      • 34显然是最好的比赛,这是在指数5,所以格大小为5。

        • 34 is clearly the best match, and it's at index 5, so the grid size is 5.

          现在你知道了网格的大小,你可以很容易地找到这点不上格:

          Now that you know the grid size, you can easily find which points are not on that grid:

          的foreach点做    wrongpoint =(point.x模XgridSize!= 0)或                 (point.y MOD YgridSize!= 0)

          foreach point do wrongpoint = (point.x mod XgridSize != 0) or (point.y mod YgridSize != 0)

          这个工程,即使有很多错误之分。我没有进入上如何旋转以及如何找到的偏移网格,但也许这可以帮助您正确的方向的细节。

          This works even if there are a lot wrong points. I didn't get into the details on how to rotate and how to find the offset for the grid, but maybe this helps you into the right direction.

          这篇关于配穴图案填充矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆