Image Blending Using Unitery CNN Algorithm
Image Blending Using Unitery CNN Algorithm
PROJECT REPORT
Submitted by:
PROJECT REPORT
DIVISION OF ELECTRONICS
AND COMMUNICATION
ENGINEERING 2023-2024
COCHIN UNIVERSITY OF SCIENCE AND TECHNOLOGY
COCHIN UNIVERSITY COLLEGE OF ENGINEERING
KUTTANAD, PULINCUNNU
CERTIFICATE
Certified that this is a bonafide on the main entitled
Submitted by:
During the year 2024 in partial fulfilment for the award of the degree of Bachelor of
Technology in Electronics and Communication Engineering from CUSAT.
We thank the Supreme Lord for imparting us with the spiritual energy in the
right direction which has led to the successful completion of the Project Report.
We would also like to thank the Principal, Dr. Joseph Kutty Jacob, for the
facilities provided by him during the preparation of the report. We are
extremely thankful to the Head of the Department of Electronics and
Communication Engineering, Dr. Anilkumar K K, for giving all the support and
valuable directions in overcoming the difficulties faced during the preparation
of the report.
We express our sincere thanks to the Project Coordinator, Dr. Anilkumar K K,
for giving innovative suggestions, timely advice, correction advice and
suggestions during this endeavour. We feel to acknowledge our indebtedness
and deep sense of gratitude to our Guide, Mr. Nishanth R, whose guidance and
kind supervision given us throughout the course which shaped the present work
as its show.
We also express our gratitude towards all faculties of CUCEK for their
encouragement. We also express our deep sense of thanks to all of our
classmates and friends for their support, constructive criticism and
suggestions.
ABSTRACT
3. LITERATURE SURVEY
4. EXISTING TECHNOLOGIES
5. METHODOLOGY
7. RESULT
8. CONCLUSION
9. FUTURE SCOPE
10. REFERENCES
11. APPENDIX
TABLE OF FIGURE
3. NORMALIZED IMAGES
5. CONTRAST ENHANCEMENT
6. AUGMENTED IMAGES
8. RESULTS
1. INTRODUCTION
Aim:
The aim of this project is to develop and implement a method for
restoring composite images using a novel image restoration process
with alpha blending for image fusion enhancement.
Objectives:
• To design and implement a preprocessing stage that includes
normalization, noise removal, and image augmentation
techniques to prepare input images for fusion.
• To develop an image fusion stage that combines preprocessed
images using alpha blending to create a composite image that is
more informative than any of the input images.
• To evaluate the quality of the composite image through
postprocessing techniques such as block diagram analysis.
• To demonstrate the effectiveness of the proposed method in
restoring composite images degraded by noise, blur, or other
imperfections.
• To assess the capability of the method in improving the quality of
composite images created from low-quality input images,
utilizing alpha blending for additional control over final image
characteristics.
LITERATURE SURVEY
4. Patch-Based Approaches:
Patch-based techniques divide the image into smaller patches and use
information from similar patches in the image to reconstruct missing regions.
These methods are effective when there are similar structures or textures present
in the image.
.....
/ Segmentation
,..,..,.. Blending
0 0
0z >I Registration
I
Deconvolution
0 >I I
0
.....
/ Artifact Removal
.....
/
Machine
*Registration: Align multiple images of the same patient or different imaging modalities
*Deconvolution: Enhance image resolution
METHODOLGY
In the process of collecting medical images for your project report, several
crucial steps ensure the integrity, relevance, and ethical compliance of the data.
Firstly, select a dataset that aligns with your research question, considering
factors like size, relevance, and the availability of required image types (e.g.,
X rays, MRI scans). Ensure legal permission for dataset use, verify image
quality, and standardize format.
• Define Criteria: Determine the specific criteria for selecting images
based on your project requirements.
• Visual Inspection: Review the sampled images visually to assess their
quality and relevance.
• Validation: Validate the selected images against your predefined criteria
to ensure they meet the desired standards
• Annotation: If necessary, annotate the selected images with relevant
labels or annotations for further analysis or machine learning tasks
• Storage and Organization
• Backup and Version Control
• Ethical Considerations
2.3 PREPROCESSING
2.5
0.5
o. ,_i
0 50 100 150
200 250
Pixel Intensity
Difference Image
3.5
2.5
15
0.5
1•
Figure 5: (a: original image, b: equalized image, c,d: histogram of original image, equalized image)
After Equalization:
This histogram will ideally be more spread out across the entire
intensity range.Each intensity value should have a more balanced
representation, indicating improved contrast between different
brain regions.
2.3.4 Resizing:
Re-sizing adjusts image dimensions to a desired size, crucial in
standardizing resolution and aspect ratio across data sets. It ensures
consistency in prepossessing and model training, reducing
variability in image sizes. Various interpolation methods preserve
image quality while resizing, including nearest-neighbour, bi-linear,
or cubic. Resizing may also involve cropping or padding images
for specific input requirements. Overall, resizing facilitates
compatibility across different stages of the image processing
pipeline, promoting efficient analysis and model deployment.
2.3.5 Augmentation:
Augmentation is a data enhancement technique used in machine
learning, including medical image analysis. It involves applying
transformations like rotation, flipping, and scaling to increase
dataset diversity. By exposing the model to varied data,
augmentation helps prevent overfitting and improves
generalization. In medical imaging, it's valuable for tasks like
classification and segmentation, where diverse image appearances
are common.
Image Fusion:
Image fusion involves combining multiple images acquired from
different sources or modalities, each potentially containing its own set
of errors or artifacts. By fusing these images, the errors present in one
image may be compensated for by the information from other images,
leading to a final fused image with reduced overall errors. For
example, if one image has noise artifacts while another has blur
artifacts, fusion techniques can combine the sharp details from one
image with the noise reduction from another, resulting in a fused
image with improved clarity and reduced noise.
Image Blending:
Image blending techniques can further refine the fused images by
seamlessly integrating them to create a visually coherent composite
image. Blending methods such as alpha blending or gradient domain
blending can be used to blend images with different errors, ensuring
smooth transitions and maintaining consistency across the composite
image. By blending images with different errors, you can effectively
combine their strengths while minimizing the impact of individual
errors, resulting in a final image that is visually appealing and
accurately represents the underlying data.
Equation that is used to implement these is given below with a brief
explanation:
blended_image = uint8((alphas(i) * double(imagel) + alphas(i) *
double(image2) + alphas(i) * double(image3) + alphas(i) *
double(image4) + alphas(i) * double(image5)) I 5);
Type Conversion:
Normalization:
• After obtaining the weighted sum of pixel values from all input
images, the sum is divided by the total number of images (5 in
this case).
• This step normalizes the blended image to ensure that the pixel
values are within the valid range (0 to 255 for uint8), suitable
for display and further processing.
Version: The code provided was developed and tested using MATLAB version
X.XX.
Version: The code relies on functions from the Image Processing Toolbox,
version X.XX.
• imgaussfilt:
• 1mwarp:
• imref2d:
Functionality: The irnref2d function is crucial for creating 2-D spatial
referencing objects, enabling the association of spatial information with
images, such as defining pixel coordinates.
Description: The rms function computes the Root Mean Square value of
an image or a part of an image, representing the average magnitude of
pixel intensities.
4.1 Kaggle
KaggleAPI:
Software Requirements:
To utilize the Kaggle API, ensure that Python is installed on your system along
with the kaggle Python package. The kaggle package can be installed via pip,
the Python package manager.
4.2 Kenhub
Verify the format of the dataset provided by Kenhub. It may be in standard file
formats such as CSV, DICOM, or proprietary formats specific to medical
1magmg.
Software Requirements:
Depending on the dataset's format and content, you may need specialized
software for medical image viewing, analysis, or processing. Common software
includes DICOM viewers, medical image analysis software, or programming
environments like MATLAB or Python with libraries such as NumPy, SciPy,
and scikit-image for image processing tasks.
Software Requirement:
DICOM Viewer:
3.1.1 Pseudocode
originallmage = imread(imagepath);
% Define a mask
maskedlmage = originallmage;
imshow(maskedlmage);
3.1.2 Algorithm
• Initialize the mask with all pixels set to a value representing the
background (e.g., logical false for binary masks).
Start
l
Initialize Environment
l
Loadimages
Create Masks
l
DefiI Regions
Apply Masks
Displt Results
l
End
Image 1 Image 2
\.
I I
t
Normalization
l
Noise Removal
l 0
i--;
(D
i--;
Augmentation ()
(D
rJJ
.....
l
rJJ
:::s
(JO
Contrast
l
Resize
1
Image Fusion
w
0
Image Blending rJJ
'"d
l
i--;
0
()
(D
rJJ
.....
rJJ
:::s
Composite Image/ Resultant Image (JO
w
Quality Evolution
-
Block Diagram
lmgS lmg4 lmg3 lmg2 lmgl
l
Double
l
Double
l
Double
l
Double Double
l
lmgS lmg4 lmg3 lmg2 lmgl
>
=-
t--- --------t-- -----+------.----------11----------+-......----------1 n
=-
=
=
-
-
-
w \I w w w
Adder
D
1/5
Divider Block
D
Blended Image
3.2 Pre- Processing
3.2.1 Algorithms
Normalization:
Noise Removal:
Augmentation:
• Read the input image.
• Define a mask on the image.
• Apply the mask to create a masked image.
• Normalize the masked image.
• Augment the image by rotating it multiple times.
• Display the original and augmented images.
3.2.2 Pseudocodes
1. Normalization:
• Input: Image path
• Output: Normalized image
• Load the image from the specified path
• Convert the image to double precision
• Calculate the minimum and maximum pixel values in the image
• Normalize the pixel values in the image between O and 1
• Return the normalized image
2. Noise Removal:
• Input: Image path, Sigma value for Gaussian filter
• Output: Noise-reduced image
• Load the image from the specified path
• Apply a Gaussian filter to the image for noise reduction with the
specified sigma value
• Return the noise-reduced image
3. Enhancement:
• Input: Image path
• Output: Equalized image and its histogram
• Load the image from the specified path
• Convert the image to grayscale
• Perform histogram equalization on the grayscale image
• Return the equalized image and its histogram
4. Augmentation:
Input: Image path, Number of augmented images
Output: Augmented images
Load the image from the specified path
Normalize the masked image
Augment the image by rotating it multiple times
Return the augmented images
3.2.3 FLOW CHART
START
\I
\,/
w \I \I
• • Load
• Load image • Load Image
Load Image Image
• Convert to
• Apply • Perform
histogram
• Normalize
the image
• Calculate the
min/max
by rotating
in different
angles
• Normalise
pixels values
Output- Normalized
ima!!:e
Output: Augmented
Image END
3.3 Image Fusion and Blending
3.3.1 Algorithm
START
l
Read Input Images
l
ResizeImages
l
Create Figure
l
Alpha Blending Loop
l
Display Output Images
l
End
3.3.3 PSEUDOCODE
15
(l'.
z
(/)
Cl.
10
5
0 0.2 0.4
0.6 0.8 1.2
Alpha
RMS Curve
100
(/) 80
(l'. 60
40
20
0 0.2 0.4
0.6 0.8 1.2
Alpha
SSIM Curve
o.9r--------r-----,1----,1----------r1- --------=.;c::::=ir:::;:::::::;=B="'=---i
0.8-
.,,,A
vi 0-.7
(/)
0.5 - I
0 0.2 0.4 0.6
0.8 1.2
Alpha
Overall Conclusion:
• Increasing the alpha value in the blending process leads to
improvements in image quality, as evidenced by higher PSNR
values, lower RMS values, and higher SSIM values.
• Therefore, selecting higher alpha values for blending results in
better-quality blended images with reduced noise, more consistent
pixel values, and improved structural similarity to the original
images.
RESULTS
fx % a Z Profiler
Find T
Refoctor Analyze Stop
Boolcmarlc •
Figurel 0 ><
+♦ 'J] ► 0: ► project oot put image ► mulllple1mage ptoJect ► Edit View Insert Tools Desktop Window Help • p
CUrrem Folder ® Command Wil I'.:) aD i;3 Ci
>> pre .,
outlutc-orrection Error u
ii
(E
O 1 NormaUnd lma IM-Remowd lmaQe (Gauulan Fitter)
H
5blendingandacruracytesting..m Ir.dex e
11.pdf
:£11111.Jpg
Error .i.
■ -accuracyallJpg
s.Jll
a1aphahnear.m Con1r•it'"ilm111t Augmenilmago1 Augmeimago2
ALPHArmsPSNRsso.m
fa.»
a1J9ment22.m
augmentanon.m
benlidnigoutpot4.m E:d1lor-
8151NPUT.m D
!,binary1mage.png
finarplo
· b1emdedlastone.png
blended5lastoutpulpng 1
I blend,goutSx2jpg
.._ blending5images.m
Name• Value
:!:angle
C) au9mentedlm... lx15c-elt
10 mask = false(size(originalimage, 1), sizeforiginalimage, 2));
equal12edlma... 721x1280x]dou...
11 mask(S0:150, 100:200) = true;
1magepath 'D:\proJectoutp... 12
mask 721x12801og«al 13 X Apply the mask
maskedlmage 721x1280x1utnt8
no,malizedlm_ 721x1280x1dou.M 14 maskedimage = originalimage;
numAugment .. 15 15 maskedimage( repmat(mask, (1, 1, size(originalimage, 3)])) = 0;
orig1nallmage 721x1280x1utnt8 16
sigma 1
17
smootl\eium... 721x1280x] dou...
I• • "• • •
==
••11
% ta! Profiler
Refactor Analyze S1op
,,gure2 0 ><
♦ + t ► 0: ► projectoutput1mage ► mult1ple1mageptOJect ► File Edit v,ew Insert Tools Desktop Window Help • p
©
current :::•- ® Co::-;r:_,.. 0_0_ _: -[i_- ,
(F oututcorrection Error
lmage1 /mage2 lmage3 lmage4 lmag,e5
m m
Sblendingandacruracytesting.m
ril il
:r.dex
• 11.pdf
t1111t.Jpg !)
• accuracyallJpg
alaphahnear.m Alpha•O Alpha•0.1 Alpha•0.2 A.lpha•0.3 Alpha•0.4
ALPHArmsPSNRsso.m
asdlds.m
augment22-m
>> fin
fa.»
I I I I I
augmentation.m Alpha•0.5 Alpha•0.6 Alpha•0.7 Alpha•0.8 Alpha•0.9
benlidnigoutp0t4.m
Bl51NPUT.m
::binary1mage.png
- blemdedlastone.png
Editor·
finalplo
1
I
Alpha=1 Alpha=1.1 Alpha=1_2 oject\normalizedBT 01. png·);
blended51asloutpulpng
2
!{.blend1gout5x2.jpg oject\normalizedBT 2. png');
blending5images.m oject\normalizedBl 3. png'); X Provide the path t
Details PSNRCur,,eg Curve oject\normalizedBir 4. png'); % Provide the path t
20 o.:1Zfs.1M Curve ject\normalizedBT 5. png'); X Provide the path t
15 0.;,ocli
>
Workspace 0 07
1 50 06
Name• Value 0 05 I Ir O 05 1 0 05 1
I alphas 1x13dooO/e Alpha Alpha Alpha mage3, 1), size(image4, 1), size(image5, 1)]);
± angle 289
10 111in_ idffi = 111 n s ze 111a1e1, , s ze 1e2, size(:mage3, 2), size(image4, 2), size(image5, 2)]);
() augmentedlm,M 1x15celt
blendeiuma_ 839x475x] u<r1t8 11 imagel = imresize(imagel, [min_height, min_width]);
equahzedlma... 721x1280xJ dou... 12 image2 = imresize(image2, [min_height, min_1,idth]);
13 13 image3 = imresize(image3, [min_height, min_1,idth]);
1magel 839x475x] u<r118
1ma9e2 839x475x]u<r118 14 image4 = imresize(image4, [min_height, min_1,idth]);
1mage3 839x475x]W1l8 15 images = imresize(imageS, [min_height, min_width]);
1mage4 839x475X]IJ<tll8 16
images 839x475x]u<r118
17
,magepath 'D:\pro1ectou1p...
• •" I • • • • •
Future research in this area may involve optimizing alpha blending algorithms
to achieve low-latency processing, ensuring real-time image fusion capabilities
during surgical procedures. Additionally, incorporating advanced registration
techniques into the image fusion process can help achieve accurate alignment of
pre-operative and intra-operative images, enhancing the reliability and
effectiveness of surgical navigation systems.
Overall, the future scope of real-time medical image fusion for surgical
navigation represents a natural extension of the current project, leveraging the
foundational concepts and techniques of alpha blending to address critical
challenges in surgical navigation and improve patient care in minimally
. .
mvas1ve surgery.
2. AI-driven Assistive Technologies for Image-guided
Interventions:
■ Image Dataset 1:
Kenhub, "Medical Imaging and Radiological Anatomy," Kenhub.com.
[Online]. Available:
https://www.kenhub.com/en/library/anatomy/medical-imaging-and
radiological-anatomy. [Accessed: 5 April 2024].
■ Image Dataset 2:
K. Mader, "SIIM Medical Images," Kaggle, Month Year. [Online].
Available: https://www.kaggle.com/datasets/kmader/siim-medical-images.
[Accessed: 5 April 2024].
Appendix 1
% Define a mask
mask= false(size( originallmage, 1), size(originallmage, 2));
mask(50: 150, 100:200) = true;
% Display images
figure;
% Original Image
subplot(5, 3, 1);
imshow(originallmage );
title('Original Image');
% Normalized Image
subplot(5, 3, 2);
imshow(normalizedimage);
title('Normalized Image');
% Contrast-Enhanced Image
subplot(5, 3, 4);
imshow(equalizedimage);
title('Contrast-Enhanced Image');
% Augmented Images
for i = 1:numAugmentedimages
subplot(5, 3, i + 4);
imshow(augmentedimages{i});
title(['Augmented Image ' num2str(i)]);
end
subplot(5, 5, 23);
plot(alphas, rms_values, 'o-');
title('RMS Curve');
xlabel('Alpha');
ylabel('RMS Value');
grid on;
subplot(5, 5, 24);
plot(alphas, ssim_values, 'o-');
title('SSIM Curve');
xlabel('Alpha');
ylabel('SSIM Value');
grid on;