Data Science Stack Exchange is a question and answer site for
Data science professionals, Machine Learning specialists, and
those interested in learning more about the field. Join them; it
only takes a minute:
Sign up
Here's how it works:
Anybody can ask a question Anybody can answer The best answers are voted up
and rise to the top
Data Science
Home
Feature extraction of images Ask Question
Questions
in Python
Tags
Users In my class I
have to
Unanswered
18 create an
application
using two
classifiers to
decide
8 whether an
object in an
image is an
example of
phylum
porifera
(seasponge)
By using our site, you acknowledge that
or you
somehave read and understand our Cookie Policy, Privacy
Policy, and our Terms of Service. other object.
However, I
am
completely
lost when it
comes to
feature
extraction
techniques
in python.
My advisor
convinced
me to use
images
which
haven't
been
covered in
class.
Can anyone
direct me
towards
meaningful
documentati
on or
reading or
suggest
methods to
consider?
python
feature-extraction
image-recognition
edited Jan 29 '16 at 6:44
Dawny33 ♦
5,638 8 34 90
asked Nov 15 '15 at 0:45
Jeremy Barnes
195 1 2 8
You read and understand our Cookie Policy, Privacy
By using our site, you acknowledge that you have
menti
Policy, and our Terms of Service.
oned
advis
or, so
I'd
assu
me
this is
part
of a
Gradu
ate
Scho
ol
assig
nment
? Do
you
have
acces
s to
any
comm
ercial
softw
are,
or are
you
expec
ted to
do
this
with
only
Pytho
n and
open-
sourc
e
packa
ges?
What
are
you
learni
ng
about
in
class
at the
mome
nt and
what
By using our site, you acknowledge that you have
is the
read and understand our Cookie Policy, Privacy
Policy, and our Terms of Service. name
of the
class
?
Also,
is
there
a
perfor
manc
e
requir
ement
in
terms
of
time it
shoul
d take
to
give
an
answ
er?
– MLo
wry
Nov
15
'15 at
3:22
I am
expec
ted to
only
use
Pytho
n and
open
sourc
e
packa
ges.
Writin
g my
own
sourc
e
code
is
disco
urage
By using our site, you acknowledge that you have
d, read and understand our Cookie Policy, Privacy
Policy, and our Terms of Service. even.
This
is a
maste
r's
level
cours
e.
The
class
is an
introd
uctory
Data
Scien
ce
cours
e.
The
last
thing
we
cover
ed is
featur
e
select
ion,
thoug
h
almos
t all of
the
discu
ssion
is
about
text
data.
There
are
no
perfor
manc
e
requir
ement
s
outsid
e of
an
accur
acy
By using our site, you acknowledge that you have
~70%
read and understand our Cookie Policy, Privacy
Policy, and our Terms of Service. – Jer
emy
Barne
s
Nov
15
'15 at
18:35
3 Answers
In images,
some
9 frequently
used
techniques
for feature
extraction
are
binarizing
and
blurring
Binarizing:
converts
the image
array into
1s and 0s.
This is
done while
converting
the image
to a 2D
image.
Even gray-
scaling can
also be
used. It
gives you a
numerical
matrix of
the image.
Grayscale
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy
takes much
Policy, and our Terms of Service.
lesser
space
when
stored on
Disc.
This is how
you do it in
Python:
from PIL import
%matplotlib inline
#Import an image
image = Image
image
Example
Image:
Now,
convert into
gray-scale:
im = image.
im
will return
you this
image:
And the
matrix can
be seen by
running
this:
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy
Policy, and our Terms of Service. array(im)
The array
would look
something
like this:
array([[213
[213
[213
...,
[173
[173
[173
Now, use a
histogram
plot and/or
a contour
plot to have
a look at
the image
features:
from pylab
# create a new figure
figure()
gray()
# show contours with origin upper left corner
contour(im,
axis('equal'
axis('off')
figure()
hist(im_array
show()
This would
return you
a plot,
which looks
something
like this:
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy
Policy, and our Terms of Service.
Blurring:
Blurring
algorithm
takes
weighted
average of
neighbourin
g pixels to
incorporate
surrounding
s color into
every pixel.
It enhances
the
contours
better and
helps in
understandi
ng the
features
and their
importance
better.
And this is
how you do
it in Python:
from PIL import
figure()
p = image.convert
p.show()
And the
blurred
image is:
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy
Policy, and our Terms of Service.
So, these
are some
ways in
which you
can do
feature
engineering
. And for
advanced
methods,
you have to
understand
the basics
of
Computer
Vision and
neural
networks,
and also
the different
types of
filters and
their
significance
and the
math
behind
them.
answered Nov 15 '15 at 7:34
Dawny33
5,638
1 Than
k you
so
much
.I
poste
d
about
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy
this
Policy, and our Terms of Service. on a
few
place
s and
yours
was
by far
the
most
infor
mativ
e
answ
er. I
realiz
ed
that I
was
misu
nders
tandi
ng
how
featu
re
extra
ction
of
imag
es
work
s
conc
eptua
lly.
– Je
remy
Barn
es
Nov
15
'15
at
19:38
Glad
that
my
answ
er
helpe
d
By using our site, you acknowledge that you have
you :)read and understand our Cookie Policy, Privacy
Policy, and our Terms of Service. – Da
wny3
3♦
Nov
16
'15
at
0:53
This great
tutorial
7 covers the
basics of
convolution
al
neuraltwork
s, which are
currently
achieving
state of the
art
performanc
e in most
vision tasks:
http://deeple
arning.net/tu
torial/lenet.h
tml
There are a
number of
options for
CNNs in
python,
including
Theano and
the libraries
built on top
of it (I found
keras to be
easy to
use).
If you prefer
to you
By using our site, you acknowledge that avoid
have read and understand our Cookie Policy, Privacy
deep
Policy, and our Terms of Service.
learning,
you might
look into
OpenCV,
which can
learn many
other types
of features,
line Haar
cascades
and SIFT
features.
http://openc
v-python-
tutroals.read
thedocs.org/
en/latest/py
_tutorials/py
_feature2d/
py_table_of
_contents_f
eature2d/py
_table_of_c
ontents_feat
ure2d.html
answered Nov 15 '15 at 6:53
jamesmf
2,417
As Jeremy
Barnes and
1 Jamesmf
said, you
can use any
machine
learning
algorithms
to deal with
the problem.
They are
powerful
and
By using our site, you acknowledge that could
you have read and understand our Cookie Policy, Privacy
Policy, and our Terms of Service.
identify the
features
automaticall
y. You just
need to feed
the
algorithm
the correct
training
data. Since
it is needed
to work on
images,
convolution
neural
networks
will be a
better option
for you .
This is a
good tutorial
for learning
about the
convolution
neural
network.
You could
download
the code
also and
could
change
according to
your
problem
definition.
But you
need to
learn python
and theano
library for
the
processing
and you will
get good
tutorials
By using our site, you acknowledge that forread and understand our Cookie Policy, Privacy
you have
Policy, and our Terms of Service. that too
http://deeple
arning.net/tu
torial/lenet.h
tml
answered May 10 '16 at 9:21
Arun Sooraj
111 1
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy
Policy, and our Terms of Service.