-
Notifications
You must be signed in to change notification settings - Fork 3
/
code.m
60 lines (41 loc) · 1.3 KB
/
code.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
clear all
Irmi = im2double(imread('070_mri.bmp'));
MRI = rgb2gray(Irmi);
RGB = im2double(imread('070_pet.bmp'));
R = RGB(:,:,1);
G = RGB(:,:,2);
B = RGB(:,:,3);
I = (R+G+B)/3;
DanhGiaAnh(I)
V1 = (-sqrt(2)*R -sqrt(2)*G + 2*sqrt(2)*B)/6;
V2 = (R-G)/sqrt(2);
H = atan(V1./(V2+eps));
S = sqrt(V1.^2 + V2.^2);
% Bien doi dwt cua 2 anh Imri va I
[LLmri, LHmri, HLmri, HHmri] = dwt2(MRI,'haar');
[LL, LH, HL, HH] = dwt2(I,'haar');
% Tong hop
LLth = (LLmri + LL)/2;
LHth = max(LHmri, LH);
HLth = max(HLmri, HL);
HHth = max(HHmri, HH);
% Bien doi nguoc Haar
%Ith = idwt2(LLth, LH, HL, HH,'haar');
Ith = idwt2(LLth, LHth, HLth, HHth,'haar');
%v1 = DanhGiaAnh(I_th);
% Thu duoc cac gia tri alpha, beta, gama sau toi uu
x = ToiUuPSO(I, 100); %n
% Goi ham tang cuong voi bo alpha, beta, gama toi uu tim duoc
I_en = Enhance(Ith,x);
% Thuc hien lay chi so danh gia cua anh sau tang cuong
v2 = DanhGiaAnh(I_en);
% Buoc 4: Lay kenh I_en sau khi tang cuong cung voi cac kenh H, S de chuyen
% nguoc lai mien RGB
%HSI = cat(3, H, S, I_en);
%f = im2uint8(hsi2rgb(HSI));
%----------------------------------------------------
R1 = I_en - V1/sqrt(2) + V2/sqrt(2);
G1 = I_en - V1/sqrt(2) - V2/sqrt(2);
B1 = I_en + sqrt(2)*V1;
I1 = cat(3,R1,G1,B1);
imshow([RGB,Irmi, I1],[])