Picture
and Video Files
By Timothy Everingham, TUGNET (The User Group Network)
In regards to the size of picture, graphics, and video
files, when you try to compress files there reaches a point where you start to
lose something.
First you have to understand that if it is either an
image or video file each little pixel or time interval is represented by bits
of data. You may have heard 8, 16, 24, 32 bit color. The number of bits
represents the color of each pixel. On an 800x600 image you have 480,000 pixels
(800 multiplied by 600). Then you multiply the color bit depth to get the size of
the image representation (800 x 600 x 24 bit equals 11,520,000 bits). Divide by
8 and you get the number of bytes (11,520,000 bits divided by 8 equals
1,440,000 bytes). It get worse with video because you have to multiply by the
frames per second and by the number of seconds in the video (at a standard 30
frames per second it would be 41 Megabytes per second or 2.4 Gigabytes per
minute). Now if you have a lot of large image or video files you are trying to
transfer through a dial up connection to the Internet you have problems. If
that is the case, you just figure you will save and send things using a smaller
image size and blow up when it will be used. The problem is that when you go to
a smaller image size you loose detail in the process. Then when you try to blow
it up again it just gets blocky. The same thing goes for video files, the
smaller the file size the less detail and nuances are
in the file. This really shows up when you take a small image and then try to
project it using a good LCD projector. So if you want to project it, show it on a large monitor, or print it out large you need
to keep the image size up. This is one reason there is so much hype on the
amount of megapixels a digital camera has.
So how then do we get the small file size of images we
do. We use compression algorithms, also known as codecs
(compressor/decompressor). There are lossless and lossy compression algorithms. But how can there be lossless
compression? It is because nature is filled with patterns and uniform things,
which is what we take images of. So if we record info about the pattern instead of each pixel of it a lot of file space is
saved. An example would be if a person in your image is wearing a blue
sweater. Instead of recording every
pixel individually you record this area of the image, where the sweater is, in
blue. The Tiff image format (.tif) uses only lossless
compression techniques, so it is a good format for achieving purposes or
something you may wish to edit later. But then there is lossy
compression. You lose some of your detail, but a lot less than if you just
shrank the image. One of the regularly used lossy
compression techniques is color palette reduction. With 24 bit color you have
16 million colors available. However, there are far less that many colors in an
image. It takes less space to analyze which colors are in an image, and create
a custom color table that will represent all the color in the image in less
than 24 bits, write the color representation of the pixels with the custom
table code, and then include a copy of the table in the file. This can be used
as a lossless technique, but usually this is taken one step farther. In the
analysis of the image it is detected how often each color is used and ranked.
As the compression rate increases then thenumber of
colors that are less used are converted to colors that are close to it but are
widely used in the image. This compresses the size of the color table, which
decreases the bits per pixel representation of a color used and the blending to
nearby colors increases the space that areas of the image that can be described
as having one color (this is a situation of compression techniques
complementing each other). Some formats start out using only lossless
compression techniques but as the level of compression increases they start to
use lossy compression. Some common formats that use a
combination of lossless and lossy compression are GIF
(.gif) and JPEG (.jpg). Remember once you lose image data using a lossy technique you will not have it anymore unless you
still have the original or a lossless copy. The compression methods discussed
so far are referred to as spatial compression because they reduce the file size
by compacting the description of the visual area
(space) of an image.
Video is made up of sequential images played over time.
This means we can not only use spatial compression; but also use temporal
compression, which compresses the file using analysis of the difference and
similarities of the frames in an image. This usually exhibits itself by the
first frame in a video sequence being compressed just like a still image using
spatial compression, but in the following frames only the changes from the
previous frame is recorded. Periodically or when there are major changes
between frames, a new initial frame, also called a keyframe,
is produced followed by more just recording of differences between frames.
These temporal compressions can be lossy or lossless.
As with still images you should achieve them using only lossless compression.
However, using only lossless compression may be impractical because of the
limitation of your computers or hard drives’ speed or hard drive space, but
keep lossy compression at a minimum.
If you are creating a video DVD for achieving that uses
the MPEG-2 format that uses both lossy and lossless
compression techniques, it is better to achieve the file using the DV codec it
was originally imported in from your video camera and writing that file to a
data DVD or CD. Be aware that some compression techniques and settings are
better for some types of video than others. If you just have a talking head in
your video with a static background you can compresses it greatly without
degrading the image much, But if there is a lot of fast action or panning of
the camera, the amount of compression you can successfully have you have to be
more picky on what codec you should use.
File size matters because it limits what you can use the
file for. If you just want a small file you can send to a friend’s dial up
connection or have friends using a dial up connection view via a website a
small file is good. However in printing large photos, showing on a large
computer display or having it projected on a screen small files are not good.
Use only lossless compression techniques on things you want to achieve or edit
later because it keeps your options open. Keep your archival file large and
make smaller copies of it for other purposes.
It is fortunate that hard drive and DVD and CD blank
prices have come down a lot so doing this does not cost a fortune, but not
planning ahead on image size and which compression techniques can cost you not
being able to fully use your precious digital photos and videos.
Timothy
Everingham is Vice Chair of the Los Angeles Chapter
of ACM SIGGRAPH, the largest chapter of the Association for Computing
Machinery’s (ACM) Special Interest Group on Computer Graphics and Interactive
Techniques and one of Southern California's significant professional
organizations within the entertainment and media industries.
http://home.earthlink.net/~teveringham