Home > Image Processing > 3c. Working with Image Types on SciLab

3c. Working with Image Types on SciLab

Image types determine the way the computer interprets data matrix elements as pixel intensity values.  SciLab has the special capability of converting between image types for necessary purposes.

Images can be imported to SciLab and converted to different representations simply.

I = imread('guitar.jpg');

J = rgb2gray(I);
K = im2bw(I, 0.3);  // 0.3 being the threshold

To open a graphical window to view the image:


Figure 1 displays a converted image from true color, to grayscale, to binary.



Binary (Black and White)

Figure 1. SciLab conversion between image types.

The basic information of the images may also be found using the imfinfo() command:


FileName    |  guitar.jpg
FileSize    |  29373
Width       |  375
Height      |  500
BitDepth    |  8
ColorType   |  truecolor

Histograms may also be viewed in order to see the distribution of values in the image and effectively determine what threshold to use for conversion.  Using the image of the chart used in a previous blog post, we enter the following commands:

I = imread('image1.jpg');

J = rgb2gray(I);
scf(0); imhist(J, 10, ''); // 10 being the bin size, scf(0) to view the result in window 0
scf(1); imhist(J, 10, 0.5, 'green'); // 0.5 being the width of the bins

Figure 2. Histogram plots for the grayscale image for the chart image.

From the image histograms above, we can say it is safe to set the threshold to 0.7.

Figure 3.  Conversion of chart image from RGB to binary, thresholded at 0.7.

Figure 3 now shows the optimized version of the chart image, with less smudges but with clearer, more defined representations.

Special thanks to Miggy C. for the guitar photo and Gladys R. for the technical insights.  For this set of activities (3A to 3C), I would rate myself 10 for the good job. 🙂
[1] Soriano, M., 2010. Image types and formats. Applied Physics 186.
[2] Yu, et. al, 2006. Scilab Image and Video Processing Toolbox v 0.4.0. Free Software Association.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: