0% found this document useful (0 votes)
184 views19 pages

DSA Report

The document is an image processing report focusing on medical imaging techniques, specifically Digital Subtraction Angiography (DSA) and Gaussian Blur Filter. It outlines the definitions, principles, applications, and MATLAB and Python implementations of these techniques. The report emphasizes the importance of image processing in medical diagnostics and provides code examples for practical application.

Uploaded by

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

DSA Report

The document is an image processing report focusing on medical imaging techniques, specifically Digital Subtraction Angiography (DSA) and Gaussian Blur Filter. It outlines the definitions, principles, applications, and MATLAB and Python implementations of these techniques. The report emphasizes the importance of image processing in medical diagnostics and provides code examples for practical application.

Uploaded by

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

VIETNAM NATIONAL UNIVERSITY, HO CHI MINH CITY

HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY


FACULTY OF APPLIED SCIENCE


IMAGE PROCESSING REPORT


MEDICAL IMAGING
CLASS CC01 – HK242

INSTRUCTOR: NGUYỄN THỊ MINH HƯƠNG

Full name Student ID Score


Nguyễn Thắng Khôi 2153481

HO CHI MINH CITY – 2025


Table of Contents
I. Introduction .................................................................................................................... 2
II. Image Processing Methods .......................................................................................... 2
1. Digital Subtraction Angiography (DSA) .................................................................. 2
1.1. Definition............................................................................................................... 2
1.2. Principle ................................................................................................................ 2
1.3. Application ............................................................................................................ 3
2. Gaussian Blur Filter .................................................................................................. 3
2.1. Definition............................................................................................................... 3
2.2. Principle ................................................................................................................ 4
2.3. Application ............................................................................................................ 4
3. Other Image Processing ............................................................................................. 5
3.1. Image Enhancement ............................................................................................. 5
3.2. Image Morphology ................................................................................................ 5
3.3. Image Segmentation ............................................................................................. 5
III. MATLAB ..................................................................................................................... 6
1. Image Processing by Digital Subtraction Angiography (DSA) using MATLAB . 6
2. Image Processing by Gaussian Blur Filter using MATLAB ................................ 10
IV. Python ......................................................................................................................... 13
1. Image Processing by Digital Subtraction Angiography (DSA) using Python .... 13
2. Image Processing by Gaussian Blur Filter using Python ..................................... 15
3. Code Comparison ..................................................................................................... 16
V. Conclusion .................................................................................................................... 17

1
I. Introduction
Image processing is a technique used to manipulate and analyze images through
computational methods. It involves various operations that aim to improve the quality of
an image, extract useful information, or transform it for specific purposes. Image
processing typically begins with image acquisition, where images are captured through
devices such as cameras or scanners. Then, through processes like filtering, segmentation,
and enhancement, the image is refined or modified to highlight relevant features. This is
often followed by feature extraction, where distinct patterns or characteristics are identified
for further analysis.

Applications of image processing are vast and include fields such as medical imaging like
MRI, CT scans, facial recognition, and computer vision. Techniques in image processing
also play a crucial role in industries like automotive, entertainment, security, and digital
art. By using algorithms and artificial intelligence, image processing has evolved to achieve
tasks like object detection, image classification, and even image generation, making it an
essential tool in modern technology.

II. Image Processing Methods


1. Digital Subtraction Angiography (DSA)
1.1. Definition
Digital Subtraction Angiography (DSA) is an advanced medical imaging technique used to
visualize blood vessels with high clarity by digitally removing background structures such
as bones and soft tissues. This technique is widely utilized in the diagnosis and treatment
of vascular diseases.

1.2. Principle
DSA operates based on the principle of digital subtraction, which enhances the visibility of
blood vessels. The process typically involves the following steps:

- Pre-contrast Image: An initial X-ray image is taken before the administration of a contrast
agent. This image captures bones, soft tissues, and background structures.

2
- Contrast Injection: A contrast agent such as iodine-based agent is injected into the
bloodstream to highlight blood vessels.

- Post-contrast Image Acquisition: Another X-ray image is taken after the contrast agent
reaches the blood vessels.

- Digital Subtraction: The pre-contrast image is digitally subtracted from the post-contrast
image. This process removes unwanted background structures, leaving only the contrast-
filled blood vessels visible.

1.3. Application
DSA is widely used in interventional radiology and vascular imaging, including:

- Neurovascular Imaging: Diagnosis of aneurysms, arteriovenous malformations (AVMs),


