Posts

Showing posts with the label image processing

Color image processing and color models

Image
Color image processing The use of color in image processing is motivated by two principal factors: 1. The fact that color is a powerful descriptor it often simplifies object identification and extraction from a given scene 2. A human can discern thousands of colors shades and intensities, compared to about only a few dozens of shades of gray. Characterizing colors The characteristics generally used to distinguish one color from another are: 1. Hue: Hue is an attribute associated with the dominant wavelength in a mixture of white light. It represents the dominant color as perceived by the observer. 2. Saturation: Saturation refers to the relative purity or amount of white light mixed with a hue. The pure spectrum colors are fully saturated. Colors such as pink (red + white) are less saturated, with degree of saturation being inversely proportional to the amount of white light added. 3. Brightness: Brightness refers to the intensity of light. Hue and saturation toge

Multiplication of images

Image
Mathematical operations on digital images consist of: 1. Addition 2. Subtraction 3. Multiplication 4. Division Arithmetic multiplication: Arithmetic subtraction can be done using the following two ways: 1. Pixel to pixel multiplication of two images 2. Multiplication of a constant to an image Pixel to pixel multiplication of two images This is the most simple and straightforward operation applied on two input images of identical dimensions that produces an output image of dimensions identical to that of first two, in which a pixel value of the output image is the arithmetic multiplication of the corresponding pixels from the two input images. Mathematically, the multiplication operation of two images can be written as: m(x,y)=f(x,y)*g(x,y) Where f and g are the two input images of identical dimensions and m is the resulting output image while x and y are the spatial coordinates of the corresponding input and output images. If the pixel values in the inpu

Subtraction of images

