Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

c programing

  • 04-12-2012 11:35AM
    #1
    Registered Users, Registered Users 2 Posts: 47


    any1 write an example c program to scan an image file to see if its a solid (all black) or a ring (black with a white circle in the middle). Cheers!


Comments

  • Registered Users, Registered Users 2 Posts: 406 ✭✭Gotham


    Is this a college project?

    When you load a bmp into a char[], you can run through it like this:

    for (int y=0;y<lengthy;y++)
    {
    for (int x=0;x<lengthx;x+=3)
    {
    char red = char[x+(lengthx*y)];
    char green= char[x+(lengthx*y)+1];
    char blue = char[x+(lengthx*y)+2];
    if (red == green == blue == 255)
    {
    //this is black
    }
    }
    }

    this is off the top of my head, but i think it should be correct for the body of the processing.


  • Registered Users, Registered Users 2 Posts: 47 paddyd8


    Thanks but what i hav that bit done. What I need is a while loop that starys at the top of the image scan down througj it and see if its a solid or a ring?


  • Registered Users, Registered Users 2 Posts: 406 ✭✭Gotham


    paddyd8 wrote: »
    Thanks but what i hav that bit done. What I need is a while loop that starys at the top of the image scan down througj it and see if its a solid or a ring?
    The code i provided scns through it.

    Whenever you come across a white pixel, calculate its distance to the center of the image. Add this distance to a global number and count the number of white pixels you have scanned.
    Average the global number out and use a tolerance (for aliasing) to check if the white pixels average out to be in the center of the image.


  • Registered Users, Registered Users 2 Posts: 47 paddyd8


    so will your example code do this?


  • Registered Users, Registered Users 2 Posts: 7,546 ✭✭✭BrokenArrows


    Sounds me me like someone wants their homework done.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 406 ✭✭Gotham


    paddyd8 wrote: »
    so will your example code do this?

    No

    The lecturers all check these sites btw. They also check those sites where you pay people to do their projects for you. I know many people personally who were caught out, and all it takes is one post that has too much info in it.

    I've given you code and a description of a very do-able solution, it's not that hard and it's not that much work. I'm not going to get you in trouble, seeing as you're already traceable enough.


Advertisement