Study & Run All The Programs in Matlab & All Functions Also: List of Experiments
Study & Run All The Programs in Matlab & All Functions Also: List of Experiments
Study & Run All The Programs in Matlab & All Functions Also: List of Experiments
List of Experiments
REFERENCE:
Aim:
Apparatus Required:
Computer,Matlab Software
Syntax
imshow(I)
imshow(I,[low high])
imshow(RGB)
imshow(BW)
imshow(X,map)
imshow(filename)
himage = imshow(...)
Theory:
imshow(I) displays the grayscale image I.
imshow(BW) displays the binary image BW. imshow displays pixels with the
value 0 (zero) as black and pixels with the value 1 as white.
imshow(X,map) displays the indexed image X with the colormap map. A color
map matrix may have any number of rows, but it must have exactly 3 columns.
Each row is interpreted as a color, with the first element specifying the intensity of
red light, the second green, and the third blue. Color intensity can be specified on
the interval 0.0 to 1.0.
imshow(filename) displays the image stored in the graphics file filename. The
file must contain an image that can be read by imread or dicomread. imshow calls
imread or dicomread to read the image from the file, but does not store the image
data in the MATLAB workspace. If the file contains multiple images, imshow
displays the first image in the file. The file must be in the current directory or on
the MATLAB path.
himage = imshow(...) returns the handle to the image object created by imshow.
Converting RGB Image into gray scale image & extracting the color
Spaces
image1=imread('dse_college.jpg');
image2=rgb2gray (image1);
[r c d]=size (image1);
z=zeros(r,c);
tempr=image1;
tempr(:,:,2)=z;
tempr(:,:,3)=z;
imshow(tempr)
tempg=image1;
tempg(:,:,1)=z;
tempg(:,:,3)=z;
imshow(tempg)
tempb=image1;
tempb(:,:,1)=z;
tempb(:,:,2)=z;
imshow(tempb)
Result:
Aim:
Apparatus Required:
Computer,Matlab Software
Syntax
J = histeq(I, hgram)
J = histeq(I, n)
[J, T] = histeq(I,...)
[newmap, T] = histeq(X,...)
Theory
J = histeq(I, hgram) transforms the intensity image I so that the histogram of the
output intensity image J with length(hgram) bins approximately matches hgram.
[J, T] = histeq(I,...) returns the grayscale transformation that maps gray levels in
the image I to gray levels in J.
newmap = histeq(X, map, hgram) transforms the colormap associated with the
indexed image X so that the histogram of the gray component of the indexed image
(X,newmap) approximately matches hgram. The histeq function returns the
transformed colormap in newmap. length(hgram) must be the same as size(map,1).
newmap = histeq(X, map) transforms the values in the colormap so that the
histogram of the gray component of the indexed image X is approximately flat. It
returns the transformed colormap in newmap.
Examples
I = imread('tire.tif');
J = histeq(I);
imshow(I)
figure, imshow(J)
Display a histogram of the original image.
figure; imhist(I,64)
figure; imhist(J,64)
Algorithm
When you supply a desired histogram hgram, histeq chooses the grayscale
transformation T to minimize where c0 is the cumulative histogram of A, c1 is the
cumulative sum of hgram for all intensities k. This minimization is subject to the
constraints that T must be monotonic and c1(T(a)) cannot overshoot c0(a) by more
than half the distance between the histogram counts at a. histeq uses the
transformation b = T(a) to map the gray levels in X (or the colormap) to their new
values.If you do not specify hgram, histeq creates a flat hgram,
hgram = ones(1,n)*prod(size(A))/n;
Result
Aim:
Apparatus Required:
Syntax
To demonstrate edge detection
% numbers of colors
sncols=128;
ncols=32;
% get image from MATLAB image
load('trees');
% show original image
figure(1);
showgimg(real(X),sncols);
drawnow;
% construct convolution functions
[m,n] = size(X);
gs = [1 -1]; ge = [];
hs = [1 -1]; he = [];
g = [gs,zeros(1,m-length(gs)-length(ge)),ge];
h = [hs,zeros(1,n-length(hs)-length(he)),he];
% construct convolution matrices as sparse matrices
Y = spcnvmat(g);
Z = spcnvmat(h);
Wg = Y*X;
Wh = X*Z';
% show transformed images
figure(2);
showgimg(Wg,ncols);
drawnow;
figure(3)
showgimg(Wh,ncols);
drawnow;
figure(4)
showgimg(abs(Wg)+abs(Wh),ncols);
drawnow;
Theory