CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2009
    Posts
    6

    Question Help! Don't understand question

    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! "

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Help! Don't understand question

    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.

  3. #3
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Help! Don't understand question

    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
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  4. #4
    Join Date
    May 2009
    Posts
    2,413

    Re: Help! Don't understand question

    Quote Originally Posted by paret View Post
    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.
    Last edited by nuzzle; October 2nd, 2009 at 04:32 AM.

  5. #5
    Join Date
    Oct 2009
    Posts
    6

    Re: Help! Don't understand question

    Thanks nuzzle...it makes sense now!

  6. #6
    Join Date
    May 2009
    Posts
    2,413

    Re: Help! Don't understand question

    Quote Originally Posted by paret View Post
    Thanks nuzzle...it makes sense now!
    Your wellcome.

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured