Custom Quantization Tables

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
cujsmith
Posts: 8
Joined: 2016-10-13T16:18:14-07:00
Authentication code: 1151

Custom Quantization Tables

Post by cujsmith »

Hello, I'm working on a C++ application and want to compress with custom quantization tables. Is there a way to do this in a C++ program? The "quality factor" function is not precise enough. And I know I can do this with the command line installation of ImageMagick but I can't find the solution for Magick++.
Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Custom Quantization Tables

Post by snibgo »

See viewtopic.php?t=20414

Does that do what you want?
snibgo's IM pages: im.snibgo.com
cujsmith
Posts: 8
Joined: 2016-10-13T16:18:14-07:00
Authentication code: 1151

Re: Custom Quantization Tables

Post by cujsmith »

Yes, this should do it. I'll work with it.
Thanks, Jeff
cujsmith
Posts: 8
Joined: 2016-10-13T16:18:14-07:00
Authentication code: 1151

Re: Custom Quantization Tables

Post by cujsmith »

I can't get it to work out.
I am using the imagemagick supplied "quantization-table.xml" that will encode with the following QTs:
Luminance Quantization Table
16, 12, 14, 17, 22, 30, 45, 72,
12, 13, 14, 17, 22, 31, 46, 74,
14, 14, 16, 19, 25, 35, 52, 83,
17, 17, 19, 23, 30, 41, 62, 100,
22, 22, 25, 30, 39, 54, 80, 129,
30, 31, 35, 41, 54, 74, 111, 178,
45, 46, 52, 62, 80, 111, 166, 267,
72, 74, 83, 100, 129, 178, 267, 428
Chrominance Quantization Table
17, 18, 22, 31, 50, 92, 193, 465,
18, 19, 24, 33, 54, 98, 207, 498,
22, 24, 29, 41, 66, 120, 253, 609,
31, 33, 41, 57, 92, 169, 355, 854,
50, 54, 66, 92, 148, 271, 570, 1370,
92, 98, 120, 169, 271, 498, 1046, 2516,
193, 207, 253, 355, 570, 1046, 2198, 5289,
465, 498, 609, 854, 1370, 2516, 5289, 12725

This is the c++ code I'm using:

Code: Select all

        image.read( "in.jpg" );
        image.defineValue("jpeg", "q-table", "quantization-table.xml");
        image.write( "out.jpg" );
However, in my "out.jpg" I'm ending up with these QTs:
Luminance Quantization Table
2, 2, 2, 2, 3, 4, 6, 10
2, 2, 2, 2, 3, 4, 6, 10
2, 2, 2, 3, 4, 5, 7, 12
2, 2, 3, 3, 4, 6, 9, 14
3, 3, 4, 4, 5, 8, 11, 18
4, 4, 5, 6, 8, 10, 16, 25
6, 6, 7, 9, 11, 16, 23, 37
10, 10, 12, 14, 18, 25, 37, 60
Chrominance Quantization Table
2, 3, 3, 4, 7, 13, 27, 65
3, 3, 3, 5, 8, 14, 29, 70
3, 3, 4, 6, 9, 17, 35, 85
4, 5, 6, 8, 13, 24, 50 120
7, 8, 9, 13, 21, 38, 80 192
13, 14, 17, 24, 38, 70 146 352
27, 29, 35, 50, 80 146 308 740
65, 70, 85 120 192 352 740 1782

Is this a bug or am I doing something wrong?
Last edited by cujsmith on 2016-10-15T11:39:05-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Custom Quantization Tables

Post by snibgo »

Sorry, I know nothing about JPEG quantization.
snibgo's IM pages: im.snibgo.com
cujsmith
Posts: 8
Joined: 2016-10-13T16:18:14-07:00
Authentication code: 1151

Re: Custom Quantization Tables

Post by cujsmith »

Anyone out there know how I can fix this and encode with the desired QTs?
Post Reply