SlideShare a Scribd company logo
1 of 42
Download to read offline
Dr. Bilal Ghazal
Lebanese University (UL) – Faculty of Sciences IV
Info 2234 1
IMAGE PROCESSING
Image Restoration
Image degradation and restoration
2
➢ f(x,y) is the initial image
➢ H degradation function
➢ n(x,y) is the noise
➢ ෠
𝒇 𝒙, 𝒚 is an approximation of the original
Image deblurring
3
➢ Fredholm integral
➢ h(x,y) :point spread function PSF of an optical system
➢ f(x,y) is a function of real object (image)
➢ n(x,y) is an additive noise
➢ g(x,y) is an observed signal
Point spread function PSF
4
True examples
5
Point spread function PSF
➢ PSF is a deterministic fixed quantity
➢ Depends on physical hardware
❖Optical system: nature of lenses, shape
❖Medical image: Anger camera for gamma rays
❖ expect to have knowledge about PSF
➢ Noise n(x,y)
❖Stochastic in nature
❖Random and unwanted fluctuation on signal
❖Don’t have control on it
❖Calculated using integral transformation
6
Convolution
➢ If PSF h is linear and shift invariant function
➢ The degraded image is expressed in the spatial domain
by its convolution with the spatial representation of PSF
7
Frequency domain representation
➢ In frequency domain representation, the convolution
formula becomes:
➢ G(u,v) Fourier transform of g(x,y)
➢ H(u,v) Fourier transform of h(x,y)
➢ F(u,v) Fourier transform of f(x,y)
➢ N(u,v) Fourier transform of n(x,y)
8
Degradation in spatial&frequency domain
➢ In the spatial domain, degradation or blurring is
observed as
❖Fuzziness
❖Unsharpened edges
❖Small image details look undistinguishable
➢ In the frequency domain, degradation or blurring
❖Affect significantly power spectrum
❖Some zero appears ➔ some frequencies disappear
➢ Phase spectrum is slightly affected
9
-
Degradation in spatial&frequency domain
10
Degradation in spatial&frequency domain
11
Examples of different PSF
12
Examples of different PSF
13
Ideal Model
➢ Ideal model assumes that effect of noise is negligible
n(x,y) = 0
➢ Relation in frequency domain
➢ To restore our image, we should solve the F(u,v)
equation
14
-
Ideal Model
➢ In spatial domain
f(x,y) = F-1{G(u,v)/H(u,v)} = F-1{G(u,v)Y(u,v)}
Where
Y(u,v) = 1/H(u,v)
➢ H(u,v) is the optical transfer function OTF
➢ H(u,v) is called also inverse filter
➢ The deconvolution equation
f(x,y) = g(x,y)*{h(x,y)}-1
➢ This equation cannot be solved since h and H
contains zero.
15
Ideal model
➢ To restore a blurred image we should know
❖The exact PSF model
❖Function h and its spectrum H ?
➢ Apply a blind deconvolution
❖Rate of success 50%
➢ It is preferable to identify the PSF
❖Frequencies where H(u,v) are not involved in the equation
❖Use neural network
❖Use support vector machine
16
Blurred images
➢ A=imread('cameraman.tif');
➢ B=fft2(double(A));
➢ B=fftshift(B); %Read in image and take FT
➢ [x y]=size(A);
➢ [X Y]=meshgrid(1:x,1:y); %Construct Gaussian PSF
➢ h=exp(-(X -x/2).^2./48).*exp(-(Y- y/2).^2./48);
%extending over entire array
➢ H=psf2otf(h,size(h));
➢ H=fftshift(H); %Get OTF corresponding to PSF
➢ g=ifft2(B.*H); g=abs(g);
17
-
Blurred images
18
2 4
6
8
10
12
2
4
6
8
10
12
0.05
0.1
0.15
PSF
10
20
30
10
20
30
0.2
0.4
0.6
0.8
corresponding |OTF|
Blurred images
19
Blurred images
➢ G=fft2(g);
➢ G=fftshift(G); %Take FT of image
➢ indices=find(H>1e-6); %Do inverse filtering avoid 0
➢ F=zeros(size(G));
➢ F(indices)=G(indices)./H(indices);%small values in
OTF !!
➢ f=ifft2(F); f=abs(f); %Inverse FT to get filtered image
➢ subplot(1,2,1), imshow(g,[min(min(g))max(max(g))]);
➢ %Display the original blurred image
➢ subplot(1,2,2), imagesc(f);
➢ axis square; axis tight; axis off;
20
Blurred images
21
Blurred images – motion filter
➢ A=imread('cameraman.tif');
➢ B=fft2(double(A));
➢ B=fftshift(B); %Read in image and take FT
➢ [x y]=size(A);
➢ h = fspecial('motion', 10, 60);
➢ H=psf2otf(h,size(A));
➢ H=fftshift(H); %Get OTF corresponding to PSF
➢ g=ifft2(B.*H); g=abs(g);
22
-
Blurred images - motion filter
➢ G=fft2(g);
➢ G=fftshift(G); %Take FT of image
➢ indices=find(H>1e-6); %Do inverse filtering avoid 0
➢ F=zeros(size(G));
➢ F(indices)=G(indices)./H(indices);%small values in
OTF !!
➢ f=ifft2(F); f=abs(f); %Inverse FT to get filtered image
➢ subplot(1,2,1), imshow(g,[min(min(g))max(max(g))]);
➢ %Display the original blurred image
➢ subplot(1,2,2), imagesc(f);
➢ axis square; axis tight; axis off;
23
Blurred images - motion filter
24
Blurred images – disk motion
➢ A=imread('cameraman.tif');
➢ B=fft2(double(A));
➢ B=fftshift(B); %Read in image and take FT
➢ [x y]=size(A);
➢ h = fspecial(‘disk’, 4);
➢ H=psf2otf(h,size(A));
➢ H=fftshift(H); %Get OTF corresponding to PSF
➢ g=ifft2(B.*H); g=abs(g);
25
-
Blurred images – disk motion
➢ G=fft2(g);
➢ G=fftshift(G); %Take FT of image
➢ indices=find(H>1e-6); %Do inverse filtering avoid 0
➢ F=zeros(size(G));
➢ F(indices)=G(indices)./H(indices);%small values in
OTF !!
➢ f=ifft2(F); f=abs(f); %Inverse FT to get filtered image
➢ subplot(1,2,1), imshow(g,[min(min(g))max(max(g))]);
➢ %Display the original blurred image
➢ subplot(1,2,2), imagesc(f);
➢ axis square; axis tight; axis off;
26
Blurred images – disk motion
27
Disk blurring – gaussian deblurring
➢ A=imread('cameraman.tif');
➢ B=fft2(double(A));
➢ B=fftshift(B); %Read in image and take FT
➢ [x y]=size(A);
➢ h = fspecial(‘disk’, 3);
➢ H=psf2otf(h,size(A));
➢ H=fftshift(H); %Get OTF corresponding to PSF
➢ g=ifft2(B.*H); g=abs(g);
28
-
Disk blurring – gaussian deblurring
➢ G=fft2(g);
➢ G=fftshift(G); %Take FT of image
➢ h=exp(-(X -x/2).^2./48).*exp(-(Y- y/2).^2./48);
➢ H=psf2otf(h,size(A));
➢ H=fftshift(H);
➢ indices=find(H>1e-6); %Do inverse filtering avoid 0
➢ F=zeros(size(G));
➢ F(indices)=G(indices)./H(indices
➢ f=ifft2(F); f=abs(f); %Inverse FT to get filtered image
➢ subplot(1,2,1), imshow(g,[min(min(g))max(max(g))]);
➢ subplot(1,2,2), imagesc(f);
➢ axis square; axis tight; axis off;
29
Disk blurring – gaussian deblurring
30
Disk blurring – motion deblurring
31
motion blurring – disk deblurring
32
gaussian blurring – disk deblurring
33
Model with noise
➢ Frequency equation
෡
𝑭(u,v) = G(u,v)/H(u,v) + N(u,v)/H(u,v)
෡
𝑭(u,v) = F(u,v) + N(u,v)/H(u,v)
➢ ෡
𝑭(u,v) is the estimated function of F(u,v)
➢ Noise spectrum is unknown and random
➢ If |N(u,v)| >> |G(u,v)| ➔ noise completely dominate
34
Blurred images
➢ A=imread('cameraman.tif'); B=fft2(double(A));
➢ B=fftshift(B); %Read in image and take FT
➢ [x y]=size(A);
➢ [X Y]=meshgrid(1:x,1:y); %Construct Gaussian PSF
➢ h=exp(-(X -x/2).^2./48).*exp(-(Y- y/2).^2./48);
➢ H=psf2otf(h,size(h));
➢ H=fftshift(H); %Get OTF corresponding to PSF
➢ g=ifft2(B.*H);
➢ g=mat2gray(abs(g)); %Blur image in Fourier domain
➢ subplot(1,2,1),imshow(abs(g),[]);
➢ g=imnoise(g,'gaussian',0,0.002);
➢ subplot(1,2,2),imshow(abs(g),[]); 35
-
Blurred images
36
Blurred images (Same Code)
➢ G=fft2(g);
➢ G=fftshift(G); %Take FT of image
➢ indices=find(H>1e-6); %Do inverse filtering avoid 0
➢ F=zeros(size(G));
➢ F(indices)=G(indices)./H(indices);%small values in
OTF !!
➢ f=ifft2(F); f=abs(f); %Inverse FT to get filtered image
➢ subplot(1,2,1), imshow(g,[min(min(g)) max(max(g))]);
➢ %Display “
original”
blurred image
➢ subplot(1,2,2), imagesc(f);
➢ axis square; axis tight; axis off;
37
-
Blurred images
38
blurred noisy image recovery image
Wiener–Helstrom filter
➢ It is a sophisticated approach
➢ Wiener filter for white noise
➢ K noise spectrum for noise
➢ 3 cases to identify
❖If |N(u,v)| << |G(u,v)| ➔ ideal filter
❖If |N(u,v)| >> |G(u,v)|
➔ filter should approaches zero Y(u,v) 0
❖If |N(u,v)|  |G(u,v)| ➔ damped these frequencies in an
appropriate compromise
39
-
Wiener–Helstrom filter
➢ I = imread('cameraman.tif');I=double(I); %Read in image
➢ noise =15*randn(size(I)); %Generate noise
➢ PSF = fspecial('motion',21,11); %Generate motion PSF
➢ Blurred = imfilter(I,PSF,'circular'); %Blur image
➢ BlurredNoisy= Blurred +noise; %Add noise to blurred image
➢ NSR = sum(noise(:).^2)/sum(I(:).^2); % Calculate SCALAR
noise to power ratio
➢ NP = abs(fftn(noise)).^2; %Calculate noise power spectrum
➢ NPOW = sum(NP(:))/prod(size(noise)); %Calculate average
power in noise spectrum
➢ NCORR = fftshift(real(ifftn(NP))); %Get autocorrelation
function of the noise, %centred using fftshift
➢ Cont… 40
-
Wiener–Helstrom filter(Cont..)
➢ IP = abs(fftn(I)).^2; %Calculate image power spectrum
➢ IPOW = sum(IP(:))/prod(size(I)); %Calculate average power
in image spectrum
➢ ICORR = fftshift(real(ifftn(IP))); %Get autocorrelation
function of the image, %centred using fftshift
➢ NSR= NPOW./IPOW; %Scalar noise to signal power ratio
➢ subplot(1,3,1);
➢ imshow(BlurredNoisy,[min(min(BlurredNoisy))
max(max(BlurredNoisy))]); %Display blurred&noisy image';
➢ subplot(1,3,2);
➢ imshow(deconvwnr(BlurredNoisy,PSF,NSR),[]);
➢ %Wiener filtered PSF and scalar noise/ %signal power ratio
➢ subplot(1,3,3);
➢ imshow(deconvwnr(BlurredNoisy,PSF,NCORR,ICORR),[]);
%Wiener filtered PSF and noise and signal autocorrelations
41
-
Wiener–Helstrom filter
42

More Related Content

Similar to Info 2234 Chapter 8 -image restoration.pdf

chapter-2 SPACIAL DOMAIN.pptx
chapter-2 SPACIAL DOMAIN.pptxchapter-2 SPACIAL DOMAIN.pptx
chapter-2 SPACIAL DOMAIN.pptxAyeleFeyissa1
 
Image Degradation & Resoration
Image Degradation & ResorationImage Degradation & Resoration
Image Degradation & ResorationSanjay Saha
 
Lecture 2-Filtering.pdf
Lecture 2-Filtering.pdfLecture 2-Filtering.pdf
Lecture 2-Filtering.pdfTechEvents1
 
Notes on image processing
Notes on image processingNotes on image processing
Notes on image processingMohammed Kamel
 
Image trnsformations
Image trnsformationsImage trnsformations
Image trnsformationsJohn Williams
 
image_enhancement_spatial
 image_enhancement_spatial image_enhancement_spatial
image_enhancement_spatialhoneyjecrc
 
Image Processing
Image ProcessingImage Processing
Image Processingtijeel
 
07 frequency domain DIP
07 frequency domain DIP07 frequency domain DIP
07 frequency domain DIPbabak danyal
 
FourierTransform detailed power point presentation
FourierTransform detailed power point presentationFourierTransform detailed power point presentation
FourierTransform detailed power point presentationssuseracb8ba
 
04 cie552 image_filtering_frequency
04 cie552 image_filtering_frequency04 cie552 image_filtering_frequency
04 cie552 image_filtering_frequencyElsayed Hemayed
 
Hyperfunction method for numerical integration and Fredholm integral equation...
Hyperfunction method for numerical integration and Fredholm integral equation...Hyperfunction method for numerical integration and Fredholm integral equation...
Hyperfunction method for numerical integration and Fredholm integral equation...HidenoriOgata
 
Digital Image Processing - Image Restoration
Digital Image Processing - Image RestorationDigital Image Processing - Image Restoration
Digital Image Processing - Image RestorationMathankumar S
 
CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10fungfung Chen
 

Similar to Info 2234 Chapter 8 -image restoration.pdf (19)

chapter-2 SPACIAL DOMAIN.pptx
chapter-2 SPACIAL DOMAIN.pptxchapter-2 SPACIAL DOMAIN.pptx
chapter-2 SPACIAL DOMAIN.pptx
 
Image Degradation & Resoration
Image Degradation & ResorationImage Degradation & Resoration
Image Degradation & Resoration
 
In2414961500
In2414961500In2414961500
In2414961500
 
Lecture 2-Filtering.pdf
Lecture 2-Filtering.pdfLecture 2-Filtering.pdf
Lecture 2-Filtering.pdf
 
Notes on image processing
Notes on image processingNotes on image processing
Notes on image processing
 
Image trnsformations
Image trnsformationsImage trnsformations
Image trnsformations
 
Week 6
Week 6Week 6
Week 6
 
Lecture5 kernel svm
Lecture5 kernel svmLecture5 kernel svm
Lecture5 kernel svm
 
Image restoration and reconstruction
Image restoration and reconstructionImage restoration and reconstruction
Image restoration and reconstruction
 
image_enhancement_spatial
 image_enhancement_spatial image_enhancement_spatial
image_enhancement_spatial
 
Image Processing
Image ProcessingImage Processing
Image Processing
 
07 frequency domain DIP
07 frequency domain DIP07 frequency domain DIP
07 frequency domain DIP
 
FourierTransform detailed power point presentation
FourierTransform detailed power point presentationFourierTransform detailed power point presentation
FourierTransform detailed power point presentation
 
04 cie552 image_filtering_frequency
04 cie552 image_filtering_frequency04 cie552 image_filtering_frequency
04 cie552 image_filtering_frequency
 
Hyperfunction method for numerical integration and Fredholm integral equation...
Hyperfunction method for numerical integration and Fredholm integral equation...Hyperfunction method for numerical integration and Fredholm integral equation...
Hyperfunction method for numerical integration and Fredholm integral equation...
 
Digital Image Processing - Image Restoration
Digital Image Processing - Image RestorationDigital Image Processing - Image Restoration
Digital Image Processing - Image Restoration
 
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...
 
CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10
 
Online Signal Processing Assignment Help
Online Signal Processing Assignment HelpOnline Signal Processing Assignment Help
Online Signal Processing Assignment Help
 

Recently uploaded

Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 

Recently uploaded (20)

Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 

Info 2234 Chapter 8 -image restoration.pdf

  • 1. Dr. Bilal Ghazal Lebanese University (UL) – Faculty of Sciences IV Info 2234 1 IMAGE PROCESSING Image Restoration
  • 2. Image degradation and restoration 2 ➢ f(x,y) is the initial image ➢ H degradation function ➢ n(x,y) is the noise ➢ ෠ 𝒇 𝒙, 𝒚 is an approximation of the original
  • 3. Image deblurring 3 ➢ Fredholm integral ➢ h(x,y) :point spread function PSF of an optical system ➢ f(x,y) is a function of real object (image) ➢ n(x,y) is an additive noise ➢ g(x,y) is an observed signal
  • 6. Point spread function PSF ➢ PSF is a deterministic fixed quantity ➢ Depends on physical hardware ❖Optical system: nature of lenses, shape ❖Medical image: Anger camera for gamma rays ❖ expect to have knowledge about PSF ➢ Noise n(x,y) ❖Stochastic in nature ❖Random and unwanted fluctuation on signal ❖Don’t have control on it ❖Calculated using integral transformation 6
  • 7. Convolution ➢ If PSF h is linear and shift invariant function ➢ The degraded image is expressed in the spatial domain by its convolution with the spatial representation of PSF 7
  • 8. Frequency domain representation ➢ In frequency domain representation, the convolution formula becomes: ➢ G(u,v) Fourier transform of g(x,y) ➢ H(u,v) Fourier transform of h(x,y) ➢ F(u,v) Fourier transform of f(x,y) ➢ N(u,v) Fourier transform of n(x,y) 8
  • 9. Degradation in spatial&frequency domain ➢ In the spatial domain, degradation or blurring is observed as ❖Fuzziness ❖Unsharpened edges ❖Small image details look undistinguishable ➢ In the frequency domain, degradation or blurring ❖Affect significantly power spectrum ❖Some zero appears ➔ some frequencies disappear ➢ Phase spectrum is slightly affected 9 -
  • 14. Ideal Model ➢ Ideal model assumes that effect of noise is negligible n(x,y) = 0 ➢ Relation in frequency domain ➢ To restore our image, we should solve the F(u,v) equation 14 -
  • 15. Ideal Model ➢ In spatial domain f(x,y) = F-1{G(u,v)/H(u,v)} = F-1{G(u,v)Y(u,v)} Where Y(u,v) = 1/H(u,v) ➢ H(u,v) is the optical transfer function OTF ➢ H(u,v) is called also inverse filter ➢ The deconvolution equation f(x,y) = g(x,y)*{h(x,y)}-1 ➢ This equation cannot be solved since h and H contains zero. 15
  • 16. Ideal model ➢ To restore a blurred image we should know ❖The exact PSF model ❖Function h and its spectrum H ? ➢ Apply a blind deconvolution ❖Rate of success 50% ➢ It is preferable to identify the PSF ❖Frequencies where H(u,v) are not involved in the equation ❖Use neural network ❖Use support vector machine 16
  • 17. Blurred images ➢ A=imread('cameraman.tif'); ➢ B=fft2(double(A)); ➢ B=fftshift(B); %Read in image and take FT ➢ [x y]=size(A); ➢ [X Y]=meshgrid(1:x,1:y); %Construct Gaussian PSF ➢ h=exp(-(X -x/2).^2./48).*exp(-(Y- y/2).^2./48); %extending over entire array ➢ H=psf2otf(h,size(h)); ➢ H=fftshift(H); %Get OTF corresponding to PSF ➢ g=ifft2(B.*H); g=abs(g); 17 -
  • 20. Blurred images ➢ G=fft2(g); ➢ G=fftshift(G); %Take FT of image ➢ indices=find(H>1e-6); %Do inverse filtering avoid 0 ➢ F=zeros(size(G)); ➢ F(indices)=G(indices)./H(indices);%small values in OTF !! ➢ f=ifft2(F); f=abs(f); %Inverse FT to get filtered image ➢ subplot(1,2,1), imshow(g,[min(min(g))max(max(g))]); ➢ %Display the original blurred image ➢ subplot(1,2,2), imagesc(f); ➢ axis square; axis tight; axis off; 20
  • 22. Blurred images – motion filter ➢ A=imread('cameraman.tif'); ➢ B=fft2(double(A)); ➢ B=fftshift(B); %Read in image and take FT ➢ [x y]=size(A); ➢ h = fspecial('motion', 10, 60); ➢ H=psf2otf(h,size(A)); ➢ H=fftshift(H); %Get OTF corresponding to PSF ➢ g=ifft2(B.*H); g=abs(g); 22 -
  • 23. Blurred images - motion filter ➢ G=fft2(g); ➢ G=fftshift(G); %Take FT of image ➢ indices=find(H>1e-6); %Do inverse filtering avoid 0 ➢ F=zeros(size(G)); ➢ F(indices)=G(indices)./H(indices);%small values in OTF !! ➢ f=ifft2(F); f=abs(f); %Inverse FT to get filtered image ➢ subplot(1,2,1), imshow(g,[min(min(g))max(max(g))]); ➢ %Display the original blurred image ➢ subplot(1,2,2), imagesc(f); ➢ axis square; axis tight; axis off; 23
  • 24. Blurred images - motion filter 24
  • 25. Blurred images – disk motion ➢ A=imread('cameraman.tif'); ➢ B=fft2(double(A)); ➢ B=fftshift(B); %Read in image and take FT ➢ [x y]=size(A); ➢ h = fspecial(‘disk’, 4); ➢ H=psf2otf(h,size(A)); ➢ H=fftshift(H); %Get OTF corresponding to PSF ➢ g=ifft2(B.*H); g=abs(g); 25 -
  • 26. Blurred images – disk motion ➢ G=fft2(g); ➢ G=fftshift(G); %Take FT of image ➢ indices=find(H>1e-6); %Do inverse filtering avoid 0 ➢ F=zeros(size(G)); ➢ F(indices)=G(indices)./H(indices);%small values in OTF !! ➢ f=ifft2(F); f=abs(f); %Inverse FT to get filtered image ➢ subplot(1,2,1), imshow(g,[min(min(g))max(max(g))]); ➢ %Display the original blurred image ➢ subplot(1,2,2), imagesc(f); ➢ axis square; axis tight; axis off; 26
  • 27. Blurred images – disk motion 27
  • 28. Disk blurring – gaussian deblurring ➢ A=imread('cameraman.tif'); ➢ B=fft2(double(A)); ➢ B=fftshift(B); %Read in image and take FT ➢ [x y]=size(A); ➢ h = fspecial(‘disk’, 3); ➢ H=psf2otf(h,size(A)); ➢ H=fftshift(H); %Get OTF corresponding to PSF ➢ g=ifft2(B.*H); g=abs(g); 28 -
  • 29. Disk blurring – gaussian deblurring ➢ G=fft2(g); ➢ G=fftshift(G); %Take FT of image ➢ h=exp(-(X -x/2).^2./48).*exp(-(Y- y/2).^2./48); ➢ H=psf2otf(h,size(A)); ➢ H=fftshift(H); ➢ indices=find(H>1e-6); %Do inverse filtering avoid 0 ➢ F=zeros(size(G)); ➢ F(indices)=G(indices)./H(indices ➢ f=ifft2(F); f=abs(f); %Inverse FT to get filtered image ➢ subplot(1,2,1), imshow(g,[min(min(g))max(max(g))]); ➢ subplot(1,2,2), imagesc(f); ➢ axis square; axis tight; axis off; 29
  • 30. Disk blurring – gaussian deblurring 30
  • 31. Disk blurring – motion deblurring 31
  • 32. motion blurring – disk deblurring 32
  • 33. gaussian blurring – disk deblurring 33
  • 34. Model with noise ➢ Frequency equation ෡ 𝑭(u,v) = G(u,v)/H(u,v) + N(u,v)/H(u,v) ෡ 𝑭(u,v) = F(u,v) + N(u,v)/H(u,v) ➢ ෡ 𝑭(u,v) is the estimated function of F(u,v) ➢ Noise spectrum is unknown and random ➢ If |N(u,v)| >> |G(u,v)| ➔ noise completely dominate 34
  • 35. Blurred images ➢ A=imread('cameraman.tif'); B=fft2(double(A)); ➢ B=fftshift(B); %Read in image and take FT ➢ [x y]=size(A); ➢ [X Y]=meshgrid(1:x,1:y); %Construct Gaussian PSF ➢ h=exp(-(X -x/2).^2./48).*exp(-(Y- y/2).^2./48); ➢ H=psf2otf(h,size(h)); ➢ H=fftshift(H); %Get OTF corresponding to PSF ➢ g=ifft2(B.*H); ➢ g=mat2gray(abs(g)); %Blur image in Fourier domain ➢ subplot(1,2,1),imshow(abs(g),[]); ➢ g=imnoise(g,'gaussian',0,0.002); ➢ subplot(1,2,2),imshow(abs(g),[]); 35 -
  • 37. Blurred images (Same Code) ➢ G=fft2(g); ➢ G=fftshift(G); %Take FT of image ➢ indices=find(H>1e-6); %Do inverse filtering avoid 0 ➢ F=zeros(size(G)); ➢ F(indices)=G(indices)./H(indices);%small values in OTF !! ➢ f=ifft2(F); f=abs(f); %Inverse FT to get filtered image ➢ subplot(1,2,1), imshow(g,[min(min(g)) max(max(g))]); ➢ %Display “ original” blurred image ➢ subplot(1,2,2), imagesc(f); ➢ axis square; axis tight; axis off; 37 -
  • 38. Blurred images 38 blurred noisy image recovery image
  • 39. Wiener–Helstrom filter ➢ It is a sophisticated approach ➢ Wiener filter for white noise ➢ K noise spectrum for noise ➢ 3 cases to identify ❖If |N(u,v)| << |G(u,v)| ➔ ideal filter ❖If |N(u,v)| >> |G(u,v)| ➔ filter should approaches zero Y(u,v) 0 ❖If |N(u,v)|  |G(u,v)| ➔ damped these frequencies in an appropriate compromise 39 -
  • 40. Wiener–Helstrom filter ➢ I = imread('cameraman.tif');I=double(I); %Read in image ➢ noise =15*randn(size(I)); %Generate noise ➢ PSF = fspecial('motion',21,11); %Generate motion PSF ➢ Blurred = imfilter(I,PSF,'circular'); %Blur image ➢ BlurredNoisy= Blurred +noise; %Add noise to blurred image ➢ NSR = sum(noise(:).^2)/sum(I(:).^2); % Calculate SCALAR noise to power ratio ➢ NP = abs(fftn(noise)).^2; %Calculate noise power spectrum ➢ NPOW = sum(NP(:))/prod(size(noise)); %Calculate average power in noise spectrum ➢ NCORR = fftshift(real(ifftn(NP))); %Get autocorrelation function of the noise, %centred using fftshift ➢ Cont… 40 -
  • 41. Wiener–Helstrom filter(Cont..) ➢ IP = abs(fftn(I)).^2; %Calculate image power spectrum ➢ IPOW = sum(IP(:))/prod(size(I)); %Calculate average power in image spectrum ➢ ICORR = fftshift(real(ifftn(IP))); %Get autocorrelation function of the image, %centred using fftshift ➢ NSR= NPOW./IPOW; %Scalar noise to signal power ratio ➢ subplot(1,3,1); ➢ imshow(BlurredNoisy,[min(min(BlurredNoisy)) max(max(BlurredNoisy))]); %Display blurred&noisy image'; ➢ subplot(1,3,2); ➢ imshow(deconvwnr(BlurredNoisy,PSF,NSR),[]); ➢ %Wiener filtered PSF and scalar noise/ %signal power ratio ➢ subplot(1,3,3); ➢ imshow(deconvwnr(BlurredNoisy,PSF,NCORR,ICORR),[]); %Wiener filtered PSF and noise and signal autocorrelations 41 -