Anonymous user
Hough transform: Difference between revisions
Scala improved
m (separated comment from a task directive.) |
(Scala improved) |
||
Line 675:
val inputData = readDataFromImage(args(0))
val minContrast = if (args.length >= 4) 64 else args(4).toInt
}
Line 695 ⟶ 694:
}
class ArrayData(
this(Array.ofDim[Int](width * height), width, height)▼
}▼
def update(x: Int, y: Int, value: Int) {
dataArray(
}
Line 722 ⟶ 715:
val r = cosTable(theta) * x + sinTable(theta) * y
val rScaled = Math.round(r * halfRAxisSize / maxRadius).toInt + halfRAxisSize
outputData.
}
Line 729 ⟶ 722:
def writeOutputImage(filename: String) {
for (y <- 0 until height; x <- 0 until width) {
val v = dataArray(x)(y)
if (v > max) max = v
▲ }
val image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB)
for (y <- 0 until height; x <- 0 until width) {
val n = Math.min(Math.round(
image.setRGB(x, height - 1 - y, (n << 16) | (n << 8) | 0x90 | -0x01000000)
}
ImageIO.write(image, "PNG", new File(filename))
}
private def contrast(x: Int, y: Int, minContrast: Int): Boolean = {
val centerValue =
for (i <- 8 until -1 by -1 if i != 4) {
val newx = x + (i % 3) - 1
val newy = y + (i / 3) - 1
if (newx >= 0 && newx < width && newy >= 0 && newy < height &&
Math.abs(
return true
}
Line 754 ⟶ 747:
false
}
}</lang>
|