Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.boosting
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.learn.boosting
Commits
55e29afc
Commit
55e29afc
authored
11 years ago
by
Rakesh MEHTA
Browse files
Options
Downloads
Patches
Plain Diff
Variable name change
parent
3f17cb4d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xbob/boosting/features/local_feature.py
+30
-30
30 additions, 30 deletions
xbob/boosting/features/local_feature.py
with
30 additions
and
30 deletions
xbob/boosting/features/local_feature.py
+
30
−
30
View file @
55e29afc
...
...
@@ -83,13 +83,13 @@ class lbp_feature():
# extract the specific feature from the image
if
self
.
ftype
==
'
lbp
'
:
feature_map
=
self
.
lbp
(
coord
,
fmap_dimx
,
fmap_dimy
,
block_sum
)
feature_map
=
self
.
lbp
(
coord
,
f
eature_
map_dimx
,
f
eature_
map_dimy
,
block_sum
)
elif
self
.
ftype
==
'
tlbp
'
:
feature_map
=
self
.
tlbp
(
coord
,
fmap_dimx
,
fmap_dimy
,
block_sum
)
feature_map
=
self
.
tlbp
(
coord
,
f
eature_
map_dimx
,
f
eature_
map_dimy
,
block_sum
)
elif
self
.
ftype
==
'
dlbp
'
:
feature_map
=
self
.
dlbp
(
coord
,
fmap_dimx
,
fmap_dimy
,
block_sum
)
feature_map
=
self
.
dlbp
(
coord
,
f
eature_
map_dimx
,
f
eature_
map_dimy
,
block_sum
)
elif
self
.
ftype
==
'
mlbp
'
:
feature_map
=
self
.
mlbp
(
coord
,
fmap_dimx
,
fmap_dimy
,
block_sum
)
feature_map
=
self
.
mlbp
(
coord
,
f
eature_
map_dimx
,
f
eature_
map_dimy
,
block_sum
)
# reshape feature image into vector
temp_vector
=
numpy
.
reshape
(
feature_map
,
feature_map
.
shape
[
0
]
*
fmap
.
shape
[
1
],
1
)
...
...
@@ -100,79 +100,79 @@ class lbp_feature():
def
lbp
(
self
,
coord
,
fmap_dimx
,
fmap_dimy
,
block_sum
):
def
lbp
(
self
,
coord
,
f
eature_
map_dimx
,
f
eature_
map_dimy
,
block_sum
):
"""
Function to compute the LBP for a image at single scale.
The LBP features of the given image is computed and the feature map is returned
Inputs:
coord: The coordinates specify the neighbour to be considered.
fmap_dimx: feature map
'
s dimension along the columns.
fmap_dimy: Feature maps dimension along the rows.
f
eature_
map_dimx: feature map
'
s dimension along the columns.
f
eature_
map_dimy: Feature maps dimension along the rows.
Return:
feature_map: The lbp feature map
"""
num_neighbours
=
8
blk_center
=
block_sum
[
1
:
1
+
fmap_dimy
,
1
:
1
+
fmap_dimx
]
feature_map
=
numpy
.
zeros
([
fmap_dimy
,
fmap_dimx
])
blk_center
=
block_sum
[
1
:
1
+
f
eature_
map_dimy
,
1
:
1
+
f
eature_
map_dimx
]
feature_map
=
numpy
.
zeros
([
f
eature_
map_dimy
,
f
eature_
map_dimx
])
for
ind
in
range
(
num_neighbours
):
feature_map
=
feature_map
+
(
2
**
ind
)
*
(
block_sum
[
coord
[
ind
][
0
]:
coord
[
ind
][
0
]
+
fmap_dimy
,
coord
[
ind
][
1
]:
coord
[
ind
][
1
]
+
fmap_dimx
]
>=
blk_center
)
feature_map
=
feature_map
+
(
2
**
ind
)
*
(
block_sum
[
coord
[
ind
][
0
]:
coord
[
ind
][
0
]
+
f
eature_
map_dimy
,
coord
[
ind
][
1
]:
coord
[
ind
][
1
]
+
f
eature_
map_dimx
]
>=
blk_center
)
return
feature_map
def
tlbp
(
self
,
coord
,
fmap_dimx
,
fmap_dimy
,
block_sum
):
def
tlbp
(
self
,
coord
,
f
eature_
map_dimx
,
f
eature_
map_dimy
,
block_sum
):
"""
Function to compute the tLBP for a image at single scale.
The tLBP features of the given image is computed and the feature map is returned
Inputs:
coord: The coordinates specify the neighbour to be considered.
fmap_dimx: feature map
'
s dimension along the columns.
fmap_dimy: Feature maps dimension along the rows.
f
eature_
map_dimx: feature map
'
s dimension along the columns.
f
eature_
map_dimy: Feature maps dimension along the rows.
Return:
feature_map: The lbp feature map
"""
feature_map
=
numpy
.
zeros
([
fmap_dimy
,
fmap_dimx
])
feature_map
=
numpy
.
zeros
([
f
eature_
map_dimy
,
f
eature_
map_dimx
])
num_neighbour
=
8
"""
Compute the feature map for the tLBP features.
"""
for
ind
in
range
(
num_neighbours
):
"""
The comparison of pixel is done with the adjacent neighbours.
"""
comparing_img
=
block_sum
[
coord
[(
ind
+
1
)
%
num_neighbour
][
0
]:
coord
[(
ind
+
1
)
%
num_neighbour
][
0
]
+
fmap_dimy
,
coord
[(
ind
+
1
)
%
num_neighbour
][
1
]:
coord
[(
ind
+
1
)
%
num_neighbour
][
1
]
+
fmap_dimx
]
comparing_img
=
block_sum
[
coord
[(
ind
+
1
)
%
num_neighbour
][
0
]:
coord
[(
ind
+
1
)
%
num_neighbour
][
0
]
+
f
eature_
map_dimy
,
coord
[(
ind
+
1
)
%
num_neighbour
][
1
]:
coord
[(
ind
+
1
)
%
num_neighbour
][
1
]
+
f
eature_
map_dimx
]
"""
Compare the neighbours and increment the feature map.
"""
feature_map
=
feature_map
+
(
2
**
ind
)
*
(
block_sum
[
coord
[
ind
][
0
]:
coord
[
ind
][
0
]
+
fmap_dimy
,
coord
[
ind
][
1
]:
coord
[
ind
][
1
]
+
fmap_dimx
]
>=
comparing_img
)
feature_map
=
feature_map
+
(
2
**
ind
)
*
(
block_sum
[
coord
[
ind
][
0
]:
coord
[
ind
][
0
]
+
f
eature_
map_dimy
,
coord
[
ind
][
1
]:
coord
[
ind
][
1
]
+
f
eature_
map_dimx
]
>=
comparing_img
)
return
feature_map
def
dlbp
(
self
,
coord
,
fmap_dimx
,
fmap_dimy
,
block_sum
):
def
dlbp
(
self
,
coord
,
f
eature_
map_dimx
,
f
eature_
map_dimy
,
block_sum
):
"""
Function to compute the dLBP for a image at single scale.
The dLBP features of the given image is computed and the feature map is returned
Inputs:
coord: The coordinates specify the neighbour to be considered.
fmap_dimx: feature map
'
s dimension along the columns.
fmap_dimy: Feature maps dimension along the rows.
f
eature_
map_dimx: feature map
'
s dimension along the columns.
f
eature_
map_dimy: Feature maps dimension along the rows.
Return:
feature_map: The lbp feature map
"""
pc
=
block_sum
[
1
:
1
+
fmap_dimy
,
1
:
1
+
fmap_dimx
]
pc
=
block_sum
[
1
:
1
+
f
eature_
map_dimy
,
1
:
1
+
f
eature_
map_dimx
]
num_neighbours
=
8
fmap
=
numpy
.
zeros
([
fmap_dimy
,
fmap_dimx
])
fmap
=
numpy
.
zeros
([
f
eature_
map_dimy
,
f
eature_
map_dimx
])
for
ind
in
range
(
num_neighbours
/
2
):
"""
The comparison of pixel is done with the diagonal neighbours.
"""
pi
=
block_sum
[
coord
[
ind
][
0
]:
coord
[
ind
][
0
]
+
fmap_dimy
,
coord
[
ind
][
1
]:
coord
[
ind
][
1
]
+
fmap_dimx
]
pi4
=
block_sum
[
coord
[
ind
+
4
][
0
]:
coord
[
ind
+
4
][
0
]
+
fmap_dimy
,
coord
[
ind
+
4
][
1
]:
coord
[
ind
+
4
][
1
]
+
fmap_dimx
]
pi
=
block_sum
[
coord
[
ind
][
0
]:
coord
[
ind
][
0
]
+
f
eature_
map_dimy
,
coord
[
ind
][
1
]:
coord
[
ind
][
1
]
+
f
eature_
map_dimx
]
pi4
=
block_sum
[
coord
[
ind
+
4
][
0
]:
coord
[
ind
+
4
][
0
]
+
f
eature_
map_dimy
,
coord
[
ind
+
4
][
1
]:
coord
[
ind
+
4
][
1
]
+
f
eature_
map_dimx
]
"""
Compare the neighbours and increment the feature map.
"""
fmap
=
fmap
+
(
2
**
ind
)
*
((
pi
-
pc
)
*
(
pi4
-
pc
)
>
0
)
+
(
4
**
ind
)
*
(
abs
(
pi
-
pc
)
>=
abs
(
pi4
-
pc
))
...
...
@@ -181,33 +181,33 @@ class lbp_feature():
def
mlbp
(
self
,
coord
,
fmap_dimx
,
fmap_dimy
,
block_sum
):
def
mlbp
(
self
,
coord
,
f
eature_
map_dimx
,
f
eature_
map_dimy
,
block_sum
):
"""
Function to compute the mLBP for a image at single scale.
The mLBP features of the given image is computed and the feature map is returned.
Inputs:
coord: The coordinates specify the neighbour to be considered.
fmap_dimx: feature map
'
s dimension along the columns.
fmap_dimy: Feature maps dimension along the rows.
f
eature_
map_dimx: feature map
'
s dimension along the columns.
f
eature_
map_dimy: Feature maps dimension along the rows.
Return:
feature_map: The lbp feature map
"""
num_neighbours
=
8
pm
=
numpy
.
zeros
([
fmap_dimy
,
fmap_dimx
])
pm
=
numpy
.
zeros
([
f
eature_
map_dimy
,
f
eature_
map_dimx
])
"""
The comparison of pixel is done with the average of the neighbours and central pixel.
"""
for
ind
in
range
(
num_neighbours
):
pm
=
pm
+
block_sum
[
coord
[
ind
][
0
]:
coord
[
ind
][
0
]
+
fmap_dimy
,
coord
[
ind
][
1
]:
coord
[
ind
][
1
]
+
fmap_dimx
]
pm
=
pm
+
block_sum
[
coord
[
ind
][
0
]:
coord
[
ind
][
0
]
+
f
eature_
map_dimy
,
coord
[
ind
][
1
]:
coord
[
ind
][
1
]
+
f
eature_
map_dimx
]
pm
=
pm
/
num_neighbours
feature_map
=
numpy
.
zeros
([
fmap_dimy
,
fmap_dimx
])
feature_map
=
numpy
.
zeros
([
f
eature_
map_dimy
,
f
eature_
map_dimx
])
for
ind
in
range
(
num_neighbours
):
"""
Select the value of the current neighbour.
"""
pi
=
block_sum
[
coord
[
ind
][
0
]:
coord
[
ind
][
0
]
+
fmap_dimy
,
coord
[
ind
][
1
]:
coord
[
ind
][
1
]
+
fmap_dimx
]
pi
=
block_sum
[
coord
[
ind
][
0
]:
coord
[
ind
][
0
]
+
f
eature_
map_dimy
,
coord
[
ind
][
1
]:
coord
[
ind
][
1
]
+
f
eature_
map_dimx
]
"""
Compare the neighbours and increment the feature map.
"""
feature_map
=
feature_map
+
(
2
**
ind
)
*
(
pi
>=
pm
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment