-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmax_mixed_value.m
executable file
·43 lines (35 loc) · 1.03 KB
/
max_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
43
function [ max_value, max_row, max_col ] = max_mixed_value( mixed_image, se, row, col, include_center)
%Funkcja zwraca wartość oraz indeksy maksimum 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
max_value = mixed_image(row, col);
max_row = row;
max_col = col;
else
max_value = -1;
max_row = -1;
max_col = -1;
end
%Funkcja iteruje po całym otoczeniu piksela, aby znaleźć maksimum
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) > max_value)
max_value = mixed_image(se_i, se_j);
max_row = se_i;
max_col = se_j;
end
end
if max_value == -1
max_value = mixed_image(row, col);
max_row = row;
max_col = col;
end
end