Representing Images (OCR GCSE Computer Science): Revision Notes
📚 Revision Notes
Representing Images
Images are stored as a series of pixels, and each pixel has a specific colour that is represented by a unique binary code. The more pixels an image has and the more bits used to represent each pixel, the higher the quality and size of the image.
Image Terminology
Pixel
- A pixel (short for "picture element") is the smallest unit of an image, representing one specific colour.
- Each pixel is stored as a binary value.
Colour Depth
- The colour depth is the number of bits used to represent each pixel.
- More bits per pixel allow for more colour combinations. For example:
- 1 bit = 2 colours,
- 2 bits = 4 colours,
- 4 bits = 16 colours,
- 8 bits = 256 colours.
- A higher colour depth means more colours and greater image detail, but also a larger file size.
Resolution
- The resolution refers to the number of pixels in an image and is often measured in dots per inch (DPI).
- The higher the DPI, the more pixels are used, which results in a sharper image.
- Higher resolution increases image quality but also increases file size.
Metadata
- Metadata is additional information stored about the image.
- This includes details like:
- Resolution (number of pixels),
- Width and height of the image,
- Colour depth (how many bits per pixel),
- Information like exposure, ISO, aperture, and the file format.
Effect of Colour Depth & Resolution on Image Quality & File Size
Larger Colour Depth and Higher Resolution
- Results in higher image quality because more colours and pixels are used.
- However, this also leads to a larger file size as more data is required to store the image.
Smaller Colour Depth and Lower Resolution
- Results in lower image quality, with fewer colours and pixels, but the file size is much smaller.
Calculating the Size of an Image File
To calculate the size of an image file, use the following formula:
- Size = Resolution × Colour Depth (in bits)
Worked Example
infoNote
Question: Calculate the size of an image with a resolution of 1000 pixels by 1000 pixels and a colour depth of 8 bits per pixel.
Step 1: Identify the Resolution and Colour Depth
- Resolution: The image is 1000 pixels wide and 1000 pixels tall, so the total number of pixels is:
- 1000 x 1000 = 1,000,000 pixels
- Colour Depth: The image uses 8 bits per pixel, which means each pixel can store 256 different colours.
Step 2: Calculate the Total Number of Bits
- To find the total number of bits needed to store the image, multiply the total number of pixels by the colour depth:
- Total Bits = 1,000,000 pixels x 8 bits per pixel
- Total Bits = 8,000,000 bits
- The image will need 8 million bits to store all the pixel data.
Step 3: Convert Bits to Bytes
- Since 1 byte = 8 bits, we can convert the total bits into bytes by dividing by 8:
- Total Bytes = 8,000,000 bits ÷ 8
- Total Bytes = 1,000,000 bytes
- So, the image file is 1,000,000 bytes.
Step 4: Convert Bytes to Megabytes
- To make the size easier to understand, we can convert bytes to megabytes (MB), since 1 MB = 1,000,000 bytes:
- 1,000,000 bytes = 1 MB
- Therefore, the file size is 1 MB.
Key Takeaways
- The resolution determines how many pixels the image has.
- The colour depth determines how many bits are used to represent each pixel.
- Multiply the total pixels by the colour depth to get the number of bits.
- Divide by 8 to convert bits to bytes, and further convert bytes to megabytes if needed.
infoNote
Key Points to Remember
- More pixels (higher resolution) and more bits per pixel (higher colour depth) give higher image quality but increase the file size.
- Metadata stores important information about the image such as resolution, size, and format.