[go: up one dir, main page]

0% found this document useful (0 votes)
54 views14 pages

Medical Imaging - Lab # 03

The document outlines the assessment criteria and tasks for a lab focused on image enhancement using histogram manipulation in MATLAB. It includes rubrics for evaluating experiment conduct, analysis, and individual participation, along with detailed tasks that involve coding for image processing and visualization. Each task demonstrates different techniques for enhancing image contrast and analyzing histograms, with corresponding MATLAB code and expected outputs.

Uploaded by

Usama Javed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views14 pages

Medical Imaging - Lab # 03

The document outlines the assessment criteria and tasks for a lab focused on image enhancement using histogram manipulation in MATLAB. It includes rubrics for evaluating experiment conduct, analysis, and individual participation, along with detailed tasks that involve coding for image processing and visualization. Each task demonstrates different techniques for enhancing image contrast and analyzing histograms, with corresponding MATLAB code and expected outputs.

Uploaded by

Usama Javed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Lab Rubrics

Assessment Criteria for Lab 03

Assessment Excellent Good Needs improvement


Points
parameters (3) (2) (1)
Effectively followed Effectively followed
Conducting the provided the provided Unable to complete
Experiment instructions and instruction and tasks and standard
(CLO-4/PLO-5) complete the complete the procedures required
(C3) experiment experiment with for the experiment
independently. minimal supervision.
Student required
Student analyzed the Student was not able
guidance in analyzing
Analysis output and presented to analyze the output
the output and
(CLO-4/PLO-5) correct explanation and did not present
producing correct
(C3) for the obtained clear explanation for
explanation for the
results. the obtained results.
obtained results.
Individual Student was Student was
Student was an active
Evaluation moderately minimally
participant and
(CLO-5/PLO-9) participating and participating and did
showed
(A2) responded when not respond when
responsiveness.
asked. asked.

Calculation: CLO-4/PLO-5 CLO-5/PLO-9


Lab Points (9) / Total Points (9) = 1.0 Mark 0.8 0.2

CLO-4/PLO-5 is 80% Weightage = (Points/6) x


0.8 Lab Marks
CLO-5/PLO-9 is 20% Weightage = (Points/3) x (Out of 1.0)
0.2

Lab Instructor’s signature: ______________________


3 LAB EXPERIMENT

OBJECT:

To study and implement image enhancement using Histogram Manipulation.

LEARNING OUTCOME:

In this lab, you will be able to understand the following points:


 Histogram.
 MATLAB commands to visualize Histogram.
 MATLAB commands to enhance images.

Introduction:
In an image processing context, the histogram of an image normally refers to a histogram
of the pixel intensity values. This histogram is a graph showing the number of pixels in
an image at each different intensity value found in that image. For an 8-bit grayscale
image there are 256 different possible intensities, and so the histogram will graphically
display 256 numbers showing the distribution of pixels.

In Statistics, Histogram is a graphical representation showing a visual impression of the


distribution of data. An Image Histogram is a type of histogram that acts as a graphical
representation of the lightness/color distribution in a digital image. It plots the number of
pixels for each value. The histogram of a digital image with gray levels in the range [0, L-1]
is a discrete function:
h(rk) = nk
Where:
rk : kth gray level
nk : # of pixels with having gray level rk

Importance of Histograms:
 Histograms are the basis for numerous spatial domain-processing techniques
 Histogram manipulation can be used effectively for image enhancement
 Histograms can be used to provide useful image statistics
 Information derived from histograms are quite useful in other image processing
applications, such as image compression and segmentation.
BME – 401 Medical Imaging

For Example: we have 600 pixels having the intensity value ≈ 160

Figure 1: Histogram Example

Figure 2: Histogram and its effect on Image

MATLAB Commands for Image Enhancement using Histogram:

Task # 01:
Source Code:
a=imread('image name.format'); % Grayscale image
subplot(3,1,1); histogram(a);
title('Grayscale Image Histogram');
subplot(3,1,2); imhist(a); ylim([0 max(imhist(a))]);
subplot(3,1,3); plot(imhist(a));

