Scilab IPCV represents images in a few formats. The 3 basic types of images supported in Scilab are:
- Binary images: Boolean -> %f, %t
- Gray Scale images: uint8 -> 0 to 255, double -> 0 to 1
- RGB images: m-by-n-by-3 matrix, could be uint8 and double
To see how Scilab imports and handles images, let’s see following tutorial.
While Scilab importing binary image, it will be represented in 2 values,%f for black and %t for white.
- Change to the working directory where the images located, for e.g.:
–> cd ‘pathto/IPCVfiles’;
- Read the image using “imread” command
–> S1 = imread(‘balloons_binary.png’);
From the variable browser, you should see the variable S1 created as an 296×300 boolean type. Double click the variable to launch the variable editor to see the values of the pixel in the image matrix.
- Use “imshow” command to visualize the imported image
- Try to manipulate the pixels value, for example, use the following command to change the pixels value to 255, which is correspond to white color.
–> S1(1:100,1:100) = %t;
- Use the “imshow” function again to show S
We are actually adding a white patch on the upper left corner of the image.
Gray Scale Image
- Now let’s explore the gray scale image. Using the same command, read in a gray scale image from the image file.
–> S2 = imread(‘balloons_gray.png’);
- Double click on the variable S2 from the variable browser, you would see the values between 0 to 255, which represent the intensity of the image.
- Use the “imshow” command to visualize the image.
- Again, use “imread” command to import color image.
–> S3 = imread(‘balloons.png’);
- In Scilab 6, the hypermatries are loaded natively. The variable browser will show the width and height of the image but not the depth.
- To inspect the size of the image matrix, we could use “size” command
- 300. 3.
Now we could see the matrix is now 3 layers, which representing R, G and B layers (Red, Green and Blue).
- Use “imshow” to visualize the color image as well.