|
a |
|
b/combinedDeepLearningActiveContour/dim_reduction.m |
|
|
1 |
% dimension reduction using PCA |
|
|
2 |
clc |
|
|
3 |
clear all |
|
|
4 |
close all |
|
|
5 |
addpath('functions') |
|
|
6 |
%% |
|
|
7 |
load matFiles/training_data; |
|
|
8 |
|
|
|
9 |
% total images |
|
|
10 |
I=t_Iroi; |
|
|
11 |
[x,y,z]=size(I); |
|
|
12 |
I1=reshape(I,x*y,z); |
|
|
13 |
|
|
|
14 |
% apply PCA |
|
|
15 |
N=size(I1,1); |
|
|
16 |
C=I1*I1'/N; |
|
|
17 |
[U,S,V]=svd(C); |
|
|
18 |
|
|
|
19 |
% reduce dimension |
|
|
20 |
n=90; |
|
|
21 |
I2=I1'*U(:,1:n); |
|
|
22 |
|
|
|
23 |
%save pca_results |
|
|
24 |
%% recover |
|
|
25 |
I3=I2*U(:,1:n)'; |
|
|
26 |
I4=I3'; |
|
|
27 |
I5=reshape(I4,x,y,z); |
|
|
28 |
imagesc(I5(:,:,1));colormap(gray) |
|
|
29 |
|
|
|
30 |
% total ROI |
|
|
31 |
B=t_yROI; |
|
|
32 |
[x,y,z]=size(B); |
|
|
33 |
B1=reshape(B,x*y,z); |
|
|
34 |
|
|
|
35 |
p2=pca(B1'); |
|
|
36 |
B2=B1'*p2; |
|
|
37 |
|
|
|
38 |
% recover |
|
|
39 |
B3=B2*p2'; |
|
|
40 |
B4=B3'; |
|
|
41 |
B5=reshape(B4,x,y,z); |
|
|
42 |
figure |
|
|
43 |
imagesc(B5(:,:,2));colormap(gray) |
|
|
44 |
imagesc(B(:,:,2));colormap(gray) |
|
|
45 |
Br=imresize(B(:,:,2),40/256); |
|
|
46 |
Brr=imresize(Br,256/40); |
|
|
47 |
Brr=round(Brr); |
|
|
48 |
imagesc(Brr);colormap(gray) |
|
|
49 |
|
|
|
50 |
|