Skip to content

Commit d81aa70

Browse files
committed
Initial code commit
0 parents  commit d81aa70

File tree

190 files changed

+15796
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+15796
-0
lines changed

Diff for: Contents.asv

+155
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2+
% Contents in G.Sfikas library ('sfikasLibrary') %
3+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4+
%
5+
% Update I: 24 Feb 2009
6+
% Last update : 20 Jul 2009
7+
%
8+
% Not included in this list:
9+
% /edgemap (Martin)
10+
% /edgemap/superpixels (Yi Ma)
11+
% /lightspeed (Minka)
12+
% /AnalyzeToolbox (Medical imaging toolbox)
13+
% /mixtureLearning/n
14+
15+
% =========================================================================
16+
% / General functions
17+
% =========================================================================
18+
%
19+
% buildRetrievalIndex Creates a list of all files of a given
20+
% extension contained on a given folder
21+
% (including its subfolders).
22+
% deterministicKmeans A set of centroids is returned for the
23+
% given dataset, found using k-means. The
24+
% initialization depends on the data, hence
25+
% the name 'deterministic'.
26+
% multistartKmeans Use several random initializations for
27+
% k-means.
28+
% gaussianValue Computes the value of a normal distribution
29+
% for a given datum or set of data.
30+
% studentValue Computes the value of a Student-t
31+
% distribution for a given datum of set of
32+
% data.
33+
% logGaussianValue Compute the log of "gaussianValue" (more
34+
% stable)
35+
% logStudentValue Compute the log of "studentValue" (more
36+
% stable)
37+
% mahalanobis Compute the mahalanobis norm for a set of
38+
% vectors. i.e X'*inv(A)*X (note the inv on
39+
% the A)
40+
% squaredist Compute X'A*X, like 'mahanalobis'.
41+
% makeMovie Show the contents of a 3d image (eg, an
42+
% MRI) as an AVI movie file.
43+
% model2image & seg2image Change the extension and path of a given file.
44+
% lab2rgb & rgb2lab Convert (X,Y,3) matrices from lab to rgb
45+
% and from rgb to lab.
46+
% xrgb2lab An old version of rgb2lab. May be required
47+
% by some old code.
48+
% randGmm Samples from a GMM.
49+
% imnoiseSNR Add noise to given signal.
50+
% Noise strengh is entered either
51+
% in decibels or noise variance.
52+
% medoid Compute medoid out of set of vectors.
53+
% imRAG Compute adjacency graph for a K-class
54+
% image.
55+
%
56+
% =========================================================================
57+
% /matrixManipulation
58+
% =========================================================================
59+
%
60+
% convertJxN Converts a (X,Y,J)-sized to a (J,X*Y)
61+
% matrix. Useful if you want to pass data to
62+
% some training algorithm.
63+
% convolution2D Convolutes a (X,Y)-sized matrix with a 2d
64+
% kernel.
65+
% maxVote Use a maximum-vote 3x3 filter on input
66+
% segmentation.
67+
% smoothUsingVariantScale Smooth an image using gaussian kernels of
68+
% spatially variant scale.
69+
% translation Translate (move) a 2d matrix by a given
70+
% offset.
71+
%
72+
% =========================================================================
73+
% /mixtureLearning
74+
% =========================================================================
75+
%
76+
% gaussianMixEmFit Learn a Gaussian MM.
77+
% studentMixEmFit Learn a Student-t MM.
78+
% gaussianMixGreedyEmFit Learn a Gaussian MM using Greedy EM.
79+
% studentMixGreedyEmFit Learn a Student-t MM using Greedy EM.
80+
% VARIATIONAL/ Variation methodology applications
81+
% gaussianMixBayesian Learn a Gaussian MM with priors.
82+
% studentMixBayesian Learn a Student-t MM with priors on all
83+
% parameters except for the degrees of
84+
% freedom.
85+
% studentMixBayesianXP Learn a Student-t MM with priors on all
86+
% parameters except for the degrees of
87+
% freedom _and_ the weights.
88+
% MARKOV/
89+
% gaussianMixBayesianContinuousLp
90+
% Learn a model with continuous line process.
91+
% (CVPR08 proposal)
92+
% gaussianMixBayesianLp Learn a model with discrete line process.
93+
% (MICCAI08 proposal)
94+
% gaussianMixDCASV Learn a model with class- and directional-
95+
% adaptive priors (Nikou07 TIP paper)
96+
%
97+
% NOMBRE/
98+
% gaussianMixNombre
99+
% Learn a model which uses a spatial MRF
100+
% and can find the number of classes
101+
% automatically
102+
% gaussianMixNombre2 Same as "gaussianMixNombre" - but without
103+
% automatic number of classes selection
104+
% (ie almost like "gaussianMixContinuousLp")
105+
% gaussianMixNombre3 Same as "gaussianMixNombre" - but without
106+
% an MRF incorporated
107+
% (ie almost like "gaussianMixBayesian")
108+
% =========================================================================
109+
% /pdfDistances
110+
% =========================================================================
111+
%
112+
% bhgmmDistance Bhatacharryya-based distance for GMMs.
113+
% emdDistance Earth movers distance.
114+
% kullbackDistance Symmetric kullback-liebler distance.
115+
% l2Distance L2 distance for GMMs. [Sfikas04]
116+
% mahalanobisDistance Quadratic distance for blobworld region
117+
% descriptors.
118+
%
119+
% =========================================================================
120+
% /segmentation
121+
% =========================================================================
122+
%
123+
% buildSegmentation Builds a segmentation for given 2D image,
124+
% using a variety of methods.
125+
% BoundaryDetectionError
126+
% GlobalConsistencyError
127+
% probabilisticRandIndex
128+
% RandIndex Fast version of 'probabilisticRandIndex'.
129+
% VariationOfInformation
130+
%
131+
% =========================================================================
132+
% /texture
133+
% =========================================================================
134+
%
135+
% MRF_texture_features Compute MRF texture feature vectors,
136+
% by default 8-variate.
137+
% computeBlobworldFeatureVectors Compute Blobworld feature vectors,
138+
% ie smooth Lab, Pol-Ani-Con
139+
% and x-y. (8-variate).
140+
%
141+
% =========================================================================
142+
% /mexRoutines
143+
% =========================================================================
144+
%
145+
% BIDProjection Project input vector 'x' onto space
146+
% sum(x) = 1 && x > 0.
147+
% Currently uses method presented in
148+
% Sfikas et al [MLSP workshop 09]
149+
% Formerly the one in
150+
% Blekas et al [TIP 05]
151+
% xConjugateProjection Deprecated. A failed attempt for
152+
% a better projection, for the same
153+
% problem treated by BIDProjection.
154+
155+

