Click to See Complete Forum and Search --> : Help! Don't understand question


paret
October 1st, 2009, 09:40 PM
I have a question that I need to do in Java. I don't want help trying to solve it, I was just hoping someone could help me figure out what is being asked,and how Im supposed to go about doing it.
any feedback would be very helpful and much appreciated. Thank You

" 1. Medical researchers are using X-rays of thousands of patients to try to diagnose a
common back injury. Their software needs the X-ray images in two-colours, instead of
the greyscale currently needed. You are to use an uncommon method for edge detection
in order to convert the images, which hopefully will result in good data for the
researchers. Be sure to get it right, people are suffering!
The images will be defined in a 2D grid of integers (which values between 0 and
255, inclusive). You will produce a new image that only contains the values 0 or 255 in
each position. A pixel should be assigned a value of 255 iff the average value in the
adjacent pixels in the original image (including diagonals) is lower than the pixel's value
itself in the original image. Otherwise, the value should be 0. A sample image is given
below, with which you should test your algorithm. Print the result of the edge detection,
in a grid format, so that you can validate the results.
public static int[][] image = {{1,5,3,8,2},
{3,0,6,3,1},
{5,4,8,1,3},
{6,2,3,2,3},
{3,5,2,1,8}};
Hint: Do not perform your conversion on the original image. Be sure to make a copy! "

keang
October 2nd, 2009, 02:40 AM
You need to read the question carefully (all the information is in there) and extract the relevant bits by making notes as you read.

For example in this case your notes should be something like:

Input Image = 2D array with values from 0 to 255
Output Image = 2D array with valaues of either 0 or 255
Output Image array is the same size as input image array
Calculate each output pixel as follows: ... {I'll leave you to fill this in}
Print the output image as a 2D grid of values to the screen.

You now have a concise view of the requirements so you can start to plan how you are going to solve the problem. Once you have a clear understanding and a plan then, and only then, start to write the code.

dlorde
October 2nd, 2009, 04:13 AM
I'd emphasise what Keang said by strongly recommending you work out everything you need to do, in English, on paper, before writing any Java code. Make sure you can process a part of the sample image by hand and get the correct results before trying to translate your plan into Java. The worst thing you can do is start coding before you know exactly what to code.

Learning how to learn is life's most important skill...
T. Buzan

nuzzle
October 2nd, 2009, 04:27 AM
I was just hoping someone could help me figure out what is being asked,and how Im supposed to go about doing it.

You have a 2D array filled with numbers between 0 and 255. Your job is to create a new 2D array of equal size containing only 0's and 255's.

To do this you consider the numbers in the original array one by one. For each number you calculate the surrounding average. Each number has 8, 5 or 3 close neighbour numbers (depending on where they're positioned in the array) and you calculate the average of these numbers. If a number is bigger than its surrounding average you set the corresponding position in the new array to 255, otherwise 0.

When you've finished you have a new array of 0's and 255's. The 255's represent all numbers in the original array that are bigger than their immediate surroundings. Everything else will be 0's. This process has extracted a black and white image from a greyscale image showing all ridges present in the original.

paret
October 5th, 2009, 11:11 AM
Thanks nuzzle...it makes sense now!

nuzzle
October 5th, 2009, 04:15 PM
Thanks nuzzle...it makes sense now!

Your wellcome.

Interesting algoritm. I hope you check it out on some real images.