Definition of "Sample" in jpeg

Started by
3 comments, last by cheez_keeper 18 years, 4 months ago
Hello! I am currently working with the jpeg format and I came across the term "Sample" but I could not find information about what a "Sample" in the jpeg standard is. Can someone give me further information? thank you,
Advertisement
I'm not familiar with the jpeg format, but for an image, a sample would be the color value at a particular point. If "pixel" is the smallest granularity we can deal with, then a pixel and sample are isomorphic. The term "supersampling" typically means that we are actually dealing with atomic samples smaller than a pixel in such a fashion that several samples are combined to get a pixel's value. Supersampling is the opposite of this, a number of pixels are all determined by a single sample.

Edit: On second thought, there is no way of telling without some specifics. A sample in general just means a point from some space ... this could be a point in color-space, as GIF formats have an array of color-space samples. And outside of images, there are tons of uses for the word "sample", so you really cant tell without giving some context.
in JPEG the term "Sample" seems to have a specific meaning. It must have something to do with the Y Cr Cb components.
in "http://white.stanford.edu/~brian/psy221/reader/Wallace.JPEG.pdf" on page 8, there is a sketch and in the text stands: "A sample is defined to be an unsigned integer with precision P bits, with any value in the range [0, 2P-1]. All samples of all components within the same source image must have the same precision P. P can be 8 or 12 for DCT-based codecs, and 2 to 16 for predictive codecs.".

But it does not help me further...
jpeg compression uses the discreet cosine function to turn groups of 8x8 pixels into a set of much more compressable numbers. i am sure that sentance wont make sense to anyone but people who have had image processing... so here is my best to try to sum it up.

you can represent a discreet square wave with a cosine funtion to several powers. basically it is turning a nice smooth cosine wave into a square wave (google cosine wave and square wave to see what i mean) using a math funtion to several powers. using the same type of function, you can make that cosine wave(s) emulate a square wave that doesnt go from 0 to 1 ... for instance if you drew a line across an image you might get values of .2, .1, .9, 0., .2, etc... you can then use that discreet transform funtion to make up a cosine wave that will come *close* to those values at those points.

now if you take that wave and multiply it by 8 (so you have 8 waves going across a 8x8 chunk) you can get a pretty good idea of the stuff in there. if you make another set of 8 waves going, say down, then you get a darn good representation of what is in there when you average the two together.

2 (the lowest .jpeg sample) is a set of waves (8, i believe, in all directions) going criss-cross (diagonal i believe is the first 2 waves). 4 would give you 4 sets of waves going in 4 directions (since down/up is the same as up/down). when you get out to the highest samples of like 16, you basically have sets of waves going in so many directions over each 8x8 chunk of data that the compression errors are almost nil. by the same token, all that data takes up a lot more space.

if you play around with .jpeg compression, you will find that 4 waves is about the cutoff. any less and the human eye can determine differences, any more and you will find that the human eye cannot distinguish the difference (seriously, look at the colors 123,154,67 and 124,153,65 right next to each other... you CANT see the difference even though they are mathmatically not the same). if you want lossless compression, dont use .jpeg. if you dont mind a little color information that you cant see going away (high frequencies are lost even at the higher sample rates) .jpegs are great for image storage.
Brett Lynnescheez_keeper@hotmail.com

This topic is closed to new replies.

Advertisement