0

I've got a ridiculously insane Linear Algebra professor at uni who asked us this last Friday to develop a programme in Java that loads a monochrome picture and then applies an edge-detecting filter on it. The problem is nobody in my class has got the slightest clue how to do it and I have only a week to get it done. As I'm still trying to get my head round it and start it from scratch, does anybody have anything ready to send me so I can study it and save my semester? Any efforts will be much appreciated.

92AlanC
  • 1,327
  • 2
  • 14
  • 33

1 Answers1

1

Here's a very basic approach you might go with:

1) What is an edge in a monochrome image? One could say that it is a steep intensity gradient. If you go from black to white that is an edge, and vice versa.

2) A very simple filter operation that builds on this idea is the Sobel operator. Read up on it here: Wikipedia.

3) You'll stumble across 2 terms that may be unfamiliar to you: Kernel and Convolution. A kernel is basically a window moved over each pixel, performing an operation on the pixel's environment. In case of the Sobel 3x3 kernel, you assign a new value to the filtered image based on the pixel's direct neighbours. The convolution operation can be thought of as - among other things - an operation that moves the kernel across every pixel in the image (note: This is a gross oversimplification to get you started and technically incorrect. It should, however, give you the right idea)

4) Now the simplest way of applying a Sobel kernel to a BufferedImage is by using the ConvolveOp class. It is a prebuilt java class that takes a kernel, applies it to a given image and returns the filtered image. However, if this is for class, you might want to implement this yourself.

sarcan
  • 3,145
  • 19
  • 22
  • Thank you! It seems to be very useful but my Java knowledge is still very basic (just got introduced to OOP, so I couldn't really implement that class and make it work. Just wondering, have u got anything ready so I can just run it and save this assignment? Unfortunately I haven't got the slightest clue how to do it. – 92AlanC Oct 30 '14 at 10:51