Created
December 20, 2011 07:33
-
-
Save jkdeveyra/1500663 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package app | |
| import ij.ImagePlus | |
| import imagescience.image.Image | |
| import harrislaplace.HarrisLaplace | |
| import imagescience.shape.Point | |
| import ij.process.ImageProcessor | |
| import scalaj.collection.Imports._ | |
| object HarrisLaplaceApp extends App { | |
| val img = Image.wrap(new ImagePlus("3.pgm")) | |
| val imgproc = img.imageplus.getProcessor | |
| val pixels = imgproc.getPixels.asInstanceOf[Array[Byte]] | |
| println(pixels.size) | |
| val px = new Array[Array[Int]](imgproc.getWidth) | |
| for (i <- 0 until imgproc.getWidth) { | |
| px(i) = new Array[Int](imgproc.getHeight) | |
| for (j <- 0 until imgproc.getHeight) | |
| px(i)(j) = pixels(imgproc.getWidth() * i + j) | |
| } | |
| val harrislaplace = new HarrisLaplace | |
| val points = harrislaplace.detect(px, imgproc.getWidth, imgproc.getHeight) | |
| val dup = imgproc.duplicate | |
| points.foreach(p => drawPoint(dup, p)) | |
| new ImagePlus("", dup).show() | |
| def drawPoint(ip: ImageProcessor, point: Point) { | |
| ip.drawLine(point.x.toInt - 2, point.y.toInt, point.x.toInt + 2, point.y.toInt) | |
| ip.drawLine(point.x.toInt, point.y.toInt - 2, point.x.toInt, point.y.toInt + 2) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment