-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmin_mixed_value.m
executable file
·42 lines (35 loc) · 1.04 KB
/
min_mixed_value.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
function [ min_value, min_row, min_col ] = min_mixed_value( mixed_image, se, row, col, include_center)
%Funkcja zwraca wartość oraz indeksy minimum spośród otoczenia piksela o
%indeksach (row, cols), otoczenie jest określone przez argument se.
if nargin == 4
include_center = True;
end
siz = size(mixed_image);
rows = siz(1);
cols = siz(2);
if include_center == true
min_value = mixed_image(row, col);
min_row = row;
min_col = col;
else
min_value = 777777777;
min_row = -1;
min_col = -1;
end
%Funkcja iteruje po całym otoczeniu piksela, aby znaleźć minimum
for i=1:size(se, 1)
se_i = row + se(i, 1);
se_j = col + se(i, 2);
%Sprawdzanie czy dany punkt otoczenia jest w granicach obrazu
if (se_i >= 1 && se_i <= rows) && (se_j >= 1 && se_j <= cols) && (mixed_image(se_i, se_j) < min_value)
min_value = mixed_image(se_i, se_j);
min_row = se_i;
min_col = se_j;
end
end
if min_value == 777777777
min_value = mixed_image(row, col);
min_row = row;
min_col = col;
end
end