Department of Biomedical Engineering, SHU.


BME – 401 Medical Imaging

Output:Summary:
Grayscale Image Histogram
6000

4000

2000

0
0 50 100 150 200 250

1500

1000

500

0
0 50 100 150 200 250

2000

1000

0
0 50 100 150 200 250 300
Figure 1The output represents a histogram, the pixels of the original image and the frequency if repeated
intensities and lastly the shape of the frequency graph

This MATLAB code loads the image 'cameraman.tif' and creates a figure with three subplots.
It displays the histogram of the grayscale image using different graph styles, effectively
visualizing the distribution of pixel intensities.

Task # 02:
Source Code:
[b,bmap]=imread('trees.tif'); % Indexed image
figure;
subplot(2,1,1); imhist(b,bmap); ylim([0 max(imhist(b,bmap))]);
title('Indexed Image Histogram');
subplot(2,1,2); plot(imhist(b,bmap));
Output:

Indexed Image Histogram

8000

6000

4000

2000

0
0 50 100 150 200 250

10000

5000

0
0 50 100 150 200 250 300

Figure 2/;The histograms of an indexed image and its corresponding colormap

Department of Biomedical Engineering, SHU.


BME – 401 Medical Imaging

Summary:
The MATLAB code processes 'trees.tif,' an indexed image with a colormap, and creates a
figure with two subplots to display its histogram. The first subplot shows a bar graph of the
indexed image's histogram with adjusted y-axis limits, labeled 'Indexed Image Histogram.'
The second subplot presents the same histogram as a line graph, enhancing the visualization
of the indexed color distribution based on the colormap.

Task # 03:
Source Code:
a=imread('onion.png'); % RGB image

Red = a(:,:,1);
Green = a(:,:,2);
Blue = a(:,:,3);
[yRGB, x] = imhist(a);
[yRed, x] = imhist(Red);
[yGreen, x] = imhist(Green);
[yBlue, x] = imhist(Blue);
imshow(a);
figure;
plot(x, yRGB,'k',x, yRed, 'r', x, yGreen, 'g', x, yBlue, 'b');
figure;
subplot(2,2,1); imhist(a);
title('RGB Image Histogram'); ylim([0 max(yRGB)]);
subplot(2,2,2); imhist(Red);
title('Red Component Histogram'); ylim([0 max(yRed)]);
subplot(2,2,3); imhist(Green);
title('Green Component Histogram'); ylim([0 max(yGreen)]);
subplot(2,2,4); imhist(Blue);
title('Blue Component Histogram'); ylim([0 max(yBlue)]);
figure;
subplot(2,2,1); histogram(a); title('RGB Image Histogram');
subplot(2,2,2); histogram(Red); title('Red Component Histogram');
subplot(2,2,3);histogram(Green);title('Green Component Histogram');
subplot(2,2,4); histogram(Blue); title('Blue Component Histogram');
Output:

3000

2500

2000

1500

1000

500

0
0 50 100 150 200 250 300

Department of Biomedical Engineering, SHU.


BME – 401 Medical Imaging

RGB Image Histogram Red Component Histogram

2000 2000

1000 1000

0 0
0 50 100 150 200 250 0 50 100 150 200 250

Green Component Histogram Blue Component Histogram


600
1500

400
1000

200
500

0 0
0 50 100 150 200 250 0 50 100 150 200 250

Figure 3/; The limited intensity distributions of the original image and all involved channels

RGB Image Histogram Red Component Histogram


3000
4000

3000 2000

2000
1000
1000

0 0
0 100 200 50 100 150 200 250

Green Component Histogram Blue Component Histogram


3000 3000

2000 2000

1000 1000

0 0
0 100 200 0 50 100 150 200

