data – how (much of) it is stored
DESCRIPTION
Data – How (Much of) It Is Stored. Outline. What Is an Image Really? Methods of Storing Images How to Make a Big File Small Compression Algorithms Conversion Algorithms In theory In practice. What is an image?. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/1.jpg)
1CS 128/ES 228 - Lecture 7a
Data – How (Much of)It Is Stored
![Page 2: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/2.jpg)
2CS 128/ES 228 - Lecture 7a
Outline
What Is an Image Really? Methods of Storing Images How to Make a Big File Small Compression Algorithms Conversion Algorithms
In theory In practice
![Page 3: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/3.jpg)
3CS 128/ES 228 - Lecture 7a
What is an image? An image is anything we store on
the computer that we think of as a “picture”. It should look “the same” on any display.
Image file formats GIF, JPEG, TIFF, BMP NOT shapefiles
![Page 4: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/4.jpg)
4CS 128/ES 228 - Lecture 7a
File Formats There are many image file formats
35 on the first page I hit looking for a list!
Each has advantages and disadvantages
![Page 5: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/5.jpg)
CS 128/ES 228 - Lecture 7a 5
GIF Developed by
Compuserve in 1987
Particularly good for line drawings (anything with sharp edges)
VERY common on web
![Page 6: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/6.jpg)
6CS 128/ES 228 - Lecture 7a
JPEG (or JPG) Product of the Joint
Photographers Experimental Group
Good for photos, images with subtle changes
Also popular on the web
![Page 7: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/7.jpg)
7CS 128/ES 228 - Lecture 7a
GIF vs. JPEGJPEG GIF
Use For “Realistic” artwork Illustrations
Compres-sion
Lossy, but controllable Lossy, no control
Colors 24-bits 8-bits
Others No transparency Transparency
![Page 8: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/8.jpg)
8CS 128/ES 228 - Lecture 7a
JPEG 2000 (aka JP2) “The JP2 and JPX file formats allow for
handling of color-space information, metadata, and for interactivity in networked applications as developed in the JPEG Part 9 JPIP protocol.”
Some imagery is now distributed as JP2 files – datum and projection included at no extra charge!
![Page 9: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/9.jpg)
9CS 128/ES 228 - Lecture 7a
Portable Network Graphics (PNG) PNG also stands for “PNG’s Not GIF”
Loss-less compression using non-patented algorithm
Supports transparency, but not really animation
ISO standard since 2003
![Page 10: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/10.jpg)
10CS 128/ES 228 - Lecture 7a
BMP Bitmap format –
Primarily for Windows (but not exclusively)
NO Compression means LARGE files
Standard Screen Snapshot is BMP
![Page 11: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/11.jpg)
11CS 128/ES 228 - Lecture 7a
EPS, PICT, TIFF
Encapsulated PostScript (mostly for printing, some display)
PICTure format (Macs only)
Tag Interchange File Format (multi-platform, but less used these days)
![Page 12: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/12.jpg)
12CS 128/ES 228 - Lecture 7a
Shapefiles and active software A running program may read from or
write to these formats, but generally uses its own memory management while running.
Shapefiles contain shape information and are not in any of these formats – and not truly image files They are vector layers, after all
![Page 13: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/13.jpg)
13CS 128/ES 228 - Lecture 7a
Compression Algorithms Compression
algorithms “shrink” files
May do so by mathematical “tricks” or by discarding information
![Page 14: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/14.jpg)
14CS 128/ES 228 - Lecture 7a
Two KEY Facts about Compression
NO LOSS-LESS compression algorithm can work all the time!
NO LOSSY compression algorithm can regenerate its original data.
![Page 15: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/15.jpg)
15CS 128/ES 228 - Lecture 7a
An LOSS-LESS ExampleRun-length compression Count and record the length of the data
set and then each group of 0’s or 1’s
111010011100001000000
3 7 0 3 1 1 2 3 4 1 6
![Page 16: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/16.jpg)
16CS 128/ES 228 - Lecture 7a
A LOSSY ExampleTruncation
12421449030293570214935210952172590275653048282535
124 029 935725 304
12400000000290000000935000000072500000003040000000
![Page 17: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/17.jpg)
17CS 128/ES 228 - Lecture 7a
How much does compression affect image quality?
Original (32 MB)
Compressed(493 kB)
![Page 18: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/18.jpg)
18CS 128/ES 228 - Lecture 7a
Converting Vector to Raster Must compute the equation of the
line
Then choose which pixels to highlight
Many algorithms, but differences are technical
![Page 19: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/19.jpg)
19CS 128/ES 228 - Lecture 7a
Typical algorithm
Y = y0 + 1
Illuminate pixel (x, int(Y))
Y = Y + 1 X = X + 1 /m
Illuminate pixel (x, int(Y))
…
Until Y == y1
X = x0 Y = y0
Illuminate pixel (x, int(Y))(x1,y1)
(x0,y0)
![Page 20: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/20.jpg)
20CS 128/ES 228 - Lecture 7a
Anti-aliasingBasic idea – Remove the “jaggies” by using color
variations
![Page 21: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/21.jpg)
21CS 128/ES 228 - Lecture 7a
Conversion in practice
![Page 22: Data – How (Much of) It Is Stored](https://reader036.vdocuments.us/reader036/viewer/2022062501/56816397550346895dd4900a/html5/thumbnails/22.jpg)
22CS 128/ES 228 - Lecture 7a
Converting Raster to Vector Basic idea
Find areas with sharp changes – these are your boundaries.
Adjust as topology indicates
Much harder in practice than the other way around
Alternative is hand-digitization