-
Notifications
You must be signed in to change notification settings - Fork 0
/
unsharpmasking.m
30 lines (26 loc) · 927 Bytes
/
unsharpmasking.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
img = (imread('/home/anonymous/jupyter notebooks/python/test/107.jpg'));
R = img(:,:,1);
[r,c] = size(R);
G = img(:,:,2);
B = img(:,:,3);
hsv_image = rgb2hsv(img);
intensity_plane = hsv_image(:,:,3);
intensity_plane = rescale(intensity_plane,0,0.8);
figure , imshow(intensity_plane) , title("rescaling")
% log_transformation
intensity_plane = 1.5 * log (1 + intensity_plane);
figure , imshow(intensity_plane) , title("log transform")
filter = ones(7,7)/49;
blurred = imfilter(intensity_plane,filter);
edges = intensity_plane - blurred;
sharpened = intensity_plane + edges;
figure , imshow(sharpened) , title('sharpened')
new_img = zeros(r,c,3);
new_img(:,:,1) = hsv_image(:,:,1);
new_img(:,:,2) = hsv_image(:,:,2);
new_img(:,:,3) = sharpened ;
figure , imshow(new_img);
newrgb = hsv2rgb(new_img);
figure , imshow(newrgb);
imwrite(newrgb,'/home/anonymous/jupyter notebooks/python/test/fixednew.jpg')
% imshow(sharpened);