midterm 1 - code and data storage Flashcards
lect 5 - 6
explain ascii (define + binary storage method + specific bit usages)
american standardized code, international exchange
standardized method for converting binary/numbers to characters
1 byte per character
7 bits to identify
8th bit used as redundancy for error detection in the stored data
explain unicode
advanced ascii –> allows for emojis + more characters by combining preexisting unicodes to form new ones
due to expanded character complexity, data is stored as hex instead of binary
UTF8
character encoding, a combination of ascii + unicode
uses variable length encoding –> allows simpler characters to take up less data storage
data storage per character
ascii = 1 byte
non-ascii unicode = 2+ bytes
utf8 uses up to 4 bytes for a single character
explain RGB
red, green blue = primary digital colours
for a given pixel, each colour is value is stored as 1 - 255 –> max 8 bit per colour. combining colour values gives diff mixes
red-blue = purple
blue-green = cyan
red-green = yellow
all3 = white
therefore 1 pixel requires 24 bits of data (8 bits, 3 inputs) –> therefore 1 pixel can be 2^24 diff possible colours
storing colour values as hex code
RRGGBB
hex colour codes allows more presentable/easily interpretted colour encoding
note how 4 bits are encoded as 1 hex value. therefore if 8 bits per colour value, use 2 hex codes per colour value. a # prefix denotes a hex colour code
how to interpret/approximate hex colours
check the first hex digit per colour
0 = nothing
F = max value
eg
#F2B732 = high red + high green + low blue –> yellow
translate to binary as
1111(F) 0010(2) R
1011(B) 0111(7) G
0011(3) 0010(2) B
raster image construction
raster image encodes resolution + colour depth of image
colour depth = colour bits per pixel
In most cases, 24 bit colour depth –> 3 bytes per pixel
so the first portion of code describes dimensions. everything afterwards is used to encode RGB per pixel
vector image construction
vector file encodes geometric math to determine edges/vertices, then fills in spaces with colours accordingly
raster vs vector imaging
since raster hardcodes pixel colours –> zooming in only scales up each pixel therefore individual pixels become easily identifiable, degrading clarity
since vector images use geometry to draw the image, scaling up the vector image retains image clarity
video files
comprised of series of images/frames
inherently limited by colour depth, resolution, frame rate
therefore inherent loss of details
–> see also: audio digitization
series of slightly changing frames –> move quickly –> illusion of video motion
audio digitization
sampled several times per second –> Hz
higher hz = cleaner audio recording
recording resolution = bit depth –> sample amplitude value
more audio bits = more audio accuracy
less audio bit depth = poor audio quality
less hz = lose the higher audio freqs
audio file to sound conversion
requires digital-audio converter (dac)
poor dac = poor audio regardless of recording quality
digitization aliasing –> audio files
aliasing = distortion/artifacting due to loss of detail during digitization
eg low audio file hz
audio recordings must be AT LEAST 2x the peak hz of the input audio to prevent aliasing
therefore if a signal peaks at 25 khz –> recording must be at least 50 khz
binary to file interpretation
initial portion of file binary encodes file format identifier –> denotes file type
programs read file ID –> determine if the code can be interpretted
based on the file type, the binary encoding differs
images –> resolution parameters + indiv pixel RGB values
audio –> sampling hz + audio depth/amplitude values per sample
videos –> resolution + colour depth + audio hz + audio depth