and stenosis in cerebral vessels.

- Coronary and Peripheral Angiography: Evaluation of arterial blockages, stenosis, and


vascular anomalies in the heart and extremities.

- Interventional Procedures: Used in procedures such as angioplasty, stent placement,


embolization, and thrombectomy.

- Preoperative and Postoperative Assessment: Used to assess vascular conditions before


surgery and monitor post-surgical outcomes.

- Renal and Pulmonary Angiography: Evaluating kidney and lung vasculature for
conditions like renal artery stenosis and pulmonary embolism.

2. Gaussian Blur Filter


2.1. Definition
In image processing, Gaussian functions are used for filtering and smoothing images. The
most common application is the Gaussian filter, which reduces noise and detail by applying
a weighted averaging technique based on a Gaussian distribution. This technique preserves
edges better than other smoothing methods like box filtering.

3
2.2. Principle
The Gaussian filter works by convolving an image with a Gaussian kernel, which is defined
as:

𝑥2 +𝑦2
1 −
𝐺 (𝑥, 𝑦) = 𝑒 2𝜎2
2𝜋𝜎 2

where:

- x, y are the pixel coordinates

- 𝜎 (standard deviation) controls the spread of the blur

A larger 𝜎 results in a stronger blur. The kernel is applied by convolving it with the image,
effectively averaging pixel values while giving more weight to closer pixels.

2.3. Application
The Gaussian filter is widely used because it preserves edge structure better than other
smoothing techniques, making it essential in various image processing applications
including:

- Noise Reduction & Smoothing: Gaussian blur removes high-frequency noise while
maintaining important structures used as a preprocessing step in edge detection.

- Edge Detection (Canny Edge Detector): The first step in the Canny edge detection
algorithm is applying a Gaussian filter to reduce noise.

- Image Resizing & Down sampling: Gaussian filtering helps prevent aliasing and
preserves smooth transitions.

- Object Detection & Feature Extraction: Gaussian pyramids are used in multi-scale image
processing, such as facial recognition and image segmentation.

- Medical Imaging: Used in MRI and CT scans for noise reduction and edge enhancement.

4
3. Other Image Processing
3.1. Image Enhancement
Image enhancement techniques aim to improve the visual quality of an image by adjusting
its contrast, brightness, sharpness, or color balance including:

- Histogram Equalization: Improves contrast by redistributing the image's intensity values.

- Contrast Limited Adaptive Histogram Equalization (CLAHE): A localized version of


histogram equalization that works well on images with non-uniform lighting.

This method is applied in improving the visibility of medical images such as X-ray, CT
scans and enhancing low-light images in photography.

3.2. Image Morphology


Morphological image processing involves operations that process images based on their
shape. These techniques manipulate pixel structures to achieve tasks such as noise removal,
shape analysis, and object recognition including:

- Dilation and Erosion: Expand or shrink image objects to highlight or remove specific
features.

- Opening and Closing: Used for noise removal and object segmentation.

This method is applied in medical imaging for detecting irregularities and shape analysis
in biological systems.

3.3. Image Segmentation


Segmentation involves dividing an image into multiple segments or regions based on pixel
intensity or color. It helps in isolating important parts of the image, like tumors, organs, or
other objects of interest such as

- Thresholding: Pixels are grouped into binary categories based on intensity levels.

- Region Growing: Starting from a seed point, pixels are added to the region based on
similarity criteria.

5
This method is applied in medical image analysis like identifying and isolating tumors in
MRI scans.

III. MATLAB
In this section, we will work with images of the skull using a contrast agent and without a
contrast agent.

Figure 1: Live image (with contrast Figure 2: Mask image (without


agent) contrast agent)

1. Image Processing by Digital Subtraction Angiography (DSA) using MATLAB


The MATLAB code is a simple example of performing image subtraction and adaptive
histogram equalization on two images. The code reads two images, performs a subtraction
operation between them, and then applies adaptive histogram equalization to enhance the
contrast of the resulting image. This process helps improve the visibility of details,
particularly in medical or analytical image processing tasks. MATLAB's image processing
functions such as histeq is used to enhance contrast of image.

clear; clc;
im1 = imread('live.jpg');
im2 = imread('mask.jpg');
imshow(im1)
figure

