Archive for the ‘jpeg2000’ Category

Saving JP2 images

August 11, 2006

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.


Loading JP2 and J2K images works!

July 31, 2006

I was finally able to find the error in my jpeg2000 plugin code. The reason for the error was that I was not reading the filename properly (basically reading NULL) and because of this I was getting segmentation faults when it tried to load images. I always assumed that the run function would automatically have the filename and never bothered to check this!  I solved the problem by providing the necessary arguments in the query function.

The good thing is that the load plugin is working smoothly on the select images that I tested it on. It may be a little slow but I can definitely speed it up using row processing. I used the openjpeg library although I could have used the jasper library as well because the problem I was getting was common. But the openjpeg library is specifically geared towards jpeg2000 development and the library functions are a lot more easier to use that the jasper library. The final code is also very clean.

A screenshot of how the image was loaded is shown below.


I will be out attending a family function for the next two days and will start working on refining the current load code and then work on saving as jp2 or j2k images.