-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_script_PST_feb_02_2016.m
69 lines (49 loc) · 1.9 KB
/
test_script_PST_feb_02_2016.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
% test script to test PST function
clc % clear screen
clear all % clear all variables
close all % close all figures
% import original image
Image_orig=imread('lena_gray_512.tif');
% if image is a color image, convert it to grayscale
try
Image_orig=rgb2gray(Image_orig);
catch
end
%show the original image
subplot(1,2,1)
imshow(Image_orig)
title('Original Image')
% convert the grayscale image do a 2D double array
Image_orig=double(Image_orig);
% low-pass filtering (also called localization) parameter
handles.LPF=0.21; % Gaussian low-pass filter Full Width at Half Maximum (FWHM) (min:0 , max : 1)
% PST parameters
handles.Phase_strength=0.48; % PST kernel Phase Strength
handles.Warp_strength=12.14; % PST Kernel Warp Strength
% Thresholding parameters (for post processing)
handles.Thresh_min=-1; % minimum Threshold (a number between 0 and -1)
handles.Thresh_max=0.0019; % maximum Threshold (a number between 0 and 1)
% choose to compute the analog or digital edge
Morph_flag = 1 ; % Morph_flag=0 to compute analog edge and Morph_flag=1 to compute digital edge.
% Apply PST and find features (sharp transitions)
[Edge PST_Kernel]= PST(Image_orig,handles,Morph_flag);
if Morph_flag ==0
% show the detected features
subplot(1,2,2)
imshow(Edge/max(max(Edge))*3)
title('Detected features using PST')
else
subplot(1,2,2)
imshow(Edge)
title('Detected features using PST')
% overlay original image with detected features
overlay = double(imoverlay(Image_orig, Edge/1000000, [1 0 0]));
figure
imshow(overlay/max(max(max(overlay))));
title('Detected features using PST overlaid with original image')
end
% show the PST phase kernel gradient
figure
[D_PST_Kernel_x D_PST_Kernel_y]=gradient(PST_Kernel);
mesh(sqrt(D_PST_Kernel_x.^2+D_PST_Kernel_y.^2))
title('PST Kernel phase Gradient')