In this article we will discuss Digital Image Processing. Let's begin from the basics.
What is an image ?
Basic definition of image is visual representation of something or someone. Example of any drawing, painting and photograph etc. It may be black and white or color.
orignal image
In other words, a digital image is a collection of pixels or an array or picture element (picture element) arranged in columns and rows. Image is defined in two dimensional function f(x,y) where x and y are spatial planes (co-ordinate) and the amplitude of f at any pair of coordinates (x, y) is called the intensity or gray level of image at the point. Digital image is composed of a finite number of elements each of which has a particular location and value. These elements are called picture elements, image elements and pixels.
Types of images
Binary image : Binary image contains only two pixels o and 1 hence it is known as binary image. 0 refers to black color and 1 refers to white color. It is also known as monochrome.
Black and white image : This image contains only two colors black and white. Hence it is known as black and white image. Black and white images and binary images are the same.
Format
Binary image have a portable bitmap
8 bit color format : In 8 color format there are 256 different color shades. It is known as a grayscale image. The range of the colors in 8 bit varies from 0-255. Where 0 stands for black, and 255 stands for white, and 127 stands for gray color.
grayscale image
16 bit color format
It is a color format and contains 65,536 colors. It is also known as high color format. A 1 bit color format is divided into three color formats which are red, green and blue (RGB format).
Code Snippet :
#import libraries
import cv2
#read image
orignal_image = cv2.imread('pexels-simon-migaj-747964.jpg')
#convert orignal image into grayscale image
gray_Image = cv2.cvtColor(orignal_image, cv2.COLOR_BGR2GRAY)
#convert orignal image into Black and white image
(thresh, black_and_white) = cv2.threshold(grayImage, 127, 255, cv2.THRESH_BINARY)
#save image
cv2.imwrite('Blackandwhite.png', black_and_white)
cv2.imwrite('grayscaleimage.png', gray_Image)
#Display image
cv2.imshow('Black white image', black_and_white)
cv2.imshow('Original image',orignal_image)
cv2.imshow('Gray image', gray_Image)
cv2.waitKey(0)
cv2.destroyAllWindows()
How computer read the image
A computer object in an image appears as an array of square blocks known as pixels assigned with the numerical values which indicate the intensity of the pixel. For a grayscale or a balck and white image each pixel have one value which ranges between to 255 but for color images each pixel have 3 values because the color image consists of 3 channels each representing red, green and blue color.
pixel of image
There are generally two types of image vector image and bitmap image.
Bitmap image : Bitmap images are stored as a series of tiny dots which are called pixels.
Vector image : Vector images are not based on the pixel pattern it is mainly based on the geometrical and mathematical formula.
Some of most common files format of image
Gif : Gif stands for Graphical interchange format. It is mostly used for the web. It is an 8 bit color format. It is a bitmap image.
JPEG : JPEG stands for Joint photographic Expert Group. It is a 16 bit color format. It is a standard image format for containing lossy and compressed image data.
PNG : PNG stands for Portable network graphics. It supports upto 16 bit channels. It uses lossless compressed data.
The RGB Color model
A color model is a specification of a coordinate system and a subspace within that system where its color is represented by a single point.
The color subspace of interest is the cube shown in Figure
What is Image Processing
Image processing is a technique of applying a relevant mathematical operation or an algorithm on a digitized image to generate an enhanced image or extract some useful information like shape, color and edge. The image processing generally includes three steps. The first step is to import the image by using the scanner or by digital photography. Second step is to analyze and manipulate the image which includes data compression, Image enhancement and spotting pattern. Output is the last stage in which the result can be altered. The purpose of image processing and various image processing operations that are widely used for example image segmentation, object detection, image enhancement, image restoration, color image processing, morphological operations etc.
Methods used for image processing operation
Image enhancement
Image enhancement is a technique of adjusting digital images so that the images are more suitable for display. For example If the image is overexposed and it needs the reduction in brightness then simply by subtracting a constant number from the pixel intensity value can reduce the brightness of the image to make it more realistic.
Code Snippet
#import libraries
import cv2
import numpy as np
# read image
image = cv2.imread('pexels-simon-migaj-747964.jpg')
image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
#number of increase brightness
increase = 70
v = image[:, :, 2]
v = np.where(v <= 255 - increase, v + increase, 255)
image[:, :, 2] = v
image = cv2.cvtColor(image, cv2.COLOR_HSV2BGR)
#save image
cv2.imwrite('increase_brightness.jpg',image)
Image Segmentation
Image segmentation is a process of partitioning a digital image into multiple regions and extracting the meaningful region which is known as Region of interest. For example we have an image where there is an image of cat, dog, bird, car etc. various objects are available in that particular image. Segregation of image cat, dog, bird and car. It means image segmentation is something which is about partitioning the image.
Code Snippet
#import libraries
import pixellib
from pixellib.semantic import semantic_segmentation
image_segment = semantic_segmentation()
#load the model
image_segment.load_pascalvoc_model("data.h5")
#save image
image_segment.segmentAsPascalvoc('cat.jpg', output_image_name = "output_sementic_image.jpg")
Object detection
Object detection is the term to describe a collection of data and identify the object in digital images captured by the cameras which are mounted on cars and this is done by using convolutional neural networks. convolutional neural networks have been successful image classifications in real world applications.
Image Restoration
Image restoration is the technique of taking a corrupt or noisy image to make it a clean image. Corruption image means it may be blur, noisy or camera mis-focus etc. It is performed by reversing the process that blurred the image and such is performed by imaging a point source and using the point source image, which is called the Point Spread Function (PSF) to restore the image information lost to the blurring process. Image restoration is different from image enhancement.
Morphological operations
Morphological image processing is a collection of non-linear operations related to the shape or morphology of features in an image. Morphology is generally concerned with the shape and properties of objects. There are two basic morphological operations, Dilation and Erosion.
Dilation : Add pixels to the boundaries of objects in an image. It expands the connected sets of the first binary image. It can be used for expanding shape and filling the holes, gaps and gulf.
Erosion : Remove pixels on object boundaries. It removes the isolated noisy pixels and removes the outer layer of object pixels i.e object become slightly smaller. It is used for smoothies object boundaries.
Morphological techniques probe an image with a small shape or template called a structuring element. Structuring element The number of pixels added or removed from the object in an image depends on the size and shape of the structuring element used to process the image.
תגובות