Summary:
The MATLAB code analyzes and displays histograms for the Red, Green, and Blue color
channels of the 'fabric.png' RGB image. It separates the image into its color components,
computes the histograms, and presents them as line plots and bar graphs in separate figures.
This process aids in analyzing the color information and intensity distribution within the
image.
Task 4:
Enhance the contrast of an intensity image using Histogram Equalization

Department of Biomedical Engineering, SHU.


BME – 401 Medical Imaging

Source Code:

a=imread('tire.tif');
c=histeq(a);
subplot(1,3,1); imshow(a); title('Original Image');
subplot(1,3,2); imshow(c); title('HistEq');
subplot(1,3,3); imhist(c); title('HistEq Histogram');
Output:
Histogram of Original Image Histogram of Equalized Image
900
1000
800
900
Original Image 700
Equalized Image
800
600
700

500 600

400 500

400
300
300
200
200
100
100
0 0

0 50 100 150 200 250 0 50 100 150 200 250

Figure 4/;This represents the Original processed image and their histograms

Summary:
The MATLAB code applies histogram equalization to the grayscale image 'tire.tif.' It loads the image,
enhances its contrast using histogram equalization, and displays both the original and enhanced
images alongside their respective histograms for visual comparison of the contrast improvements.
Original Image & Its Histogram:

Processed Image & its Histogram:

Department of Biomedical Engineering, SHU.


BME – 401 Medical Imaging

Task 5:
Enhance the contrast of an intensity image using imadjust command:

Source Code:

I = imread('pout.tif');
figure;
subplot(1,2,1);
imshow(I);
title('Original Image');
subplot(1,2,2);
imhist(I);
title('Original Image Histogram');
F = imadjust(I);
figure;
subplot(1,2,1)
imshow(F);
title('Adjusted Image');
subplot(1,2,2)
imhist(F);
title('Adjusted Image Histogram');
Output:
Original Image & Its Histogram;

Processed Image & its Histogram:

Summary:

Department of Biomedical Engineering, SHU.


BME – 401 Medical Imaging

This MATLAB code demonstrates contrast enhancement for the grayscale image 'pout.tif'
through histogram adjustment. It first displays the original image along with its histogram,
then applies contrast enhancement using the `imadjust` function and shows the enhanced
image along with its histogram. This process illustrates how histogram adjustment can
improve image contrast and overall quality.
Task 6:
Enhance the contrast of an intensity image using adapthisteq command:

Source Code:
a = imread('indiancorn.jpg');
grayImage = rgb2gray(a);
b = adapthisteq(grayImage);
subplot(2,2,1);
imshow(grayImage);
title('Original Gray Image');
subplot(2,2,2);
imshow(b);
title('Adaptive and Equalized Image');
subplot(2,2,3);
imhist(a);
title('Original Image Histogram');
subplot(2,2,4);
imhist(b);
title('Adapted and Equalized Image Histogram');
Output:
Original Gray Image Adaptive and Equalized Image

10 4 Original Image Histogram Adapted and Equalized Image Histogram


2.5
7000
2 6000

5000
1.5
4000

1 3000

2000
0.5
1000

0 0
0 50 100 150 200 250 0 50 100 150 200 250

Summary:
The MATLAB code converts 'indiancorn.jpg' to grayscale, applies adaptive histogram
equalization for contrast enhancement, and displays the original grayscale image, the
enhanced version, and its histogram in a row of three subplots. This showcases the improved
contrast and enhanced visibility of details in the image.

Task 7:
Take an X-RAY image and visualize its histogram.
Source Code:
xrayImage = imread('X-ray.jpg');

Department of Biomedical Engineering, SHU.


BME – 401 Medical Imaging

grayImage = rgb2gray(xrayImage);
figure;
imshow(grayImage);
title('X-ray Image');
figure; subplot(3,1,1); histogram(grayImage);
subplot(3,1,2); imhist(grayImage); ylim([0 max(imhist(grayImage))]);
subplot(3,1,3); plot(imhist(grayImage)),title('X-ray Image Histograms');
Output:
X-ray Image

