thorfdbg / libjpeg

A complete implementation of 10918-1 (JPEG) coming from jpeg.org (the ISO group) with extensions for HDR, lossless and alpha channel coding standardized as ISO/IEC 18477 (JPEG XT).
327 stars 81 forks source link

jls to any format #2

Closed egorsh0 closed 7 years ago

egorsh0 commented 8 years ago

When you convert images from jls format to any other amount received on the 18-bit larger than the original , which I think is not correct. Why? How to fix it?

thorfdbg commented 8 years ago

Am 05.04.2016 um 14:03 schrieb egorsh:

When you convert images from jls format to any other amount received on the 18-bit larger than the original , which I think is not correct. Why? How to fix it?

Sorry, but your report is so unspecific it is impossible to address it.

First, which type of input image did you feed into the codec? How did you configure the codec, i.e. which command line options did you use?

Could you provide the image you want to compress?

Last but not least, which format do you compress to? Lossless JPEG (10918-1), JPEG LS (14495-1)? Lossless JPEG XT (18477-8)?

Greetings, Thomas

egorsh0 commented 8 years ago

The codec I send a 12-bit image in JPEG LS format. When sending 8-bit image, the resulting after the codec is displayed correctly. To perform the conversion, I would do a ./jpeg file.jls file.ppn

The archive contains the original image size of 5029270 bytes and concise. Image size 2448 to 2054 pixels. After the codec on the compressed file size to get a new 10036818, i.e. one pixel uses 2 bytes. Carrying no complex mathematical calculations: (10,036,818 - (2448 * 2054)) / 2448 should receive 8 extra lines, but beyond 7,992. I may not correctly use your codec. Push on the right solution, please Thank you

P.s. Sorry for my bad english example.zip

thorfdbg commented 8 years ago

Am 05.04.2016 um 15:40 schrieb egorsh:

The codec I send a 12-bit image in JPEG LS format. When sending 8-bit image, the resulting after the codec is displayed correctly. To perform the conversion, I would do a ./jpeg file.jls file.ppn

Correct.

The archive contains the original image size of 5029270 bytes and concise. Image size 2448 to 2054 pixels. After the codec on the compressed file size to get a new 10036818, ie one pixel uses 2 bytes.

Certainly. This is how ppm works. The jpeg command line reconstructs to a "framed container", which is ppm. ppm uses either one byte or two bytes per pixel. If the bit depths is larger than 8 bits/sample, each sample is two bytes large, big-endian, with padding zeros in the most significant bits. If the bit depth is lower than 8 bits/sample, each pixel takes a single byte, again with padding zero bits at the MSBs to fill an entire byte.

The jpeg command front-end does not write unframed data (aka "raw"). If you want to, you would need to write another front-end around the libjpeg core. Alternatively, you can use the difftest_ng command line tool (on the same github) to perform a conversion to raw. Since there are many unframed formats, I would suggest to read "difftest_ng --rawhelp" first.

Carrying no complex mathematical calculations: (10,036,818 - (2448 * 2054)) / 2448 should receive 8 extra lines, but beyond 7,992. I may not correctly use your codec. Push on the right solution, please.

You use it correctly, but you need to understand how ppm works. It's different than what you expect. See "man ppm" for details.

Greetings, Thomas

egorsh0 commented 8 years ago

So, thank you very much. I'll try to do it the other day. I understand you correctly that difftest_ng will perform conversion from JPEG LS in raw or need to change the codec code? And if so, how? All the same, I would have been ideal to both 8 bit and 12 bit JPEG LS turned raw Thanks

thorfdbg commented 8 years ago

Am 05.04.2016 um 17:53 schrieb egorsh:

So, thank you very much. I'll try to do it the other day. I understand you correctly that difftest_ng will perform conversion from JPEG LS in raw or need to change the codec code?

No, difftest_ng does not convert between jpeg-ls and other formats. difftest_ng converts only between uncompressed formats, and jpeg-ls is none of them. For example,

difftest_ng --convert output.tiff input.ppm -

will convert from ppm to tiff.

If you want to convert to .raw, you first need to decide what you mean by "raw". Then read "difftest_ng --rawhelp" (really!).

