-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBrightness.m
30 lines (26 loc) · 795 Bytes
/
Brightness.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
function [BrightImage] = Brightness(image ,operand, offset)
[row , col, depth] = size(image);
BrightImage = zeros(row,col,depth);
BrightImage = im2double(BrightImage);
if operand == '+'
BrightImage = image + offset;
elseif operand == '-'
BrightImage = image - offset;
elseif operand == '*'
BrightImage = image * offset;
elseif operand == '/'
BrightImage = image / offset;
end
for r = 1:row
for c = 1:col
for dep =1:depth
if BrightImage(r, c, dep) > 255
BrightImage(r, c, dep) = 255;
elseif BrightImage(r, c, dep) < 0
BrightImage(r, c, dep) = 0;
end
end
end
end
BrightImage = im2uint8(BrightImage);
end