MATLAB

A popular scientific (mathematical) tool for those working in advanced image processing is MATLAB. MATLAB (from "matrix laboratory") is described as a "numerical computing environment." Originally developed for teaching purposes, since 1984 it has been a commercial product maintained by The MathWorks. It is commonly used for image processing. As an example, the following MATLAB code creates separate bitplane images from an image document:

clear all

% read image
img=imread('gm-1.jpg');

% select one color (1,2 or 3)
img=img(:,:,1);

img=imresize(img,0.25,'bicubic');

img2=im2double(img);
img2=255*img2;

[x,y]=size(img2);

bitplanes=zeros(x,y,8);

for i=1:x
for j=1:y
binary=de2bi(img2(i,j),8,'left-msb');
for k=1:8
bitplanes(i,j,k)=binary(k);
end

end
end

imwrite(img,'original.png'); % original grayscale image
imwrite(bitplanes(:,:,1),'bit1.png'); % MSB
imwrite(bitplanes(:,:,2),'bit2.png');
imwrite(bitplanes(:,:,3),'bit3.png');
imwrite(bitplanes(:,:,4),'bit4.png');
imwrite(bitplanes(:,:,5),'bit5.png');
imwrite(bitplanes(:,:,6),'bit6.png');
imwrite(bitplanes(:,:,7),'bit7.png');
imwrite(bitplanes(:,:,8),'bit8.png'); % LSB

On the following page can be seen the results of running this code on a typical document image.

Continued Continued