The file annex for raw files is ".raw":

difftest_ng --convert output.raw@: input.ppm -

and is something you need to decide upon.

So unless you want to write a front-end for libjpeg, you would first need to run "jpeg" to convert from .jls to .ppm, and "difftest_ng" to convert from ppm to your target format (whatever this format may be).

Greetings, Thomas

egorsh0 commented 8 years ago

Hmm, and what you recommend to convert jls in raw? Can I use your codec and if so, how? (You need just such a conversion)

thorfdbg commented 8 years ago

Am 05.04.2016 um 18:28 schrieb egorsh:

Hmm, and what you recommend to convert jls in raw? Can I use your codec and if so, how? (You need just such a conversion)

Please see my previous email. You have the following options:

a) use a two-step process that a.1) convert jpeg-ls to ppm by the jpeg command line tool -and- a.2) convert ppm to raw by difftest_ng

-or-

b) implement your own command line front end on the basis of the libjpeg core library. (This is entirely possible using the current license)

Greetings, Thomas

egorsh0 commented 8 years ago

Sorry, but I have a question . You are not going to use the projects 'cmake'? Maybe I 'm doing something wrong, but using 'make' difftest_ng not going.

thorfdbg commented 8 years ago

On 07.04.2016 08:32, egorsh wrote:

Sorry, but I have a question . You are not going to use the projects 'cmake'? Maybe I 'm doing something wrong, but using 'make' difftest_ng not going.

Because cmake does not work on Solaris and IRIX machines. Type "./configure" to configure difftest_ng. If you see any warnings or errors, please send me the "config.log" file.

Greetings, Thomas

egorsh0 commented 8 years ago

File "config.log" is not created. Errors: make: autoheader2.59: command not found Makefile:48: recipe for target 'autoconfig.h.in' failed make: *\ [autoconfig.h.in] Error 127

What's wrong?

thorfdbg commented 8 years ago

On 07.04.2016 09:14, egorsh wrote:

File "config.log" is not created. Errors: make: autoheader2.59: command not found Makefile:48: recipe for target 'autoconfig.h.in' failed make: *\ [autoconfig.h.in] Error 127

What's wrong?

I forgot to add "configure" to the git repository. Make a "git pull" to fetch the latest release, then run "./configure" on the command line. Then run "make". In this order.

Greetings, Thomas

egorsh0 commented 8 years ago

Yes, now I create a file 'config.log', but with an error. config.zip

What to do with it?

egorsh0 commented 8 years ago

I tried a few things to correct, but it does not work. Perhaps you have some solution? There are all the same mistakes that were several e-mails back

thorfdbg commented 8 years ago

I tried a few things to correct, but it does not work. Perhaps you have some solution? There are all the same mistakes that were several e-mails back

So what's the output of "configure" then?

Greetings, Thomas

egorsh0 commented 8 years ago

I run ./configure then appeared ./config.status file that is printed to the console: config.status: creating automakefile config.status: creating autoconfig.h config.status: autoconfig.h is unchanged Once launched the 'make' and appeared the same mistakes

configure.zip

thorfdbg commented 8 years ago

On 07.04.2016 11:42, egorsh wrote:

I run ./configure then appeared ./config.status file that is printed to the console: config.status: creating automakefile config.status: creating autoconfig.h config.status: autoconfig.h is unchanged Once launched the 'make' 'and appeared the same mistakes

Please try again, I've updated the makefile. But as said, the output of configure on the console would be helpful.

Greetings, Thomas

egorsh0 commented 8 years ago

Everything is working. Thank you very much. I hope I have not bored.

thorfdbg commented 8 years ago

Am 07.04.2016 um 13:00 schrieb egorsh:

Everything is working. Thank you very much. I hope I have not bored.

No, you're welcome. Good to know that everything works now.

Greetings, Thomas

egorsh0 commented 8 years ago

Hello. I am interested in the task to remove the code from the libjpeg to add a frame to the image , but for a couple of days I sit and study the function 'Reconstruct' and understand it can not. Could you help me?

thorfdbg commented 8 years ago

On 19.04.2016 13:09, egorsh wrote:

Hello. I am interested in the task to remove the code from the libjpeg to add a frame to the image , but for a couple of days I sit and study the function 'Reconstruct' and understand it can not. Could you help me?

Given the generality of the question, it is hard to come up with an answer. So what exactly do you want to achieve?

Image::ReconstructRegion() requires that an image is already loaded into the internal buffers of the library, and then performs the reconstruction through the bitmap hook.

Greetings, Thomas

egorsh0 commented 8 years ago

I want to make sure that it was possible, using the library 'libjpeg' to get the image in raw format. And for this the formation ppm format, you need to somehow remove the frame, if I understand correctly

thorfdbg commented 8 years ago

On 19.04.2016 15:06, egorsh wrote:

I want to make sure that it was possible, using the library 'libjpeg' to get the image in raw format. And for this the formation ppm format, you need to somehow remove the frame, if I understand correctly

Actually - no. The "frame" class in libjpeg is responsible for the JPEG "frame", which is a technical term for the data and data structures related to the SOF marker. That is completely unrelated to the data framing to generate the pnm image format, and this is outside of the core library and only part of the command line front-end. The core library only generates raw image samples. It does not write them in a particular way, nor does it write them to files. That's all part of the command line (demo) front-end in the "cmd" directory.

The core library retrieves (on encoding) and delivers (on decoding) its data through a structure/call-back hook called the "bitmap hook". A particular implementation of such a hook function you'll find in cmd/bitmaphook.cpp.

The actual generation of the pnm format header ("the framing" of the pnm format) is so simple, it is not even part of a function. You'll find that as a couple of printf's in cmd/reconstruct.cpp, in the Reconstruct() function. There's a single fprintf which writes the first lines for a pnm file.

Greetings, Thomas

egorsh0 commented 8 years ago

Hello. Could you tell me if it is possible, using any of your libraries to implement the reverse transformation : raw in jls?

thorfdbg commented 8 years ago

Am 30.05.2016 um 10:20 schrieb egorsh:

Hello. Could you tell me if it is possible, using any of your libraries to implement the reverse transformation : raw in jls?

If I tell you "yes", would that help? (-:

Look, I believe your question is based on several misconceptions.

"raw" is not a format, but a collection of several proprietary formats, one for each camera family, and the "Frame class" is not responsible for framing, but responsible for a marker segment within JPEG called "Start of Frame", and the JPEG abstraction of a "TV frame" (at best).

Thus, to properly answer your question, I believe you first need to understand your question.

So, what exactly do you want to do?

Greetings, Thomas

egorsh0 commented 8 years ago

Let's say, I want check if the conversion right executed. I changed the raw image code. After that is converted into "jls", and then again in the "raw". And I want to make sure that the source and destination images will coincide completely. That's why I asked you about whether it is possible to perform the conversion of "raw" and, if so, how? I will be very grateful. I too became interested in drawing :D

thorfdbg commented 8 years ago

Am 30.05.2016 um 12:06 schrieb egorsh:

Let's say, I want check if the conversion right executed. I changed the raw image code. After that is converted into "jls", and then again in the "raw". And I want to make sure that the source and destination images will coincide completely. That's why I asked you about whether it is possible to perform the conversion of "raw" and, if so, how? I will be very grateful. I too became interested in drawing :D

Again, you do not understand the problem. The problem is that there is no "raw format", hence I cannot convert to something I do not know. There are a couple of programs out there that support multiple "raw" formats in "a sense". "dcraw" is one of them, it can create a tiff from a raw. Or a ppm. Is that conversion lossy? Yes, certainly, you cannot go back to a format that is proprietary and not well-defined, with parameters that have never been documented by the vendors.

libjpeg does not support "raw" because there is no basis on which it could support it. dcraw supports "raw" on a "best guess" basis, by reverse engineering closed-source proprietary solutions. Is that good enough?

difftest_ng supports "raw unframed data", with pixels aligned in some form in the file. But that's neither the same "raw" as "camera raw".

You can certainly write a converter or a front-end to libjpeg for a format that is documented and that is different from the now-supported ppm. That is an easy going and the harmless part. The not-so-harmless part is to understand what "raw" actually means.

So, as I said, you first need to understand the question before asking it.

Greetings, Thomas