Diff for: Contents.m

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2+
% Contents in G.Sfikas library ('sfikasLibrary') %
3+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4+
%
5+
% Update I: 24 Feb 2009
6+
% Last update : 20 Jul 2009
7+
%
8+
% Not included in this list:
9+
% /edgemap (Martin)
10+
% /edgemap/superpixels (Yi Ma)
11+
% /lightspeed (Minka)
12+
% /AnalyzeToolbox (Medical imaging toolbox)
13+
% /mixtureLearning/nombre (Ipse, u.c.)
14+
%
15+
%
16+
% =========================================================================
17+
% / General functions
18+
% =========================================================================
19+
%
20+
% buildRetrievalIndex Creates a list of all files of a given
21+
% extension contained on a given folder
22+
% (including its subfolders).
23+
% deterministicKmeans A set of centroids is returned for the
24+
% given dataset, found using k-means. The
25+
% initialization depends on the data, hence
26+
% the name 'deterministic'.
27+
% multistartKmeans Use several random initializations for
28+
% k-means.
29+
% gaussianValue Computes the value of a normal distribution
30+
% for a given datum or set of data.
31+
% studentValue Computes the value of a Student-t
32+
% distribution for a given datum of set of
33+
% data.
34+
% logGaussianValue Compute the log of "gaussianValue" (more
35+
% stable)
36+
% logStudentValue Compute the log of "studentValue" (more
37+
% stable)
38+
% mahalanobis Compute the mahalanobis norm for a set of
39+
% vectors. i.e X'*inv(A)*X (note the inv on
40+
% the A)
41+
% squaredist Compute X'A*X, like 'mahanalobis'.
42+
% makeMovie Show the contents of a 3d image (eg, an
43+
% MRI) as an AVI movie file.
44+
% model2image & seg2image Change the extension and path of a given file.
45+
% lab2rgb & rgb2lab Convert (X,Y,3) matrices from lab to rgb
46+
% and from rgb to lab.
47+
% xrgb2lab An old version of rgb2lab. May be required
48+
% by some old code.
49+
% randGmm Samples from a GMM.
50+
% imnoiseSNR Add noise to given signal.
51+
% Noise strengh is entered either
52+
% in decibels or noise variance.
53+
% medoid Compute medoid out of set of vectors.
54+
% imRAG Compute adjacency graph for a K-class
55+
% image.
56+
%
57+
% =========================================================================
58+
% /matrixManipulation
59+
% =========================================================================
60+
%
61+
% convertJxN Converts a (X,Y,J)-sized to a (J,X*Y)
62+
% matrix. Useful if you want to pass data to
63+
% some training algorithm.
64+
% convolution2D Convolutes a (X,Y)-sized matrix with a 2d
65+
% kernel.
66+
% maxVote Use a maximum-vote 3x3 filter on input
67+
% segmentation.
68+
% smoothUsingVariantScale Smooth an image using gaussian kernels of
69+
% spatially variant scale.
70+
% translation Translate (move) a 2d matrix by a given
71+
% offset.
72+
%
73+
% =========================================================================
74+
% /mixtureLearning
75+
% =========================================================================
76+
%
77+
% gaussianMixEmFit Learn a Gaussian MM.
78+
% studentMixEmFit Learn a Student-t MM.
79+
% gaussianMixGreedyEmFit Learn a Gaussian MM using Greedy EM.
80+
% studentMixGreedyEmFit Learn a Student-t MM using Greedy EM.
81+
% VARIATIONAL/ Variation methodology applications
82+
% gaussianMixBayesian Learn a Gaussian MM with priors.
83+
% studentMixBayesian Learn a Student-t MM with priors on all
84+
% parameters except for the degrees of
85+
% freedom.
86+
% studentMixBayesianXP Learn a Student-t MM with priors on all
87+
% parameters except for the degrees of
88+
% freedom _and_ the weights.
89+
% MARKOV/
90+
% gaussianMixBayesianContinuousLp
91+
% Learn a model with continuous line process.
92+
% (CVPR08 proposal)
93+
% gaussianMixBayesianLp Learn a model with discrete line process.
94+
% (MICCAI08 proposal)
95+
% gaussianMixDCASV Learn a model with class- and directional-
96+
% adaptive priors (Nikou07 TIP paper)
97+
%
98+
% NOMBRE/
99+
% gaussianMixNombre
100+
% Learn a model which uses a spatial MRF
101+
% and can find the number of classes
102+
% automatically
103+
% gaussianMixNombre2 Same as "gaussianMixNombre" - but without
104+
% automatic number of classes selection
105+
% (ie almost like "gaussianMixContinuousLp")
106+
% gaussianMixNombre3 Same as "gaussianMixNombre" - but without
107+
% an MRF incorporated
108+
% (ie almost like "gaussianMixBayesian")
109+
% =========================================================================
110+
% /pdfDistances
111+
% =========================================================================
112+
%
113+
% bhgmmDistance Bhatacharryya-based distance for GMMs.
114+
% emdDistance Earth movers distance.
115+
% kullbackDistance Symmetric kullback-liebler distance.
116+
% l2Distance L2 distance for GMMs. [Sfikas04]
117+
% mahalanobisDistance Quadratic distance for blobworld region
118+
% descriptors.
119+
%
120+
% =========================================================================
121+
% /segmentation
122+
% =========================================================================
123+
%
124+
% buildSegmentation Builds a segmentation for given 2D image,
125+
% using a variety of methods.
126+
% BoundaryDetectionError
127+
% GlobalConsistencyError
128+
% probabilisticRandIndex
129+
% RandIndex Fast version of 'probabilisticRandIndex'.
130+
% VariationOfInformation
131+
%
132+
% =========================================================================
133+
% /texture
134+
% =========================================================================
135+
%
136+
% MRF_texture_features Compute MRF texture feature vectors,
137+
% by default 8-variate.
138+
% computeBlobworldFeatureVectors Compute Blobworld feature vectors,
139+
% ie smooth Lab, Pol-Ani-Con
140+
% and x-y. (8-variate).
141+
%
142+
% =========================================================================
143+
% /mexRoutines
144+
% =========================================================================
145+
%
146+
% BIDProjection Project input vector 'x' onto space
147+
% sum(x) = 1 && x > 0.
148+
% Currently uses method presented in
149+
% Sfikas et al [MLSP workshop 09]
150+
% Formerly the one in
151+
% Blekas et al [TIP 05]
152+
% xConjugateProjection Deprecated. A failed attempt for
153+
% a better projection, for the same
154+
% problem treated by BIDProjection.
155+
%
156+
%

