Thread: How to use loadJPG function from library jpeg?

  1. #16
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    As I just stated, it is not a standard function. There are many implementations out there for the jpeg format; depending on your compiler/OS/library files the answers are going to be different. You really haven't provided us with any information here. Why don't you post the code you came up with and then maybe provide a link to your instructions; it would be a starting point.
    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.

  2. #17
    Registered User
    Join Date
    Jul 2011
    Posts
    12
    So far I've came up with nothing, unfortunately .
    Here's the link to the assignment:
    http://www.cise.ufl.edu/class/cgs346.../homework6.pdf (The first question)

    Thanks for all the attempts to help, I really do appreciate it.

  3. #18
    Registered User
    Join Date
    Jul 2011
    Posts
    12
    jpeg.o and jpeg.h can be downloaded from here:

    Index of /class/cgs3460su11/homework

  4. #19
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    So did you do the histogram homework that this is based on? If I give you a number, do you know how to figure out which bin it should go in? (And now, if I give you three numbers, do you know which triple-bin it should go in?)

  5. #20
    Registered User
    Join Date
    Jul 2011
    Posts
    12
    Yes, the histogram part is not really a problem.

    The part I don't understand is how to use the loadJPG function to get all the data I need. Specifically, how to function call loadJPG and read the output of loadJPG into memory.

  6. #21
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Oh my, let's take a look:
    Quote Originally Posted by Homework
    1. In this problem we will extend the histogram introduced in previous home-
    works
    to a three dimensional histogram and apply it to compute the his-
    togram of a color image.
    Do you know what a histogram is?

    Quote Originally Posted by Homework
    (b) To get the pixels from an actual JPEG image, the image has to
    be decompressed first. A library jpeg is provided, which contains
    the following function defined in jpeg:h that decompresses a JPEG
    image:
    // this function reads a JPEG image from file named
    // input_file_name
    // and stores the pixel data in the file named
    // output_file_name
    // The function returns the number of bytes written
    int loadJPG(const char* input_file_name,
    const char * output_file_name);
    The output le is a binary le where the rst item is an integer
    representing the width of the image, the second item is an integer
    representing the height, and then the pixel data follows in the same
    way as described in a). Write a function that first calls loadJPG
    to decompress the image and then reads into memory the pixel data
    written by loadJPG Your function should have the following header:
    unsigned char * get_pixels(char * filename,
    int *width, int *height);
    The function returns a pointer to where the pixel data is stored in
    memory and also returns the width and height of the image in pa-
    rameters width and height.
    If you noticed this is actually part 2 of your problem.

    Part 1 would be:
    Quote Originally Posted by Homework
    Write a function which takes as input a pointer to pixel data, the
    width and the height of the image in pixels and the number of bins
    for each color and returns a pointer to histogram data. The function
    should have this prototype
    unsigned int * compute_histogram(
    unsigned char * pixels, int width, int height,
    int bins_per_color);
    The memory where pixels points to is structured such that the rst
    item is the blue value of the rst pixel (the upper left corner), the....
    So again, what have you done?
    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.

  7. #22
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by CNoobgrammer View Post

    The part I don't understand is how to use the loadJPG function to get all the data I need. Specifically, how to function call loadJPG and read the output of loadJPG into memory.
    So did you read the homework assignment at all?
    The output file is a binary file where the first item is an integer
    representing the width of the image, the second item is an integer
    representing the height, and then the pixel data follows in the same
    way as described in a).
    Last edited by tabstop; 07-23-2011 at 11:00 PM.

  8. #23
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by CNoobgrammer View Post
    Yes, the histogram part is not really a problem.

    The part I don't understand is how to use the loadJPG function to get all the data I need. Specifically, how to function call loadJPG and read the output of loadJPG into memory.
    Quote Originally Posted by Homework
    The output file is a binary fille where the first item is an integer
    representing the width of the image, the second item is an integer
    representing the height, and then the pixel data follows in the same
    way as described in a).
    Write a function that first calls loadJPG
    to decompress the image and then reads into memory the pixel data
    written by loadJPG Your function should have the following header:
    unsigned char * get_pixels(char * filename,
    int *width, int *height);
    The function returns a pointer to where the pixel data is stored in
    memory and also returns the width and height of the image in pa-
    rameters width and height.
    How would you do what is in red?

    EDIT: To slow again.
    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.

  9. #24
    Registered User
    Join Date
    Jul 2011
    Posts
    12
    Quote Originally Posted by tabstop View Post
    So did you read the homework assignment at all?
    I really do appreciate you taking the time to help me, but why are you asking the same question again?

    Trust me, I've spent a lot of time going over the instructions. It is not easy for me to convert the english into codes.

  10. #25
    Registered User
    Join Date
    Jul 2011
    Posts
    12
    I will try to figure the problem out on my own.

    Thanks for all your help

  11. #26
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    May I refer you to the eloquent words of iMalc:

    Quote Originally Posted by iMalc View Post
    You might think you're appealing to our sympathetic side here, but you're not really. What you are doing is showing that you're an unmotivated person who isn't actively interested in learning programming and leaves things until the last minute. If that's not you then show us a different story.
    The kind of person we want to help here is the kind of person who is well motivated to learn programming but for one reason or another just gets stuck on little things here and there, or maybe just needs some clarification or second opinion on their work. Someone who shows they're really trying to learn.

    Attempting to dump the problem on others will not get you very far. Think of us more like a physiotherapist who is helping you walk again. It's not our intention to run the race for you. We will only help as much as we can see that you are helping yourself.
    Show some real interest in what you are doing. Describe what you're trying to do, and describe what isn't working or what you aren't sure how to do. Just pick one bit that you aren't sure of and start there. Have a go and when you can't figure it out, come and ask about it. Then when we're helped you understand how to solve that bit, work on the next bit.

    You're not getting many responses so far because you're not doing these things. I've done you a favour by telling you how you can present yourself as someone who others will actually want to help.
    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. #27
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by CNoobgrammer View Post
    The function is provided in the assignment; the function prototype is:
    Code:
    int loadJPG(const char* input_file_name,
    const char * output_file_name);
    The assignment itself is quite long with almost 3 pages of instructions. Essentially, we have to decompress an image file toobtain it's pixel data and read them into memory then compute the color histogram for the image.

    I really don't know anything about the function since it's not included in the book, or mentioned in the class.
    How far into this course are you? 2nd year... 3rd?

    This is very advanced coding. I've been messing with C for almost 7 years and I would find this challenging...

    Are you sure your teacher knows what he or she is doing?

  13. #28
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    The loadJPG function is horribly misnamed. It should in fact be called decompressJPGToFile.

  14. #29
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by rags_to_riches View Post
    The loadJPG function is horribly misnamed. It should in fact be called decompressJPGToFile.
    Or perhaps MessWithStudentsHead()

    It would seem simple enough...

    loadjpeg infile.jpg pixels.dat
    openfile pixels.dat
    ... start processing

    But apparently not...

  15. #30
    Registered User
    Join Date
    Jul 2011
    Posts
    2
    Hey are you on CGS 3460 at UF? because this looks so similar to the program we're making right now lol Who are you?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. function library (from scratch)?
    By SirJiub in forum C Programming
    Replies: 7
    Last Post: 06-05-2011, 01:48 PM
  2. how to know which function belongs to which library?
    By gibsosmat in forum Linux Programming
    Replies: 8
    Last Post: 11-18-2007, 07:46 AM
  3. The mathematical function library in C++
    By turkertopal in forum C++ Programming
    Replies: 3
    Last Post: 10-08-2005, 06:54 AM
  4. Library Function to verify Int
    By Mr_roboto in forum C++ Programming
    Replies: 24
    Last Post: 09-29-2005, 02:11 PM
  5. library function
    By darfader in forum C Programming
    Replies: 4
    Last Post: 09-10-2003, 09:38 PM

Tags for this Thread