像素里面有不规则形状? [英] pixel inside an irregular shape ?

查看:102
本文介绍了像素里面有不规则形状?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要允许用户使用折线绘制闭合的形状,然后遍历这个闭合形状内部的所有像素。有没有一种简单的方法可以找出哪些像素是形状的元素? (我需要索引(x,y))。



我想这有点类似于油漆中的填充方法?

我有一个使用矩形的原型(这很简单),但我不知道如何开始使用折线方法。



任何提示更多欢迎。



谢谢。





图片是太阳黑子的图画。用户可以(今天)围绕太阳黑子组绘制一个矩形,应用程序将检测脏像素(形成太阳黑子)并对其进行一些计算。但是,如果我们使用的是折线形状而不是矩形,那么这些图纸(例如书面文字)就会出现不需要的特征。

[/ EDIT]

I would need to allow a user to draw a closed shape using polylines and then loop through all the pixels "inside" this closed shape. Is there an easy way to find out which pixels are an element of the shape? (I would need the index (x,y)).

I guess this is somewhat similar to a "fill method" like in paint?
I have a prototype working with rectangles (which is easy), but I have no clue on how to start with the polyline method.

Any tips are more than welcome.

thanks.


The image is a drawing of sunspots. The user can (today) draw a rectangle around a sunspot group and the application will detect the "dirty" pixels (that make out the sunspots) and do some calculations on it. There are, however, unwanted features on these drawings (written text eg) which we could take out if we were using a polyline shape instead of a rectangle.
[/EDIT]

推荐答案

以下页面提供了检测像素是否在不规则多边形内的基本技术:



像素测试 [ ^ ]。



可以采用类似的原则。给定制作多边形的点集,找到沿x / y坐标的最小值/最大值。然后,对于每条扫描线,随时跟踪您在多边形内部或外部的时间。



然后,您可以将太阳黑子检测算法仅应用于枚举的那些点在多边形内。
The following page provides a basic technique for detecting if a pixel is inside an irregular polygon:

Pixel Test[^].

A similar principle can be applied. Given the set of points making your polygon, find the min/max along the x/y coordinates. Then, for each scan line, track when you are inside or outside the polygon as you go.

You can then apply your sunspot detection algorithm only to those points that enumerate within the polygon.


这篇关于像素里面有不规则形状?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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