%start With True Color Image: Img Imread Imshow (Img)
%start With True Color Image: Img Imread Imshow (Img)
LAB HANDOUT- 08
OBJECTIVE:
objective of this lab is to understand
1. How to Display different image types
2. How to do Histogram
3. How to do Histogram Equalization
INLAB TASK:
CODE OUTPUT
%Start with true color image
img=imread('skull.jpg')
imshow(img)
INSTITUTE OF BIOMEDICAL ENGINEERING & TECHNOLOGY LIAQUAT UNIVERSITY OF
MEDICAL & HEALTH SCIENCES JAMSHORO
%Convert to Binary or black
and white
img_bin=im2bw(img);
imshow(img_bin)
%convert to grayscale
img_gray=rgb2gray(img);
imshow(img_gray)
HISTOGRAMS:
Histogram are way of visualizing predominant intensities of an image. As a definition, image Histograms
are a count of the number of pixels that are at a certain intensity. When represented as a plot, the x-axis
is the intensity value, and the y-axis is the number of pixels with that intensity value.
Histogram represents a relative frequency of the appearance of different levels of gray in the image. In
MATLAB, histogram can calculated and displayed with a function imhist()
CODE:
%Redue to indexed color
[img_indexed, map]=rgb2ind(img,8);
imshow(img_indexed,map)
figure
imhist(img_indexed,map) %calculate and display the histogram
HISTOGRAM EQUALIZATION:
Histogram equalization is an operation of an image so that the number of pixels is approximately equal
for all histogram levels. In MATLAB, histogram can be equalized with the function histeq():
The idea behind Histogram Equalization is that we try to evenly distribute the occurrence of pixel
intensities so that the entire range of intensities is used more fully. We are trying to give each pixel
intensity equal opportunity; thus equalization. Especially for images with a wide range of values with
detail clustered around a few intensities, histogram will improve the contrast in image.
CODE:
Instructions: