Posts

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