6
imshow(im2)
angio1 = im2 - im1;
figure
imshow(angio1)
%im_adjust = imadjust(angio1);
%figure
%imshow(im_adjust)
%im_histeq = histeq(angio1);
%figure
%imshow(im_histeq)
im_adapthisteq = adapthisteq(angio1);
figure
imshow(im_adapthisteq)

Result

The MATLAB code is for a GUI-based application that handles and processes images
related to a digital subtraction process. This code uses the GUIDE to create a simple
interface, allowing users to load two images, perform subtraction between them, and apply
image enhancement techniques such as histogram equalization.

function varargout = testG(varargin)


% TESTG MATLAB code for testG.fig
% TESTG, by itself, creates a new TESTG or raises the existing
% singleton*.
%

7
% H = TESTG returns the handle to a new TESTG or the handle to
% the existing singleton*.
%
% TESTG('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TESTG.M with the given input arguments.
%
% TESTG('Property','Value',...) creates a new TESTG or raises the
% existing singleton*. Starting from the left, property value pairs
are
% applied to the GUI before testG_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property
application
% stop. All inputs are passed to testG_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help testG

% Last Modified by GUIDE v2.5 20-Jan-2022 14:25:34

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @testG_OpeningFcn, ...
'gui_OutputFcn', @testG_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

% --- Executes just before testG is made visible.


function testG_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to testG (see VARARGIN)

8
% Choose default command line output for testG
handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

% UIWAIT makes testG wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = testG_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure


varargout{1} = handles.output;

% --- Executes on button press in pushbutton1.


function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes1);
im1 = imread('live.jpg');
imshow(im1);

% --- Executes on button press in pushbutton2.


function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
im2 = imread('mask.jpg');
imshow(im2);

% --- Executes on button press in pushbutton3.


function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes3);
im1 = imread('mask.jpg');
im2 = imread('live.jpg');
im = im1-im2;
im = histeq(im);

9
imshow(im);

Result

2. Image Processing by Gaussian Blur Filter using MATLAB


The MATLAB code is designed for a GUI-based application that processes images using
the Gaussian Blur Filter. It provides an interactive interface where users can load images,
apply image processing techniques such as Gaussian blur and view the results. The code
uses MATLAB's built-in functions for image manipulation such as imgaussfilt, to apply the
blur filter, and the imshow function to display the processed images within the GUI. This
allows users to visualize and interact with the image processing operations easily.

function varargout = testG(varargin)


% TESTG MATLAB code for testG.fig
% TESTG, by itself, creates a new TESTG or raises the existing
% singleton*.
%
% H = TESTG returns the handle to a new TESTG or the handle to
% the existing singleton*.
%
% TESTG('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TESTG.M with the given input arguments.

10
%
% TESTG('Property','Value',...) creates a new TESTG or raises the
% existing singleton*. Starting from the left, property value pairs
are
% applied to the GUI before testG_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property
application
% stop. All inputs are passed to testG_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Last Modified by GUIDE v2.5 20-Jan-2022 14:25:34

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @testG_OpeningFcn, ...
'gui_OutputFcn', @testG_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

% --- Executes just before testG is made visible.


function testG_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to testG (see VARARGIN)

% Choose default command line output for testG


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

11
% UIWAIT makes testG wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = testG_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure


varargout{1} = handles.output;

% --- Executes on button press in pushbutton1.


function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes1);
im1 = imread('live.jpg');
imshow(im1);

% --- Executes on button press in pushbutton2.


function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
im2 = imread('mask.jpg');
imshow(im2);

% --- Executes on button press in pushbutton3.


function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes3);
im1 = imread('mask.jpg');
im2 = imread('live.jpg');
im = im1-im2;
im = histeq(im);
imshow(im);

% --- Executes on button press in pushbutton4 (Gaussian Blur).


function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

12
axes(handles.axes4);
im1 = imread('live.jpg');
im2 = imread('mask.jpg');
im_diff = im1 - im2;
im_his = histeq(im_diff);

% Apply Gaussian Blur Filter


im_blur = imgaussfilt(im_his, 0.5); % 0.5 is value of sigma (standard
deviation of Gaussian)

% Display processed image


imshow(im_blur);

Result

IV. Python
1. Image Processing by Digital Subtraction Angiography (DSA) using Python
The Python code demonstrates image subtraction and adaptive histogram equalization
applied to two images related to DSA. It utilizes the OpenCV, NumPy, and Matplotlib
libraries for image processing. OpenCV is responsible for image manipulation, NumPy

