Video. We will consider how electronic pictures are made up. Consider some important characteristics of electronic images. See how image are represented in a computer. Appreciate compromises and limitations.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Video • We will consider how electronic pictures are made up. • Consider some important characteristics of electronic images. • See how image are represented in a computer. • Appreciate compromises and limitations. • Finally you will be able to edit individual picture elements and change the brightness, contrast and colour of an image, as say Photoshop may do.
The television picture • Consider monochrome first. • The image that we see on our monitors is composed of a series of horizontal lines. • In the television signal the brightness of the line varies continually along the line. • However, the picture is sampled in the vertical direction. • Subject to aliasing. Limits vertical spatial resolution.
Spatial resolution. • Is the amount of detail in the vertical and horizontal direction we can resolve (see). • Our eyes can only resolve a minimum angle. • Therefore viewing monitor size and viewing distance determine how much spatial resolution we require from our television pictures.
Spatial resolution. • We do not want to see the individual lines of a television picture. • If the television picture is to have good spatial resolution we must have a minimum number of lines. • The more lines (vertical samples) the higher the resolution.
Aspect ratios • The maximum angle that our eyes can see (without moving them) is greater in the horizontal direction. • Therefore square televisions are out. • Television screens are larger horizontally than vertically. • The ratio of the wide to the height is called the aspect ratio. • Two common television aspect ratios are: • 4:3 • 16:9
The digital picture and pixels. • In the computer we cannot represent television’s horizontal line. • So we represent it as a series of samples (of the television picture) along the line. • In digital video each sample is called a pixel (picture element). • Digital picture sampled in the horizontal or vertical directions.
How many samples? • The higher the number of samples, the better is the spatial resolution. • There is no real reason to make the horizontal resolution much better (or worse) than the vertical resolution. (Although the eye’s response it not exactly equal).
How many samples? • It may seem simple therefore to make the horizontal resolution equal to the vertical resolution. • Although there may be nominally 625 lines in the European television picture, not all of these lines are used to transmit the picture. They are used and reserved for other purposes. • In the American NTSC standard there are nominally 525 lines per frame, but only approximately 480 lines make up the actual picture.
How many samples? • There are effectively therefore 480 samples in the vertical direction. • If we: • keep the spatial resolution in the horizontal and vertical directions equal. • Have square pixels. • Maintain a 4:3 (Width : Height) aspect ratio. • How many samples do we need in the horizontal direction?
How many samples? • Answer: • 4/3 x 480 = 640 • The NTSC television based 640 x 480 resolution has become a standard for computers. • Other higher (we view computer monitors more closely than television) computer standard resolutions exist : • 800 x 600 • 1024 x 768 • All 4:3 aspect ratio.
Total number of samples, physical significance • We can consider a block of 640 horizontal samples (in a 640 x 480 image) as a television line or a row of a 2 dimensional matrix. • The full picture is made up of 480 such lines stacked on top of each other. • Any given position in each horizontal block (line) forms a column (vertical line) with that same position in those blocks above and beneath any given line. • We can consider our digital picture as a horizontal matrix.
Brightness and contrast • The value of each point in this two dimensional matrix represents the brightness of a pixel. • In other words brightness is the absolute value of a pixel. • Contrast is the difference between the brightest pixel and the darkest pixel in an image.
Square or 4:3 pixels? • Instead of having different numbers of samples in the horizontal direction, some systems have equal numbers of pixels in both directions, but the pixels are not square and take on the aspect ratio of the image, nominally 4:3. • This therefore gives less horizontal resolution.
Colour • The visible spectrum consists of a continuous range of colours ranging from red to violet. • Our eyes sense colour by having three “receptors”: • One more sensitive to red. • One more sensitive to green. • One more sensitive to blue. • This allows us to “fool” the eye into seeing most (not all) naturally occurring colours by mixing red, green and blue lights to different degrees.
Colour • Television and computer monitors, have three types of light emitting phosphors: • One emits red light. • One emits green light. • One emits blue light. • So the colour television signal sends three sets of brightness information; for the red, green and blue.
Colour • In the digital form this means that we may need to save three separate images to represent colour. One for each of red green and blue. • The uncompressed colour picture is therefore three times larger than a black and white picture.
The bitmap format .bmp • Contains the following data structures: • BITMAPFILEHEADER bmfh; BITMAPINFOHEADER bmih; RGBQUAD aColors; BYTE aBitmapBits;
The bitmap format .bmp • BITMAPFILEHEADER
The bitmap format .bmp • BITMAPINFOHEADER
The bitmap format .bmp • BITMAPINFOHEADER
The bitmap format .bmp • RGBQUAD array for colour map (not used for 24 bit colour)
The bitmap format Notes • “biwidth” important for rows and column structure, change it and see. • Bitmap data is “upside down”. • “Length” data is LSB first.
Altering “biwidth” • fid=fopen('am8fix.bmp') • A=fread(fid); • A8=uint8(A); • A8(19:22) holds the width in little endian notation. • hex2dec('00000300') gives values in decimal. • Let’s halve it. • A8(19)=128; (is equal to 8016) • A8(20)=1; (01 8016 equals 38410) • fid=fopen('newpix.bmp','wb') • fwrite(fid, A8) • fclose(fid)
Loading, saving and showing bitmaps in Matlab • A=imread(‘filename.bmp’) • imwrite(Array,‘filename.bmp’) • image(A) • Change “edit -> axis properties” to “Set axis equal shape” • Note that A is class uint8.
Accessing rows and columns of pixels. • A single pixel • A(row, column, red:blue) • Eg A(3, 5, 1:3)=127 Changes the value of red, green and blue values of the pixel on row 3, column 4 to 127. • A set of rows • A(20:30, :, 1:3)=64 • A set of columns • -A(:, 20:30, 1:3)=64
Removing lines and columns from the image • Lines • newimage= [image( 1:flr, : , :) ; image(llr:end ,: ,:)] • Columns • newimage= [image( :, 1:fcr, :, :) image(:, lcr:end, :)] Where flr, llr, fcr and lcr stand for: first line removed last line removed first column removed last column removed
Piecing two images together. • Linewise • newimage= [image1( start:end, : , :) ; image2(start:end,:,:)] Images 1 and 2 must have same number of columns • Columnwise • newimage= [image1( : , start:end, :) image2(:, start:end, :)] Images 1 and 2 must have same number of lines.
Altering the overall brightness and contrast of an image. • Brightness • An offset operation • Use + or – • Contrast • A scaling operation • Use * or / • You will have to cast uint8 to double before using +, -, *, or / (and then back again) • Exceeding 255 will cause ‘clipping’. • Numbers less than zero will cause ‘crushing’
Changing the colour of an image. • Operate (+ - * /) on different colours • Example • Give picture a red lift piccycopy =piccy piccycopy(:, :, 1) = piccycopy(:, :, 1) + 20
Matlab’s “colormap” • Translates numbers into colours.