如何找到自定义形状特殊区域? [英] How to find custom shape speicific area?
本文介绍了如何找到自定义形状特殊区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请看下面的图片,在这里你可以看到蓝色矩形是自定义形状边界,自定义形状是鞋子,我想找到一部分写在图像中的区域,我想要矩形形式的区域
do是否存在任何路径迭代器概念?
注意
自定义形状,我从相同尺寸的图像中派生出来。
解决方案
我会这样做:
1.为所有边界框矩形周界线创建表
- 每个值都将代表空白空间长度形成边框线形状
- 类似如下:
- 值为通过简单的图像扫描找到,直到找到第一个非空白颜色
- 为所有4种组合(从其他角落的星星)做到这一点
- 我也确信这可以通过某种方式进行优化
- 例如通过派生周界找到极值并从它们开始向后检查
- 大小将开始收缩然后停止...
- 当然要记住,在复杂的形状上,这种优化不会起作用...
b
$ b < y =左上角
for xs = 1到边界框宽度
现在扫描矩形的最大有效高度,从x到x + xs(x向右增长)
//它应该是最小的y0 [x..x + xs]
记住最大的有效区域/大小组合
I now Brute-您可以将边界线不是像素,而是用一些步骤来代替
please , see following image, here you can see blue rectangle is custom shape bounds and custom shape is shoe , i want to find area of a portion written in image and i want that area in form of rectangle
do is there any path iterator concept ?
Note
custom shape i derived from image of the same size.
解决方案
I would do it like this:
1.create table for all bounding box-rect perimeter lines
- each value in it will represent the empty space length form border line to shape
- something like this:
- the values are found by simple image scanning until first non space color found
2.now bruteforce find the biggest rectangle area
x,y = top left corner
for xs = 1 to bounding box width
now scan the max valid height of rectangle from x to x + xs (x grows to the right)
// it should be the min y0[x..x+xs]
remember the biggest valid area/size combination
- do this for all 4 combinations (star from the other corners)
I now Brute-force is slow but
- you can divide perimeter lines not by pixels but with some step instead
- also I am sure this can be optimized somehow
- for example by derivation of perimeter find the extremes and check from them backwards
- when the size will start shrinking then stop ...
- of course take in mind that on complicated shapes this optimization will not work ...
这篇关于如何找到自定义形状特殊区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文