13
handles array operations, and Matplotlib is used for displaying the results. The code first
subtracts one image from another and then applies adaptive histogram equalization to
enhance the image contrast.

import cv2
import numpy as np
import matplotlib.pyplot as plt

# Link of image
path1 = r"C:\Users\acer\Downloads\Lab1_DSA\DSA\live.jpg"
path2 = r"C:\Users\acer\Downloads\Lab1_DSA\DSA\mask.jpg"

# Read image
im1 = cv2.imread(path1, cv2.IMREAD_GRAYSCALE) # Ảnh gốc
im2 = cv2.imread(path2, cv2.IMREAD_GRAYSCALE) # Ảnh mask

# Subtraction between 2 images


angio1 = cv2.subtract(im2, im1)

# Display image
plt.figure()
plt.imshow(angio1, cmap='gray')
plt.title('Angio1 (Subtracted Image)')
plt.axis('off')
plt.show()

# Adaptive Histogram Equalization


im_adapthisteq = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8))
angio1_adapthisteq = im_adapthisteq.apply(angio1)

# Display image
plt.figure()
plt.imshow(angio1_adapthisteq, cmap='gray')
plt.title('Adaptive Histogram Equalization')
plt.axis('off')
plt.show()

Result

14
2. Image Processing by Gaussian Blur Filter using Python
The Python code demonstrates the application of a Gaussian Blur filter for image
processing. When an image is processed with the Gaussian Blur filter, it results in a blurred
effect. The code utilizes the OpenCV, NumPy, and Matplotlib libraries to perform the
necessary image operations.

import cv2
import numpy as np
import matplotlib.pyplot as plt

# Link of images
path1 = r"C:\Users\acer\Downloads\Lab1_DSA\DSA\live.jpg"
path2 = r"C:\Users\acer\Downloads\Lab1_DSA\DSA\mask.jpg"

# Read image
im1 = cv2.imread(path1, cv2.IMREAD_GRAYSCALE) # Live image
im2 = cv2.imread(path2, cv2.IMREAD_GRAYSCALE) # Mask image

# Subtraction between 2 images


angio1 = cv2.subtract(im2, im1)

# Gaussian Blur Filter


# Gaussian with size of kernel 5x5 và sigma = 2)
im_blur = cv2.GaussianBlur(angio1, (5, 5), 2)

# Display

15
plt.figure()
plt.imshow(im_blur, cmap='gray')
plt.title('Gaussian Blur Filter')
plt.axis('off')
plt.show()

Result

3. Code Comparison
Sample Gaussian Blur

import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt

img = cv.imread('opencv-logo-white.png')
assert img is not None, "file could not be read, check with
os.path.exists()"

blur = cv.blur(img,(5,5))

plt.subplot(121),plt.imshow(img),plt.title('Original')
plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(blur),plt.title('Blurred')
plt.xticks([]), plt.yticks([])

16
plt.show()

ChatGPT code

import cv2
import numpy as np
import matplotlib.pyplot as plt

# Link of images
path1 = r"C:\Users\acer\Downloads\Lab1_DSA\DSA\live.jpg"
path2 = r"C:\Users\acer\Downloads\Lab1_DSA\DSA\mask.jpg"

# Read image
im1 = cv2.imread(path1, cv2.IMREAD_GRAYSCALE) # Live image
im2 = cv2.imread(path2, cv2.IMREAD_GRAYSCALE) # Mask image

# Subtraction between 2 images


angio1 = cv2.subtract(im2, im1)

# Gaussian Blur Filter


# Gaussian with size of kernel 5x5 và sigma = 2)
im_blur = cv2.GaussianBlur(angio1, (5, 5), 2)

# Display
plt.figure()
plt.imshow(im_blur, cmap='gray')
plt.title('Gaussian Blur Filter')
plt.axis('off')
plt.show()

Overall, the structure of the Sample Gaussian Blur code and the ChatGPT version is quite
similar, with both following a comparable sequence of steps including image reading,
preprocessing, applying a blur filter, and displaying the results.

V. Conclusion
In conclusion, various image processing techniques are used to enhance, analyze, and
transform digital images effectively. Gaussian blur filter proved to be particularly useful in
noise reduction and image smoothing. The results confirm that appropriate selection and
tuning of processing methods can significantly improve the performance of downstream
applications such as object detection and recognition. Overall, the results highlight the

17
importance of image preprocessing in computer vision and pave the way for advanced
methods like deep learning-based enhancement and segmentation.

18

You might also like