Line | |
---|
1 | % generate a simple dataset for the cell images |
---|
2 | %clear all; load cells_gabor; |
---|
3 | function [a,b] = gencellsimple(x,z,dtype) |
---|
4 | |
---|
5 | if nargin<3 |
---|
6 | dtype = 'max'; |
---|
7 | end |
---|
8 | |
---|
9 | N = size(x,1); |
---|
10 | if ndims(x{1,1})<3 |
---|
11 | dim = size(x{1,1},2); |
---|
12 | else |
---|
13 | dim = size(x{1,1},3); |
---|
14 | end |
---|
15 | feat = zeros(N,dim); |
---|
16 | imlab = zeros(N,1); |
---|
17 | for i=1:N |
---|
18 | i |
---|
19 | if strcmp(dtype,'nothing') |
---|
20 | feat(i,:) = x{i,:}; |
---|
21 | else |
---|
22 | for j=1:dim |
---|
23 | gim = x{i,1}(:,:,j); |
---|
24 | gim = gim(find(x{i,2})); |
---|
25 | switch dtype |
---|
26 | case 'max' |
---|
27 | feat(i,j) = max(gim); |
---|
28 | case 'mean' |
---|
29 | feat(i,j) = mean(abs(gim)); |
---|
30 | case 'var' |
---|
31 | feat(i,j) = var(gim); |
---|
32 | end |
---|
33 | end |
---|
34 | end |
---|
35 | xlab(i,:) = x{i,4}; |
---|
36 | imlab(i,1) = x{i,3}; |
---|
37 | end |
---|
38 | a = dataset(feat,xlab); |
---|
39 | a = setident(a,imlab,'image'); |
---|
40 | M = size(z,1); |
---|
41 | feat = zeros(M,dim); |
---|
42 | imlab = zeros(M,1); |
---|
43 | for i=1:M |
---|
44 | i |
---|
45 | if strcmp(dtype,'nothing') |
---|
46 | feat(i,:) = z{i,:}; |
---|
47 | else |
---|
48 | for j=1:dim |
---|
49 | gim = z{i,1}(:,:,j); |
---|
50 | gim = gim(find(z{i,2})); |
---|
51 | switch dtype |
---|
52 | case 'max' |
---|
53 | feat(i,j) = max(gim); |
---|
54 | case 'mean' |
---|
55 | feat(i,j) = mean(abs(gim)); |
---|
56 | case 'var' |
---|
57 | feat(i,j) = var(gim); |
---|
58 | end |
---|
59 | end |
---|
60 | end |
---|
61 | zlab(i,:) = z{i,4}; |
---|
62 | imlab(i,1) = z{i,3}; |
---|
63 | end |
---|
64 | b = dataset(feat,zlab); |
---|
65 | b = setident(b,imlab,'image'); |
---|
66 | |
---|
67 | %switch dtype |
---|
68 | %case 'max' |
---|
69 | % save cellssimplemax a b; |
---|
70 | %case 'mean' |
---|
71 | % save cellssimplemean a b; |
---|
72 | %case 'var' |
---|
73 | % save cellssimplevar a b; |
---|
74 | %end |
---|
Note: See
TracBrowser
for help on using the repository browser.