🟢Introduction
PPM, PGM, and PBM are three different types of image file formats that are used for storing digital images. These formats are particularly useful for storing grayscale and black-and-white images, as they are relatively simple and take up less space than more complex formats like JPEG and PNG. PPM, or "Portable Pixmap," is used for storing colour images, while PGM, or "Portable Graymap," is used for storing grayscale images. PBM, or "Portable Bitmap," is used for storing black-and-white images. Each of these formats has its own set of advantages and disadvantages, and the choice of which format to use will depend on the specific needs of the image and the application it will be used in. In this article, we will take a closer look at PPM, PGM, and PBM image files, exploring their features, use cases, and how to work with them in various software applications.
🟢PPM ➡Portable Pixmap
🔹PPM, or "Portable Pixmap," is a type of image file format that is used for storing digital colour images. The format is relatively simple and can be used to store images with a wide range of colour depths, from 8-bit per channel to 32-bit per channel. PPM images are typically saved in the ASCII or binary format, and the file typically has a .ppm file extension. The format is supported by a wide range of image editing software, making it a popular choice for image manipulation and storage.
🔹For example, A PPM image of a sunset can be represented as a matrix of pixels with different RGB values, where each pixel represents the colour of that specific location in the image. The image file might contain information such as image width, height, and colour depth and also the matrix of pixels with their corresponding RGB values. PPM is a lossless format, meaning that the image data is not compressed and the image quality remains intact after it's saved and opened again. This makes it ideal for applications where image quality is a primary concern, such as scientific or medical imaging.
🔹The following are all valid PPM headers.
✔
✔
✔
🔹Generally, a PPM file exists in the following way:
🔹If the PPM magic identifier is "P6," the image data is saved in byte format, with one byte for each colour component (r,g,b). Comments can only exist before the last header field, and only one byte can appear after the last header field, which is usually a carriage return or line feed. "P6" picture files are clearly smaller than "P3" image files and significantly faster to view. It should be noted that "P6" PPM files can only be used for single-byte colours.
🔹While it is not required by the format specification, it is a common practice to store the image from top to bottom, left to right. Each pixel is stored as a byte, with values 0 equaling black and 255 equaling white. Red - green - blue is the "normal" order in which the components are stored.
🟢PGM ➡Portable GrayMap
🔹PGM, or "Portable Graymap," is a type of image file format that is used for storing digital grayscale images. The format is similar to PPM, but it stores only one channel of information, rather than three (red, green, and blue). This means that PGM images can only represent shades of gray, rather than full-color images. The format is also relatively simple and can be used to store images with a wide range of grayscale depths, from 8-bit per channel to 32-bit per channel. PGM images are typically saved in the ASCII or binary format, and the file typically has a .pgm file extension.
🔹For example, a PGM image of a Black and White photograph of a cat can be represented as a matrix of pixels with different shades of gray, where each pixel represents the lightness or darkness of that specific location in the image. The image file might contain information such as image width, height, and the grayscale depth and also the matrix of pixels with their corresponding shades of gray values. PGM is a lossless format, meaning that the image data is not compressed and the image quality remains intact after it's saved and opened again. This makes it ideal for applications where image quality is a primary concern, such as scientific or medical imaging. It's also a good choice for images with large areas of solid color or images that require a high level of detail and accuracy.
🔹An example of a PGM file of type "P2" is given below
🟢PBM ➡Portable BitMap
🔹PBM, or "Portable Bitmap," is a type of image file format that is used for storing digital black-and-white images. It is a binary format, meaning that each pixel in the image can have only two values: black or white. The format is extremely simple, as it only needs to store a single bit of information for each pixel. PBM images are typically saved in the ASCII or binary format, and the file typically has a .pbm file extension.
🔹For example, a PBM image of a signature can be represented as a matrix of pixels with either black or white, where each pixel represents the color of that specific location in the image. The image file might contain information such as image width, height, and the color depth, which is 1 bit. PBM is a lossless format, meaning that the image data is not compressed and the image quality remains intact after it's saved and opened again. PBM is not recommended for most general-purpose image manipulation, as it can only represent a limited range of images. However, it can be useful in certain specialized applications, such as image processing, where the image is used as a mask or as an input to a black-and-white image processing algorithm.
🔹An example of a PBM file of type "P1" is given below
Thank You Soo Much for your valuable time.😊🥳👋
➲Mithin Dev
I would love to connect and collaborate.