Skip to content

Commit ce27dca

Browse files
add: new functions, gui
1 parent fb3ef41 commit ce27dca

16 files changed

+1301
-16
lines changed

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
# vectofil+
2-
A program to perform Basic Vector Directional Filtering for the noisy color images. This a project of Computer Vision and Image Processing course in West Pomeranian University of Technology.
2+
A program to perform Basic Vector Directional Filtering for the noisy colour images. This a project of Computer Vision and Image Processing course in West Pomeranian University of Technology.
33

4-
For the demostration, check out Results directory, or [see the GUI on YouTube](https://www.youtube.com/watch?v=pXBCrB0VlLY).
4+
For the demonstration, check out Results directory, or [see the GUI on YouTube](https://www.youtube.com/watch?v=pXBCrB0VlLY).
55

66
### What we will add?
7-
- Save the output functionality.
8-
- Save the process as a PDF and PNGs functionality
9-
- Choosing the Vector Median Filtering or Basic Vector Directional Filtering process. Comperasion between two filters.
10-
- Percentage addition between VMF and BVDF.
11-
- Much more pretty UI!
12-
- Documentation for every function. Especially lots of comments on the file of BVDF_FILTER.
7+
8+
- [ ] Save the output functionality.
9+
10+
- [ ] Save the process as a PDF and PNGs functionality.
11+
12+
- [x] Choosing the Vector Median Filtering or Basic Vector Directional Filtering process. Comperasion between two filters.
13+
14+
- [x] Percentage addition between VMF and BVDF.
15+
16+
- [x] Much more pretty UI!
17+
18+
- [ ] Documentation for every function. Especially lots of comments on the file of BVDF_FILTER.
1319

1420
### License
1521
This is a art of open source. Please make sure that you also create an open source for the public good.
22+
23+
License: GNU v2
24+
Binary file not shown.
Binary file not shown.

results/Lenna-VMF-BVDF-60.pdf

935 KB
Binary file not shown.

src/API/bvdf_plot_vectors.m renamed to src/API/3DVectorPlot.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function bvdf_plot_vectors(vectors, origin, ColorScheme)
2-
% BVDF_PLOT_VECTORS The function plots the 3D vectors in space.
1+
function 3DVectorPlot(vectors, origin, ColorScheme)
2+
% 3DVectorPlot The function plots the 3D vectors in space.
33
% Only and first parameter is the matrix which every column is a vector.
44

55
% Control if the optional arguments are given.
@@ -34,4 +34,4 @@ function bvdf_plot_vectors(vectors, origin, ColorScheme)
3434
end
3535

3636
hold off;
37-
end
37+
end

src/API/bvdf_add_noise.m renamed to src/API/AddPseudoNoise.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function noisy_img = bvdf_add_noise(image, perc, channel_size, assigned)
1+
function noisy_img = AddPseudoNoise(image, perc, channel_size, assigned)
22
noisy_img = image;
33

44
% Travel throught every pixel.
@@ -27,4 +27,4 @@
2727
end
2828
end
2929
end
30-
end
30+
end
File renamed without changes.

src/API/bvdf_filter.m renamed to src/API/BasicVectorDirectionalFilter.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function filtered_image = bvdf_filter(image, sample_dims)
1+
function filtered_image = BasicVectorDirectionalFilter(image, sample_dims)
22
% BVDF_FILTER Function to filter the image according the BVDF rule.
33
if nargin < 2
44
error("You have to give the image as uint8 matrix, and dimensions of the vectoral process.");
@@ -21,7 +21,7 @@
2121
area2filter = im2double(area2filter).*255;
2222

2323
vectors_list = reshape(area2filter , [], 3)';
24-
sorted_vectors = bvdf_sort_vectors(vectors_list);
24+
sorted_vectors = SortVectorsbyAngle(vectors_list);
2525
filtered_image(x_index, y_index, :) = sorted_vectors(:, 1);
2626
end
2727
end

src/API/ColorImageDifference.m

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
% COLORIMAGEDIFFERENCE
2+
3+
function [resultedImage, differentPixelCount] = ColorImageDifference(image1, image2)
4+
sizeImg1 = size(image1);
5+
sizeImg2 = size(image2);
6+
differentPixelCount = 0;
7+
8+
if (sizeImg1 - sizeImg2) ~= zeros(1, 3)
9+
error("Given input images' sizes are not matched.");
10+
end
11+
12+
resultedImage = zeros(sizeImg1);
13+
14+
for rowPixel = 1:sizeImg1(1)
15+
for colPixel = 1:sizeImg1(2)
16+
if min(...
17+
image1(rowPixel, colPixel, :) == image2(rowPixel, colPixel, :)...
18+
) == 0
19+
20+
resultedImage(rowPixel, colPixel, :) = [255, 255, 255]';
21+
differentPixelCount = differentPixelCount + 1;
22+
end
23+
end
24+
end
25+
end

src/API/DistanceDirectionalFilter.m

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
function filtered_image = DistanceDirectionalFilter(corrupted_image, window_size, BVDFratio, yValueVMF)
2+
image_X = size(corrupted_image, 1);
3+
image_Y = size(corrupted_image, 2);
4+
5+
filtered_image = zeros(size(corrupted_image));
6+
starting_points = [ceil(window_size/2), ceil(window_size/2)];
7+
choosing_distance = [floor(window_size/2), floor(window_size/2)];
8+
9+
for x_index = starting_points(1):(image_X-starting_points(1))
10+
for y_index = starting_points(2):(image_Y-starting_points(2))
11+
12+
area2filter = corrupted_image(x_index-choosing_distance(1):x_index+choosing_distance(2),...
13+
y_index-choosing_distance(2):y_index+choosing_distance(2), :);
14+
area2filter = im2double(area2filter).*255;
15+
vectors_list = reshape(area2filter , [], 3)';
16+
17+
% Sorting Process
18+
% In here, one array of vectors is created. First row will give
19+
% us the distances calculated with VMF, second row will give us
20+
% the angles calculated with BVDF. That's why there is "+2".
21+
calculations = zeros(size(vectors_list, 1) + 3, size(vectors_list, 2));
22+
calculations(4:end, :) = vectors_list;
23+
24+
for index = 1:size(vectors_list, 2)
25+
for jndex = 1:size(vectors_list, 2)
26+
27+
% For each pixel, we are choosing the window-size of
28+
% pixels, and calculate the angles and distances from
29+
% them.
30+
31+
vectA = vectors_list(:, index);
32+
vectB = vectors_list(:, jndex);
33+
34+
if vectA == vectB
35+
continue;
36+
end
37+
38+
% BVDF method for window-sized vectors.
39+
calculations(3, index) = calculations(2, index) + ...
40+
acosd(dot(vectA, vectB) / (norm(vectA) * norm(vectB)));
41+
42+
% VMF method for window-sized vectors with Euclodien distances.
43+
colorRed = (vectA(1) - vectB(1)).^(yValueVMF);
44+
colorGreen = (vectA(2) - vectB(2)).^(yValueVMF);
45+
colorBlue = (vectA(3) - vectB(3)).^(yValueVMF);
46+
VMF_distance = (colorRed + colorGreen + colorBlue).^(1/yValueVMF);
47+
calculations(2, index) = calculations(2, index) + VMF_distance;
48+
49+
end
50+
end
51+
52+
% Combination of VMF and BVDF: Distance Directional Filter
53+
calculations(1, :) = (calculations(3, :).^(BVDFratio)) .* (calculations(2, :).^(1-BVDFratio));
54+
55+
% Sorting the vectors inside the window, with the rules of BVDF
56+
% and VMF.
57+
% [~, VMForder] = sort(calculations(2, :));
58+
% [~, BVDForder] = sort(calculations(3, :));
59+
% VMFSortedVects = calculations(3:end, VMForder);
60+
% BVDFSortedVects = calculations(3:end, BVDForder);
61+
% VMF_Vector = VMFSortedVects(:, 1);
62+
% BVDF_Vector = BVDFSortedVects(:, 1);
63+
[~, DDForder] = sort(calculations(1, :));
64+
DDFSortedVects = calculations(4:end, DDForder);
65+
DDF_Vector = DDFSortedVects(:, 1);
66+
67+
filtered_image(x_index, y_index, :) = DDF_Vector;
68+
69+
end
70+
end
71+
72+
filtered_image = cast(filtered_image, 'uint8');
73+
end

src/API/bvdf_sort_vectors.m renamed to src/API/SortVectorsbyAngle.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [sorted_vectors, sorted_angles] = bvdf_sort_vectors(vectors)
1+
function [sorted_vectors, sorted_angles] = SortVectorsbyAngle(vectors)
22
% BVDF_VECTOR_SORT A function to sort the given n-dimensional vectors.
33
% Parameter vectors has to be a matrix which every column represents a
44
% vector. Function returns a vector, first element is the sorted vectors'

src/API/VMF_BVDF_Present.m

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
function VMF_BVDF_Present(corrupted_image)
2+
vmf_result = VectorMedianFilter(corrupted_image, 3);
3+
bvdf_result = bvdf_filter(corrupted_image, 3);
4+
[diff_img, diff_img_count] = ColorImageDifference(vmf_result, bvdf_result);
5+
hybrid_result = VMF_BVDF_Combine(corrupted_image, 3);
6+
7+
SameRatio = (size(corrupted_image, 1) .* size(corrupted_image, 2) - diff_img_count) ...
8+
/ (size(corrupted_image, 1) .* size(corrupted_image, 2));
9+
sprintf("Sameness Ratio: %d", SameRatio);
10+
11+
tiledlayout(2,3)
12+
nexttile
13+
imshow(corrupted_image)
14+
title("Corrupted Image")
15+
nexttile
16+
imshow(vmf_result)
17+
title("VMF")
18+
nexttile
19+
imshow(bvdf_result)
20+
title("BVDF")
21+
nexttile
22+
imshow(diff_img)
23+
title("Img Diff")
24+
nexttile
25+
imshow(hybrid_result)
26+
title("Hybrid")
27+
28+
29+
end

src/API/VectofilPlus.prj

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<deployment-project plugin="plugin.ezdeploy" plugin-version="1.0">
2+
<configuration file="/media/pop49/Data/Projeler/Dersler/West Pomaranian University of Technology/Computer Vision and Image Processing/Basic Vector Directional Filters/VectofilPlus.prj" location="/media/pop49/Data/Projeler/Dersler/West Pomaranian University of Technology/Computer Vision and Image Processing/Basic Vector Directional Filters" name="VectofilPlus" target="target.ezdeploy.standalone" target-name="Application Compiler">
3+
<param.appname>VectofilPlus</param.appname>
4+
<param.icon />
5+
<param.icons />
6+
<param.version>1.0</param.version>
7+
<param.authnamewatermark>Gökhan Koçmarlı</param.authnamewatermark>
8+
<param.email>gokhankocmarli@gmail.com</param.email>
9+
<param.company>West Pomeranian University of Technology</param.company>
10+
<param.summary>A GUI based application to create noise, and filter color images with Basic Vector Directional Filters.</param.summary>
11+
<param.description />
12+
<param.screenshot />
13+
<param.guid />
14+
<param.installpath.string>/VectofilPlus/</param.installpath.string>
15+
<param.installpath.combo>option.installpath.user</param.installpath.combo>
16+
<param.logo />
17+
<param.install.notes />
18+
<param.target.install.notes>In the following directions, replace MR/v910 by the directory on the target machine where MATLAB is installed, or MR by the directory where the MATLAB Runtime is installed.
19+
20+
(1) Set the environment variable XAPPLRESDIR to this value:
21+
22+
MR/v910/X11/app-defaults
23+
24+
25+
(2) If the environment variable LD_LIBRARY_PATH is undefined, set it to the following:
26+
27+
MR/v910/runtime/glnxa64:MR/v910/bin/glnxa64:MR/v910/sys/os/glnxa64:MR/v910/sys/opengl/lib/glnxa64
28+
29+
If it is defined, set it to the following:
30+
31+
${LD_LIBRARY_PATH}:MR/v910/runtime/glnxa64:MR/v910/bin/glnxa64:MR/v910/sys/os/glnxa64:MR/v910/sys/opengl/lib/glnxa64</param.target.install.notes>
32+
<param.intermediate>${PROJECT_ROOT}/VectofilPlus/for_testing</param.intermediate>
33+
<param.files.only>${PROJECT_ROOT}/VectofilPlus/for_redistribution_files_only</param.files.only>
34+
<param.output>${PROJECT_ROOT}/VectofilPlus/for_redistribution</param.output>
35+
<param.logdir>${PROJECT_ROOT}/VectofilPlus</param.logdir>
36+
<param.enable.clean.build>false</param.enable.clean.build>
37+
<param.user.defined.mcr.options />
38+
<param.target.type>subtarget.standalone</param.target.type>
39+
<param.support.packages />
40+
<param.web.mcr>true</param.web.mcr>
41+
<param.package.mcr>false</param.package.mcr>
42+
<param.no.mcr>false</param.no.mcr>
43+
<param.web.mcr.name>MyAppInstaller_web</param.web.mcr.name>
44+
<param.package.mcr.name>MyAppInstaller_mcr</param.package.mcr.name>
45+
<param.no.mcr.name>MyAppInstaller_app</param.no.mcr.name>
46+
<param.windows.command.prompt>false</param.windows.command.prompt>
47+
<param.create.log>false</param.create.log>
48+
<param.log.file />
49+
<param.native.matlab>false</param.native.matlab>
50+
<param.checkbox>false</param.checkbox>
51+
<param.example />
52+
<param.help.text>Syntax
53+
-?
54+
55+
Input Arguments
56+
-? print help on how to use the application
57+
input arguments</param.help.text>
58+
<unset>
59+
<param.icon />
60+
<param.icons />
61+
<param.version />
62+
<param.description />
63+
<param.screenshot />
64+
<param.guid />
65+
<param.installpath.combo />
66+
<param.logo />
67+
<param.install.notes />
68+
<param.intermediate />
69+
<param.files.only />
70+
<param.output />
71+
<param.logdir />
72+
<param.enable.clean.build />
73+
<param.user.defined.mcr.options />
74+
<param.target.type />
75+
<param.support.packages />
76+
<param.web.mcr />
77+
<param.package.mcr />
78+
<param.no.mcr />
79+
<param.web.mcr.name />
80+
<param.package.mcr.name />
81+
<param.no.mcr.name />
82+
<param.windows.command.prompt />
83+
<param.create.log />
84+
<param.log.file />
85+
<param.native.matlab />
86+
<param.checkbox />
87+
<param.example />
88+
</unset>
89+
<fileset.main>
90+
<file>${PROJECT_ROOT}/GUI/vectofil.mlapp</file>
91+
</fileset.main>
92+
<fileset.resources />
93+
<fileset.package />
94+
<fileset.depfun />
95+
<build-deliverables>
96+
<file location="${PROJECT_ROOT}/VectofilPlus/for_testing" name="run_VectofilPlus.sh" optional="false">/media/pop49/Data/Projeler/Dersler/West Pomaranian University of Technology/Computer Vision and Image Processing/Basic Vector Directional Filters/VectofilPlus/for_testing/run_VectofilPlus.sh</file>
97+
<file location="${PROJECT_ROOT}/VectofilPlus/for_testing" name="VectofilPlus" optional="false">/media/pop49/Data/Projeler/Dersler/West Pomaranian University of Technology/Computer Vision and Image Processing/Basic Vector Directional Filters/VectofilPlus/for_testing/VectofilPlus</file>
98+
<file location="${PROJECT_ROOT}/VectofilPlus/for_testing" name="splash.png" optional="false">/media/pop49/Data/Projeler/Dersler/West Pomaranian University of Technology/Computer Vision and Image Processing/Basic Vector Directional Filters/VectofilPlus/for_testing/splash.png</file>
99+
<file location="${PROJECT_ROOT}/VectofilPlus/for_testing" name="readme.txt" optional="true">/media/pop49/Data/Projeler/Dersler/West Pomaranian University of Technology/Computer Vision and Image Processing/Basic Vector Directional Filters/VectofilPlus/for_testing/readme.txt</file>
100+
</build-deliverables>
101+
<workflow />
102+
<matlab>
103+
<root>/media/pop49/LinuxApps/MATLABR2021A</root>
104+
<toolboxes>
105+
<toolbox name="matlabcoder" />
106+
<toolbox name="embeddedcoder" />
107+
</toolboxes>
108+
<toolbox>
109+
<matlabcoder>
110+
<enabled>true</enabled>
111+
</matlabcoder>
112+
</toolbox>
113+
<toolbox>
114+
<embeddedcoder>
115+
<enabled>true</enabled>
116+
</embeddedcoder>
117+
</toolbox>
118+
</matlab>
119+
<platform>
120+
<unix>true</unix>
121+
<mac>false</mac>
122+
<windows>false</windows>
123+
<win2k>false</win2k>
124+
<winxp>false</winxp>
125+
<vista>false</vista>
126+
<linux>true</linux>
127+
<solaris>false</solaris>
128+
<osver>5.11.0-7620-generic</osver>
129+
<os32>false</os32>
130+
<os64>true</os64>
131+
<arch>glnxa64</arch>
132+
<matlab>true</matlab>
133+
</platform>
134+
</configuration>
135+
</deployment-project>

0 commit comments

Comments
 (0)