10 5

6
4
2
0
0 50 100 150 200 250
105

0
0 50 100 150 200 250

10 5

6
4
2
0
0 50 100 150 200 250 300

Department of Biomedical Engineering, SHU.


BME – 401 Medical Imaging

Summary:
This MATLAB code loads a grayscale X-ray image, displays it, and then plots its histogram
using both bar and line graphs in subplots. This approach provides a comprehensive view of
the pixel intensity distribution within the image.

Task 8:
Take an MRI Scan and apply ‘imadjust’ command.
Source Code:
mriImage = imread('mri.tif');
adjustedImage = imadjust(mriImage);
subplot(1,2,1);
imshow(mriImage);
title('Original MRI Scan');
subplot(1,2,2);
imshow(adjustedImage);
title('Adjusted MRI Scan');
title('MRI Scan and Adjusted Image');

Output:

Original MRI Scan Adjusted MRI Scan

Summary:
This MATLAB code loads an MRI scan image, enhances its contrast using the `imadjust`
function, and displays both the original and enhanced images in a single figure with
appropriate titles. This setup allows for a visual assessment of the impact of the contrast
enhancement.

Task 9:
Take a CT-Scan; enhance its contrast using histeq, adapthisteq and imadjust command.
Source Code:
ctImage = imread('CT.jpg');
grayImage = rgb2gray(ctImage);
enhancedHisteq = histeq(grayImage);
enhancedAdapthisteq = adapthisteq(grayImage);
adjustedImage = imadjust(grayImage);
figure;
subplot(1,2,1);
imshow(ctImage);
title('Original CT Scan');
subplot(1,2,2);
imhist(grayImage);

Department of Biomedical Engineering, SHU.


BME – 401 Medical Imaging

title('Original CT Scan Histogram')


figure;
subplot(1,2,1);
imshow(enhancedHisteq);
title('Enhanced Equalized Image');
subplot(1,2,2);
imhist(enhancedHisteq);
title('Enhanced Equalized Histogram')
figure;
subplot(1,2,1);
imshow(enhancedAdapthisteq);
title('Enhanced, Adapted & Equalized Image');
subplot(1,2,2);
imhist(enhancedAdapthisteq);
title('Enhanced, Adapted & Equalized Histogram')
figure;
subplot(1,2,1);
imshow(adjustedImage);
title('Adjusted Image');
subplot(1,2,2);
imhist(adjustedImage);
title('Adjusted Image Histogram');

Output:

Department of Biomedical Engineering, SHU.


BME – 401 Medical Imaging

Enhanced, Adapted & Equalized Histogram


10000

Enhanced, Adapted & Equalized Image9000


8000

7000

6000

5000

4000

3000

2000

1000

0 50 100 150 200 250

Adjusted Image Histogram

Adjusted Image 10000

8000

6000

4000

2000

0 50 100 150 200 250

Original CT Scan Histogram

Original CT Scan 10000

8000

6000

4000

2000

0 50 100 150 200 250

Department of Biomedical Engineering, SHU.


BME – 401 Medical Imaging

Enhanced Equalized Histogram

16000
Enhanced Equalized Image
14000

12000

10000

8000

6000

4000

2000

0 50 100 150 200 250

Summary:
The MATLAB code loads a CT scan image, converts it to grayscale, and enhances its
contrast using standard histogram equalization, adaptive histogram equalization, and contrast
adjustment. It displays each enhanced image along with its histogram in separate figures,
allowing for a visual assessment of the improvements in image quality.

CONCLUSION:
In this lab, we performed various tasks using different MATLAB tools. Histogram
manipulation in MATLAB is invaluable for enhancing image quality and extracting critical
information from images. MATLAB's diverse tools, such as histogram equalization and
contrast adjustment, allow for customized enhancements, supporting applications in fields
like healthcare and remote sensing.

Department of Biomedical Engineering, SHU.

You might also like