Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Cittena
cittena
Commits
ac331330
Commit
ac331330
authored
Dec 09, 2016
by
Niels-Oliver Walkowski
Browse files
change scatter contrast into rudimentary class
parent
85207cb0
Changes
4
Hide whitespace changes
Inline
Side-by-side
itten/__pycache__/contrasts.cpython-35.pyc
View file @
ac331330
No preview for this file type
itten/__pycache__/movie.cpython-35.pyc
View file @
ac331330
No preview for this file type
itten/contrasts.py
View file @
ac331330
...
...
@@ -8,36 +8,36 @@ import numpy as np
from
.helpers
import
luminance
# TODO nicht benötigte Parameter löschen
def
mono_ctrst_scatplt
(
channel
,
frames
,
frm_step
=
1
,
bins
=
16
,
threshold
=
60000
,
save
=
False
,
**
kwargs
):
"""Creates a scatterplot for the dynamic of contrast across movie
frames
frm_fld: path to folder with movie images
frm_pref: file nave in fron of the count value
frm_step: take every x frame
channel: channel in the HSV color spac
e
save: save plot also to disk
threshold: TODO
"""
contrast_points
=
[]
# pwd list sollte in Frames sein und hier nur durchlaufen werden
for
frm_nr
in
range
(
frames
.
start
,
frames
.
end
,
frm_step
):
pwd
=
frames
.
folder
+
frames
.
prefix
+
str
(
frm_nr
)
+
'.png'
img
=
cv2
.
imread
(
pwd
)
if
channel
==
2
:
_img
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2RGB
)
luminances
=
luminance
(
_img
)
hist_value
,
_
=
np
.
histogram
(
luminances
,
bins
=
bins
,
range
=
(
0
,
255
))
else
:
img_hsv
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2HSV_FULL
)
hist_value
=
cv2
.
calcHist
([
img_hsv
],
[
channel
],
None
,
[
16
],
[
0
,
256
])
for
bin_index
,
point
in
enumerate
(
hist_value
):
if
point
>
threshold
:
contrast_points
.
append
((
frm_nr
,
bin_index
,
int
(
point
)))
return
contrast_points
class
LightDark
(
object
):
"""representations of light/dark contrasts"""
def
__init__
(
self
,
frames
):
self
.
_channel
=
2
self
.
_frm_step
=
50
self
.
_bins
=
16
self
.
_threshold
=
60000
self
.
_save
=
Fals
e
self
.
_frames
=
frames
def
hist_vstack
(
self
):
contrast_points
=
[]
# pwd list sollte in Frames sein und hier nur durchlaufen werden
for
frm_nr
in
range
(
self
.
_
frames
.
start
,
self
.
_
frames
.
end
,
self
.
_
frm_step
):
pwd
=
self
.
_
frames
.
folder
+
self
.
_
frames
.
prefix
+
str
(
frm_nr
)
+
'.png'
img
=
cv2
.
imread
(
pwd
)
if
self
.
_
channel
==
2
:
_img
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2RGB
)
luminances
=
luminance
(
_img
)
hist_value
,
_
=
np
.
histogram
(
luminances
,
bins
=
self
.
_
bins
,
range
=
(
0
,
255
))
else
:
img_hsv
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2HSV_FULL
)
hist_value
=
cv2
.
calcHist
([
img_hsv
],
[
self
.
_
channel
],
None
,
[
16
],
[
0
,
256
])
for
bin_index
,
point
in
enumerate
(
hist_value
):
if
point
>
self
.
_
threshold
:
contrast_points
.
append
((
frm_nr
,
bin_index
,
int
(
point
)))
return
contrast_points
itten/movie.py
View file @
ac331330
...
...
@@ -8,15 +8,17 @@ from . import helpers
from
.
import
contrasts
# zum Problem mit privaten und öffentlichen Eigenschaften http://www.python-course.eu/python3_properties.php
class
Movie
(
object
):
"""main class to interact with the colorspace of movieframes"""
def
__init__
(
self
,
prefix
,
folder
=
'./'
):
# TODO platform independent
Movie
.
frames
=
Frames
(
folder
,
prefix
)
self
.
fsize
=
Movie
.
frames
.
frm_cnt
self
.
_
frames
=
Frames
(
folder
,
prefix
)
self
.
fsize
=
self
.
_
frames
.
frm_cnt
def
scatterpoints
(
self
,
channel
):
contrast
=
contrasts
.
mono_ctrst_scatplt
(
1
,
Movie
.
frames
)
return
contrast
def
light_dark
(
self
):
"""compute the light/dark contrast of the movie """
light_dark_ctrst
=
contrasts
.
LightDark
(
self
.
_frames
)
return
light_dark_ctrst
.
hist_vstack
()
class
Frames
(
object
):
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment