Ijraset Journal For Research in Applied Science and Engineering Technology
Authors: Vedarutvija Joopally, Akhil Kaundinya, Annapurna Rao
DOI Link: https://doi.org/10.22214/ijraset.2023.53847
Certificate: View Certificate
As technology is growing drastically day by day, undoubtedly there is a rapid increase in demand for image processing in every field. Each day billions of images are clicked. Collecting and analyzing those images may give us amazing results in our real-time applications. There are many different applications of image processing in the areas of space, medical, traffic, and banking, such as planet discovery, brain tumor detection, fraud detection, and object detection, etc. The objective of this research is to compare images of different formats, different resolutions, and different sizes and analyze the differences between them. We have used open-source Python libraries, OpenCV, and Pillow which are helpful in the computer vision area. Our analysis found that working with the pillow library is more accurate than working with the OpenCV library.
I. INTRODUCTION
We conserve the beauty of the world in the form of images. In the past, images were just memories but in today’s fast-growing world, information in images plays a crucial role. Each image contains a lot of information that can be used in different ways. Image processing is a technique to extract the required information from an image. It is a type of signal processing in which we use different operations and techniques on images for obtaining desired output. Computer vision has given a new dimension to the real-time world in the field of IOT, AI, and robotics. It has a wide range of applications in almost every field. There are many image processing techniques we can use in predicting the results using advanced algorithms in machine learning and deep learning which allows us to manipulate and process image dictionaries. In our research, we compared two same images of different formats, different resolutions, and different sizes and analyzed the results. Not all image file formats store the same information, and each file has its own applications and advantages While working with image processing techniques, it is important to understand the difference in the information stored in the digital images that we process. It is important to consider which file format is most appropriate for a given scenario. Python with its rich image-processing libraries is the most commonly used programming language for deep learning and neural networks. In our study, we have used the famous library OpenCV and Pillow to work on the images to understand the differences in the digital information stored in image formats.
A. Image
An image is a two- or three-dimensional visual representation of an object. It can be a colored or grayscale representation of an object, photograph, picture, or subject. Images can be captured by cameras, telescopes, and microscopes. They can also be paintings, banners, computer graphics, or carvings. Images can be of humans, nature, statistical representations in the form of graphs and maps, etc. Black and white images record the intensity of light. Color images are generally in the Red Green Blue (RGB) format, which is commonly used in digital images. Images of the CMYK (Cyan, Magenta, Yellow, and black) format, with four colors, are available with printers. Images captured by ultrasound and X-rays are non-optical, which record sound intensity or X-rays.
There are different image file formats and each has its own advantages and disadvantages. In general, images are of two main types Raster and Vector. Raster images are either captured by a camera or scanner or are created using software which works with pixels. On the other hand Vector images are created by vector software like CAD.
B. Vector Images
Vector images consist of lines and curves on grids. These images are not made of pixels. Mathematical formulas are used to capture the size border and shape of images.[2] The number of colors can be easily increased and decreased as per requirement. Change in dimension is done by formula change and grid change and does not affect the quality of the image.
Illustrations and logos are the best examples of vector images. Vector images are of small size and can be easily converted to raster images. AI, CDR, SVG, EPS, and PDF are some of the commonly used types of vector images. And some of the commonly used vector programs are Illustrator and CorelDraw.
In our research, we have only taken and analyzed different raster image formats. We have considered JPEG/JPG, PNG, BMP, and GIF image formats for our analysis.
C. Raster Images
Raster images are built of tiny pixels or squares where each pixel has its own property. The density of a pixel defines image clarity. More pixels give more clarity to the image. The number of pixels in a photograph decides the image file type. JPEG, GIF, and PNG are examples of such file types. As the number of pixels in an image is fixed and the image has a defined dimension, expanding the image with less number of pixels distorts the image affecting the quality of the image. These images are also called bitmap images. When the quality of the image matters raster images are best with every pixel detail. Better the quality, the bigger the size. Software like Photoshop is used to edit Raster images which have the capacity to edit each pixel. PNG, JPG or JPEG, BMP, GIF, PSD, EPS, and PDF are some of the most commonly used raster images. And some of the commonly used raster programs are Photoshop, Paint, and GIMP. In our research we only considered raster images for our analysis.
JPG (Joint Photographic Experts Group) is a standard image file format and requires less storage than other formats. It uses a lossy compression algorithm which means there is a loss in the image information while reducing the number of bits to represent the given information unlike PNG (Portable Network Graphics), BMP(Bitmap Image File), and GIF. It uses 24-bit representation for colour and can display 16.8 million colors. The raw format photograph is generally converted to JPG format with compression by photographers for easing mailing, sharing, presentation, and web display. During compression of JPEG image, the RGB image is transformed into luminance/chrominance image. The chrominance part is compressed by changing color value and grouping pixels of uniform color together.
Alpha channel is absent in JPG. Comparing JPG images of the same image with JPG file type doesn’t show any difference as both of the images have the same pixel values, same size, and same resolution.
2. PNG
A PNG (Portable Network Graphics) is the most widely used format. The most important feature of PNG is that it supports transparent and semi-transparent backgrounds. The transparency should be placed on a colored background. Which are generally used with Logos. Non-transparent images have white backgrounds. PNG files use lossless compression and support 16 million colors. These types of files consume more storage space because of their big size. The number of channels in PNG depends on whether it is a colored or grayscale image and has an alpha channel. Some of the PNG supports are Adobe photoshop, Corel’s Photo Paint and GIMP. Medical Imaging is the main application area of PNG images because the reconstructed image after decompression is exactly the same as the original image. [1]
3. BMP
Bitmap Image Files (BMP) on the other hand contain bitmap graphics data, they are independent of the device. Image data is usually uncompressed or compressed with a lossless compression algorithm. It also contains an Alpha channel like a PNG file. It uses more space. The BMP file format is capable of storing colored or monochrome two-dimensional image. It is commonly used across different operating systems. BMP files lack compression and are compressed using algorithm like ZIP as they contain redundant data. Like PNG, BMP also supports transparency and commonly used extensions are .bmp and .dib
4. GIF
Graphics Interchange Format (GIF) images contain one or more frames containing images. These images may be of similar or different formats. It can be multiple PNG or JPG images making a GIF file. The logical screen is filled with single image or sub-images represented by separate palette of 256 colors in RGB format with 8 bits per pixel. but well-suited for simpler images such as graphics or logos with solid areas of color. GIF images use lossless compression best suited for logos, cartoons, and greyscale photographs. If the image has multiple frames and if they are painted with time delays they facilitate animation. Because it is animated video graphics.
Hence the comparison of a JPG or PNG file format with a GIF file is unveiled. It is not possible to compare GIF, a multi-frame image with JPG, which is a single-frame image. In order to achieve this, the frames from the GIF image file need to be extracted to be compared with a JPG file with a single frame iteratively. GIF images are popularly used on Facebook and Twitter.
D. Alpha Channel in Images
In addition to the color for each pixel, BMP, PNG, and TIFF images may also contain information that denotes pixel's transparency - the so-called alpha channel. Depending on the alpha value, a pixel may range from fully transparent (0%), to semi-transparent to fully opaque (100%).
If the baseline image contains the alpha channel, the comparison is performed regarding the pixel’s transparency. Fully transparent pixels are ignored during the comparison, opaque pixels should have the same color to be reported as matching, and the colors of semi-transparent pixels should resemble one another to some degree (at that, the degree of conformity is determined by the alpha value).
II. IMAGE COMPARISON
Digital images are taken as 2D signals and image processing extracts useful information from them. Image comparison may be aimed to find subsequent changes in the image which look similar to the human eye or to find the nearest similarity between two different images. Our study includes images of same format compared with change in resolution and size, same image when converted and stored in a different format. Python libraries OpenCV and PIL are used for the analysis.
A. Resolution Change
Resolution is crucial in image processing to analyze and study differences between two images. It also helps us a lot in object detection. Changing the resolution (DPI – Dots per Inch) of the image outputs both images as different using OpenCV. The same is the case with Pillow library. When an image of low quality is compared to an image of high quality, the PPI (Pixel Per Inch) varies in both images which makes a difference in the quality of the image. The more the value higher the quality and vice versa. When we decrease the quality and compare it with a high-quality image, the output we obtained is a dim graphical image.
III. OBSERVATIONS AND FUTURE WORKS
We have chosen a JPG image format which is a lossy format and converted it to respected formats (PNG, TIFF) for analysis. It is clearly seen that the pillow library always gave better possible results compared to OpenCV. OpenCV only compared 3 channels in the case of TIFF vs BMP comparison which gave us false results while the Pillow library compared all 4 different channels and hence produced the correct results. In section 2.2 it is observed that the RGB values are true implying both TIFF and BMP images are the same. But the Pillow library has given a blue shade image as an output which means there is a difference beyond pixel data which we will be researching in our future works. And it is advised to only choose lossless formats for conversion if you don’t want data loss.
Python provides a number of libraries to convert one image format to another but while comparing we should not use lossy formats for conversion. lossless formats should be used to convert images into different formats so that we don’t lose any image data. If the two images differ both in file size and quality we should compare one parameter at a time. The images of different sizes, different resolutions, and different image formats have been compared and analyzed. We have used two different libraries to achieve this. OpenCV (Open-Source Computer Vision Library), developed by Intel, and Pillow (Python Imaging Library) by Fredrik Lundh and Contributors. In conclusion, we found that the pillow library is friendlier compared to OpenCV and gives the correct output. Because the pillow library can be used to compare images in depth. It uses all the channels while comparing two images including the alpha channel. But OpenCV only compares three channels which shows the pixel-wise output is the same and it outputs both the images are completely the same, which we concluded as wrong in our case with BMP file format. This can give a wrong conclusion that both the images are the same but when the pillow library is used the difference is shown clearly, though the pixel values are also not the same. This concludes Pillow is better to use than OpenCV while working with image formats. Data Availability Statement The datasets generated during and/or analyzed during the current study are available in the [Image Processing] repository, [https://github.com/Vedarutvija/Image-Processing]
[1] Gomathi Kasi Viswanathan, Rayappan Lotus: Comparison and analysis of Image File Formats. [2] Prof. Shilpa Hiremath, Dr. A Shobha Rani: Concise Report on Image Types, Image File Format and Noise Model for Image Preprocessing (2020) [3] Lk Tan, et al., : Image file formats (2006) [4] Comparing Images, https://link.springer.com/chapter/10.1007/978-1-84628-968-2_17 [5] How to compare images fairly, https://kornel.ski/en/faircomparison [6] https://support.smartbear.com/testcomplete/docs/testing-with/checkpoints/regions/factors-affecting-image-comparison.html
Copyright © 2023 Vedarutvija Joopally, Akhil Kaundinya, Annapurna Rao. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.
Paper Id : IJRASET53847
Publish Date : 2023-06-07
ISSN : 2321-9653
Publisher Name : IJRASET
DOI Link : Click Here