Diff for: README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
== sfikasLibrary ==
2+
3+
= Useful files =
4+
5+
* Contents.m -------- Package summary
6+
* buildSegmentation.m -------- Builds a segmentation on a given image. Numerous clustering/segmentation methods are supported.
7+
* gaussianMixBayesian.m -------- Train a GMM w/ Gaussian-Wishart priors using Variational EM.
8+
* gaussianMixBayesianContinuousLp.m -------- Train a GMM w/ the model presented in Sfikas et al. "Edge-preserving spatially-varying mixtures for image segmentation" [CVPR 2008] and the corresponding model in Sfikas et al. "Spatially varying mixtures incorporating line processes for image segmentation" [JMIV 2010].
9+
* buildSegmentation.m
10+
11+
= Requirements =
12+
13+
Tom Minka's lightspeed package: http://research.microsoft.com/en-us/um/people/minka/software/lightspeed/

Diff for: blobworld/NOTE.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"ComputeBlobworldFeatureVectors" has been moved to folder /texture .

Diff for: blobworld/buildBlobDescriptor.m

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
function res = buildBlobDescriptor(labColor, contrast, anisotropy, means, vars);
2+
% Build a blob descriptor as described in blobworld paper.
3+
%
4+
% Example:
5+
% buildBlobDescriptor(labColor, contrast, anisotropy).
6+
%
7+
% -------------------------------------------------------------------------
8+
% labColor: 3xN matrix, w/ each row containing L*a*b* values for
9+
% a single pixel.
10+
% contrast: 1xN or Nx1 vector containing contrast values.
11+
% anisotropy: 1xN or Nx1 vector containing anisotropy values.
12+
% Returns: A 502x1 vector (the descriptor).
13+
% -------------------------------------------------------------------------
14+
%
15+
% See also
16+
%
17+
% G.Sfikas 13/11/06
18+
%
19+
% UPDATE HISTORY:
20+
% ---------------
21+
% 13-11-06 Symmazema
22+
% 22-11-06 Allages gia normalization
23+
24+
if isempty(labColor)
25+
res = zeros(1,502);
26+
return;
27+
end
28+
res = hist(findProperBin(labColor), 0:499);
29+
res = res / (sum(res));
30+
% Normalization
31+
contrastMean = means(6);
32+
contrastVar = vars(6);
33+
caMean = means(9);
34+
caVar = vars(9);
35+
temp1 = (contrast - contrastMean) / contrastVar;
36+
res(501) = mean(temp1);
37+
temp = contrast .* anisotropy;
38+
temp = (temp - caMean) / caVar;
39+
res(502) = mean(temp);
40+
return;

0 commit comments

Comments
 (0)