First, I admit that this is a homework question. However, I seem to be stuck. I need to get all quantized coefficients from a jpeg image using Phil Sallee's JPEG Toolbox (link listed at the bottom of the table under an "update" heading)(I'll be building a histogram, but that part I can handle once I can get to the data I need). I have a JPEG image that is about 5 MB in size and get back this data when I run it through Sallee's code:
image_width: 3000
image_height: 4000
image_components: 3
image_color_space: 2
jpeg_components: 3
jpeg_color_space: 3
comments: {}
coef_arrays: {[4000x3000 double] [2000x3000 double] [2000x3000 double]}
quant_tables: {[8x8 double] [8x8 double]}
ac_huff_tables: [1x2 struct]
dc_huff_tables: [1x2 struct]
optimize_coding: 0
comp_info: [1x3 struct]
progressive_mode: 0
How do I get the quantized coefficients from this image? At first I tried something like this to just spit out the coefficients so I could see what I was dealing with:
pic = jpeg_read(image)
img_coef = pic.quant_tables{pic.comp_info(1).quant_tbl_no}
img_coef = pic.quant_tables{pic.comp_info(2).quant_tbl_no}
img_coef
is run twice because there are two elements to the quant_tables
data point above. However, this seems like a very low amount of coefficients for such a large image. Can someone more knowledgeable than me in this regard point me in the right direction? Where/how do I pull the quantized coefficients from a jpeg image?
This will open a file, pull off the luminance, Cr and Cb arrays, and the two quantization arrays. It will then quantize luminance, Cr and Cb into their own variables.