Image
Mathematical operations on digital images consist of: 1. Addition 2. Subtraction 3. Multiplication 4. Division Arithmetic subtraction: Arithmetic subtraction can be done using the following two ways: 1. Pixel to pixel subtraction of two images 2. Subtraction of constant from an image Pixel to pixel subtraction of two images This is the most simple and straightforward operation applied on two input images of identical dimensions that produces an output image of dimensions identical to that of first two, in which a pixel value of the output image is the arithmetic difference of the corresponding pixels from the two input images. Mathematically, the subtraction operation of two images can be written as: d(x,y)=f(x,y)-g(x,y) Where f and g are the two input images of identical dimensions and d is the resulting output image while x and y are the spatial coordinates of the corresponding input and output images. If the pixel values in the input image are vectors (e.g. fo

Digital image formation

Image
Digital Image Formation The digital image conversion process involves namely two process, sampling and quantization. Digitizing the coordinates is called sampling . Digitizing the amplitude is called quantization . This digitization process requires decisions about values for M, N and for the number, L (where L =discrete gray levels allowed for each pixel).   There are no requirements on M and N (dimensions of an image), other than that they have to be positive integers. However, due to processing, storage, and sampling hardware considerations, the number of gray levels typically is an integer power of 2: L = 2^k    The discrete grayscale intensity levels are equally spaced and that they are integers in the interval [0, L-1]. Thus, for an 8 bit image (class: uint8) the number of discrete grayscale intensity levels are [0, 255]. The range of values spanned by the gray scale is called dynamic range of an image. The number of bits (b) required to store a digitized

Addition of digital images

Image
Mathematical operations on digital images consist of: 1. Addition 2. Subtraction 3. Multiplication 4. Division Arithmetic addition: Arithmetic addition can be done using the following two ways: 1. Pixel to pixel addition of two images 2. Addition of constant to an image Pixel to pixel addition of two images This is the most simple and straightforward operation applied on two input images of identical dimensions that produces an output image of dimensions identical to that of first two, in which pixel value of the output image is the arithmetic sum of the corresponding pixels from the two input images.  Mathematically, the addition operation of two images can be written as: s(x,y)=f(x,y)+g(x,y) Where f and g are the two input images of identical dimensions and s is the resulting output image while x and y are the spatial coordinates of the corresponding input and output images. If the pixel values in the input image are vectors (e.g. for color images) then th

Exploring digital images: Interactive design (Part 2)

Image
In the previous blog, we have seen the use of msgbox to have interaction with user. Let us know, use another interactive tool, called the menu to have more interaction with user. Octave code: clc; clear all; input_image = imread("ubuntu.jpg"); [height width channels] = size(input_image); figure, imshow(input_image); title("Input Image"); if channels == 3   msgbox("Input image is a color image");   choice = menu("Do you want to convert into grayscale", "Yes", "No");   if choice == 1    grayscale_image = rgb2gray(input_image);    figure, imshow(grayscale_image); title("Grayscale Image");    else    msgbox("Exiting execution prcoess");    close all;   end  else  disp("Input image is grayscale image")   imshow(input_image); end Output: Octave code Interactive msgbox Interactive menu option Output of above code Explanation: Menu is a interactive di

Exploring digital images: Interactive design (Part 1)

Image
Let us check whether the input image that we read is a color image or gray-scale image. As discussed earlier a color image has 3 channels (RGB) while a grayscale image has only one channel (brightness/intensity). In order to have, response based interaction with the user we can add interactive message boxes in GNU Octave. Otcave code: clc; clear all; input_image = imread("google.jpg"); [height width channels] = size(input_image); imshow(input_image); title("Input Image"); if channels == 3   msgbox("Input image is color image. Converting input image to grayscale");   grayscale_image = rgb2gray(input_image);   figure, imshow(grayscale_image); title("Grayscale Image");   else   disp("Input image is grayscale image")   imshow(input_image);   end Output: Octave code Interactive message box Output of the above code Explanation: [x,y,z]=size(): The  size function returns the sizes of each dimension of the ar

Converting a color image into grayscale image

Image
Gray-scale image: Gray-scale is a range of monochromatic shades from black to white. Therefore, a gray-scale image contains only shades of gray and no color. In a gray-scale image, the hue (apparent color shade) and saturation (apparent color intensity) of each pixel is equal to 0. The lightness (apparent brightness) is the only parameter of a pixel that can vary. Lightness can range from a minimum of 0 (black) to 255 (white) for an 8 bit gray-scale image. Octave code: clc; clear all; input_image = imread("ubuntu.jpg"); imshow(input_image); grayscale_image = rgb2gray(input_image); figure, imshow(grayscale_image); title("Grayscale Image"); Note : Kindly load the image package before executing the code. For more information on how to load packages click here . Output Color image converted into grayscale image Explanation : The functions imread() and imshow() have been discussed earlier.  rgb2gray(): The function rgb2gray converts a dig

Reading a digital image (color image) in GNU Octave

Image
Digital image: An image is defined as a two dimensional function of f(x,y), where x and y are spatial coordinates, and the amplitude of f at any pair of coordinates (x,y) is called the intensity of the image at that point. When x, y and the amplitude f are all finite and discrete quantities, we call the image a digital image. A color digital image: A color image consists of 3 channels- namely the R(Red), G(Green) and B(Blue). For more information on color image click here . Let us start with a simple code of reading a digital (color) image. Octave Code: clc; clear all; input_image = imread("Ubuntu.jpg"); imshow(input_image); Explanation: imread (): Reads the digital image and creates a variable input_image and stores  the digital image as a two dimensional array of size M×N ; where M equals to number of rows and N equals to no of columns. M and N basically represent the size of image in terms of height and width respectively. You can check the size of

Installing and loading packages in GNU Octave

Image
Installing packages in GNU Octave GNU Octave, unlike Matlab, does not come with preinstalled toolbox (or packages) and hence it is necessary to install packages in GNU Octave. You can find different packages by clicking here . You can install packages as required. Since we are working with images, we will require the image package. You can install the image package by executing following command in the Ubuntu terminal: sudo apt-get install octave-image Find packages installed in GNU Octave GNU Octave will install interdependent packages during installation. Once installed you can find the list of packages installed in your Octave by executing following command in the command window of GNU Octave: pkg list Finding package list installed in Octave Loading package in GNU Octave You can load a certain package by executing following command in the command of GNU Octave: pkg load image

Basics of GNU Octave

Image
Now have we installed GNU Octave, let's jump right into the basics of the software. You can open your GNU Octave through the application window by searching GNU Octave or through terminal by running a simple command: sudo octave The basic graphical user interface (GUI) will look somewhat as shown in the figure below(may vary if changed): GNU Octave GUI The basic windows that you observe are: 1. The command Window 2. Command History 3. File Browser 4. Workspace 5. And the menu bar