对一组连续像素进行边缘检测?

时间:2017-12-25 18:22:49

标签: java scala image-processing

我正在编写一个动画库,其中输入没有任何比例。尺寸和比例由提供的渲染后端确定。

trait RenderingBackend {

  def render(w: Int, h: Int, f: File, d: Drawable, framerate: Int, totalTime: Long, unit: TimeUnit): Unit

}

我想实现边缘检测转换

trait Transformation {

  def transform(t: Transformable): Transformable

}

可以应用于可转换的

trait Transformable extends Drawable {

  def transform(t: Transformation): Transformable = t.transform(this)

}

给出颜色和笔划半径。 Drawable接口在哪里

trait Drawable {

  /**
    * If the drawable does not contain (x, y) as a point, then this should return None.
    * If the drawable perfectly defines (x, y) as a point, then this should return the Some(color).
    * If the drawable does not perfectly define (x, y) as a point but does define points around it, a weighted average should be chosen.
    * @param x the x relative to the whole image to be retrieved
    * @param y the y relative to the whole image to be retrieved
    * @return an optional color
    */
  def color(x: Double, y: Double): (Double) => Option[Color]

  /**
    * Generates an image for a time.
    * Square resolutions work best.
    * @param w width of output
    * @param h height of output
    * @return function to generate an image based on time [0.0, 1.0)
    */
  def image(w: Int, h: Int): (Double) => BufferedImage = // some implementation using the color method

}

Full code for Drawable can be found here.

实现Transformable特征的类会返回(Double) => Option[Color],其中Some(_)表示已定义的颜色(可转换的一部分),而None表示点是形状的一部分。然而,与Drawable的不同之处在于它可能会被改变。

什么是"连续"是没有定义的比例或分辨率。例如,椭圆的颜色函数是

(t) => {
  val (ph, pk) = pos(t)
  val rx = w(t) / 2
  val ry = h(t) / 2
  val c = (((x - ph) * (x - ph)) / (rx * rx)) + (((y - pk) * (y - pk)) / (ry * ry))
  if(c <= 1) {
    Some(color(t))
  } else {
    None
  }
}

它不需要任何比例,分辨率或单位,只需要一点。

由于渲染前所有内容都是连续的,如何通过Transformation检测某些边缘?

0 个答案:

没有答案