Saving JP2 images

By deebuv

After four days of dealing with continous errors in save routine for jp2 files, I finally got something fruitful. Initially I was getting errors from glibc which was giving me trouble using malloc(). Turns out I had not freed some memory and doing that fixed that error. Then came a run-time seg fault which was annoying. It took me a while to notice that in a for loop I had for(k =0;i< comps;i++) whereas it should have been for(k=0;k<comps;k++). i was uninitialized so the program basically skipped the step and a opj_create_image routine did not get the proper values.

After finding these stupid errors came the errors from the openjpeg library. Finding this error made me understand how the library is written, so it may have been a blessing in disguise! The problem was in writing header data into a stream. After a lot of debugging, I noticed the actual problem was initializing the data buffer in the stream. This led me to realize that I was actually not setting the width and height in the openjpeg image data structure. I assumed this done during initializing because I provided this data for each individual component. After doing this the program ran smoothly and saved the image. But now the problem was that the saved image was all black. The reason was some uinitialized values in the compression parameters. After figuring out the right values the image was finally saved correctly.

There are still some improvement that are needed though. First I need an interactive way of changing paramters for compression. Secondly, I need to test it with some standard images provided on the openjpeg discussion forum. That should complete this plugin. I would need to work a little harder to complete all this within two days as I have until August 21 to do this work.

I also need to make changes in the inverse halftoning plugin to put a graphical interface so that halftoned images of various frequencies can be reversed. The denoising plugin I believe is complete and works well.

After all this I need to make sure I have proper copyrights in the files and also write a final report.  Hopefully things will be done in time.

14 Responses to “Saving JP2 images”

  1. Simon Says:

    “valgrind” is a great tool to spot places where you use uninitialized memory. It also helps with free/malloc problems. Have a look at devel-docs/debug-plug-ins.txt in the gimp sources to get an idea how to invoke it.

    (It will show you some errors you can do nothing about, especially when your plugin starts up, you need to carefully look at them and try to figure out if they are in GTK/X11/libc, so that they are not in your code)

    Hope this helps,
    Simon

  2. Roo Says:

    Is the plugin available for download?

  3. Pucelo Says:

    Yes, but it hasn’t been compiled for Windows, Mac or Linux:
    http://registry.gimp.org/plugin?id=8629

    When it has been compiled, We will can say that GIMP can save JPEG 2000 format.

  4. pucelo Says:

    I have compiled it for Windows,
    In this link you have five plugins that they aren’t in normal GIMP distribution.
    http://www.megaupload.com/?d=9S9VMR19

  5. Deebu Says:

    hey..thanks for compiling on windows..I will check out and see..

  6. pucelo Says:

    In this link you have a Windows compiled version:
    http://www.megaupload.com/?d=BANPHKD6

    This is the tread in a Spanish forum about the file:
    http://www.gimp.org.es/modules/newbb/viewtopic.php?topic_id=691&forum=2

    The filter of “ihalf” has been changed in this file, there was a overflow bug, and I have killed it.

  7. deebuv Says:

    It seems to work well, that is gr8. Could you tell what you used to compile the code? I could only get it to compile on linux. Filter “ihalf” was buggy from the beginning and does not perform too well, so I won’t worry about it.

  8. Roo Says:

    Thanks to all these who’ve contributed.

    Has anyone compiled it for Linux? It would be really appreciated.

  9. Orderge Says:

    ONLINE – DRUGSTORE!
    PRICES of ALL MEDICINES!

    FIND THAT NECESSARY…
    VIAGRA, CIALIS, PHENTERMINE, SOMA… and other pills!

    Welcome please: pills-prices.blogspot.com

    NEW INFORMATION ABOUT PAYDAY LOANS!

    Welcome please: payday-d-loans.blogspot.com

    GOOD LUCK!

  10. dinosaur fact Says:

    I was searching for this kind of a blog for months now. Actually lost the hope of finding one, but here i am :) Thanks for the great articles! Looking forward for a little read after dinner :)

  11. Bart Says:

    I’m looking for a linux binary of the JPEG2000 plugin. Does somebody where to get it?

    Thanks.

  12. photocomix Says:

    nice work

    i may suggest to use http://www.box.net instead then megaupload to upload your files ?

    download from megaupload is really a pain, i’m not in anyway affiliated with box.net i just use it and offer a better server without that awful ads, and withot forcing not paying consumers to long wait

  13. BaraArbiz Says:

    There are 5 houses in five different colors
    In each house lives a different nationality.
    These 5 owners drink a certain beverage, smoke a certain brand of cigar and keep a certain pet.
    No owners have the same pet, smoke the same brand of cigar, or drink the same beverage.

    The CLUES:

    The Brit lives in the Red house.
    The Swede keeps dogs as pets.
    The Dane Drinks tea.
    The Green House is on the left of the White House.
    The Green House’s owner drinks coffee.
    The person who smokes Pall Mall rears birds.
    The owner of the yellow house smokes Dunhill.
    The man in the center house drinks milk.
    The Norwegian lives in the first house.
    The man who smokes Blends lives next to the one who keeps cats
    The man who keeps horses lives next to the man who smokes Dunhill.
    The man who smokes Blue Master drinks beer.
    The German smokes Prince.
    The Norwegian lives next to the Blue House.
    The man who smokes Blends has a neighbor who drinks water.
    The QUESTION:

    Who owns the fish?

  14. Slopayday Says:

    Outstanding page – Will come back.

Leave a Reply