Thread: image processing

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    28

    image processing

    Hey everyone. Iam trying to make a program using structs and pointers on arrays to analyze a bmp picture characteristics. Any good links to study?
    Thanks

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    So which bit(s) are confusing you?
    - structs and arrays in C
    - the details of the BMP file format
    - image processing techniques in general
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    28
    well iam trying to make the basic struct so i can build on it the rest of the program. I have read the bmp header file format but i can't really understand the difference between the file size and the raw file size

  4. #4
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Where is this the raw file size? AFAIK there is a file size and an offset to the bitmap. But you can investigate the header of some real bmp files to confirm how the data is laid out.

  5. #5
    Registered User
    Join Date
    Sep 2011
    Posts
    28
    Yes i am aware of those two sizes. But the size of the raw bitmap data is the one i don't understand.

  6. #6
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    The size of the bitmap data would be, (file size - header size) the actual image data. But look at a real bmp file it's easy to confirm this.

  7. #7
    Registered User
    Join Date
    Sep 2011
    Posts
    28
    yeap that's it!!
    thank you very much Subsonics

  8. #8
    Registered User
    Join Date
    Sep 2011
    Posts
    28
    Well so far so good.. i have build the structs for header and data now the problem is how do i read the data in binary from a bmp picture i have?

  9. #9
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by antros48 View Post
    Well so far so good.. i have build the structs for header and data now the problem is how do i read the data in binary from a bmp picture i have?
    Read: File operations Tutorial.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  10. #10
    Registered User
    Join Date
    Sep 2011
    Posts
    28
    Thanks for the reply! But how about when i want to give the files to the program when i run the program .. can i use argv[] and set e.g. argv[1] = file??

  11. #11
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by antros48 View Post
    Thanks for the reply! But how about when i want to give the files to the program when i run the program .. can i use argv[] and set e.g. argv[1] = file??
    Yes, just like you would handle any other command line argument. If you need a refresher on the topic, you can look at How to access command line parameters-FAQ().

    Due not that since argv[1] is a char*, you would need to use strcpy() and not the assignment operator if you wanted to store it in another variable.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  12. #12
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Using argv for the file works, no problem.

    Code:
    FILE *fp = fopen(argv[1], "r");
    Something to think about, is how a pixel is represented and color depth. Then there might be padding at the end of each row to "even up" the number of bytes per row, but you will find that out soon enough.

  13. #13
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by Subsonics View Post
    Using argv for the file works, no problem.
    I never said it wouldn't.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  14. #14
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    I never said you said it wouldn't.

  15. #15
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by Subsonics View Post
    I never said you said it wouldn't.
    LOL......
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Image processing
    By Gabi in forum C++ Programming
    Replies: 3
    Last Post: 06-30-2010, 05:42 PM
  2. Image Processing
    By abachler in forum General AI Programming
    Replies: 2
    Last Post: 09-22-2009, 08:25 AM
  3. help in image processing
    By hasson28 in forum C++ Programming
    Replies: 3
    Last Post: 09-06-2006, 11:46 AM
  4. Image processing in c and c++
    By riswan in forum C++ Programming
    Replies: 0
    Last Post: 03-23-2005, 03:29 AM
  5. Image rotation using intel image processing
    By sunis in forum Windows Programming
    Replies: 1
    Last Post: 11-18-2002, 02:40 AM