Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BachelorDeeplearning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
s184400
BachelorDeeplearning
Commits
2a5790c1
Commit
2a5790c1
authored
4 years ago
by
Gustav Als
Browse files
Options
Downloads
Patches
Plain Diff
general_cc
parent
4e34f0fe
No related branches found
No related tags found
1 merge request
!2
Prepocessing
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Gaussian_derivative.py
+42
-8
42 additions, 8 deletions
Gaussian_derivative.py
with
42 additions
and
8 deletions
Gaussian_derivative.py
+
42
−
8
View file @
2a5790c1
import
numpy
as
np
import
cv2
from
PIL
import
Image
import
matplotlib.pyplot
as
plt
from
scipy
import
signal
...
...
@@ -187,14 +186,17 @@ plt.figure(2)
plt
.
imshow
(
test_img2
)
plt
.
show
()
def
general_color_constancy
(
image
,
gaussian_differentiation
=
0
,
sigma
=
1
,
minkowski_norm
=
0
,
mask_image
=
0
,
saturation_threshold
=
255
):
def
general_color_constancy
(
image
,
gaussian_differentiation
=
0
,
minkowski_norm
=
1
,
sigma
=
1
,
mask_image
=
0
):
y_height
,
x_height
,
dimension
=
image
.
shape
if
mask_image
==
0
:
mask_image
=
np
.
zeros
((
y_height
,
x_height
))
if
mask_image
==
0
:
mask_image
=
np
.
zeros
((
y_height
,
x_height
))
#Removing saturated points
saturation_threshold
=
255
mask_image2
=
mask_image
+
(
dilation33
(
np
.
max
(
image
,
axis
=
2
))
>=
saturation_threshold
).
astype
(
int
)
mask_image2
=
(
mask_image2
==
0
).
astype
(
int
)
# TODO wright set border
mask_image2
=
set_border
(
mask_image2
,
sigma
+
1
)
out_image
=
image
...
...
@@ -204,7 +206,6 @@ def general_color_constancy(image, gaussian_differentiation=0,sigma = 1,minkowsk
for
i
in
range
(
3
):
image
[:,:,
i
]
=
gaussian_derivative
(
image
,
sigma
,
0
,
0
)
elif
gaussian_differentiation
>
0
:
# TODO wright norm_derivative
Rx
,
Gx
,
Bx
=
norm_derivative
(
image
,
sigma
,
gaussian_differentiation
)
image
[:,:,
0
]
=
Rx
Image
[:,:,
1
]
=
Gx
...
...
@@ -212,6 +213,39 @@ def general_color_constancy(image, gaussian_differentiation=0,sigma = 1,minkowsk
image
=
np
.
abs
(
image
)
if
minkowski_norm
!=
-
1
:
#Minkowski norm = (1, infinity [
kleur
=
np
.
power
(
image
,
minkowski_norm
)
white_R
=
np
.
power
(
np
.
sum
(
kleur
[:,
:,
0
]
*
mask_image2
),
1
/
minkowski_norm
)
white_G
=
np
.
power
(
np
.
sum
(
kleur
[:,
:,
1
]
*
mask_image2
),
1
/
minkowski_norm
)
white_B
=
np
.
power
(
np
.
sum
(
kleur
[:,
:,
2
]
*
mask_image2
),
1
/
minkowski_norm
)
som
=
np
.
sqrt
(
white_R
**
2
+
white_G
**
2
+
white_B
**
2
)
white_R
=
white_R
/
som
white_G
=
white_G
/
som
white_B
=
white_B
/
som
else
:
#Minkowski norm is infinite, hence the max algorithm is applied
R
=
image
[:,
:,
0
]
G
=
image
[:,
:,
1
]
B
=
image
[:,
:,
2
]
white_R
=
np
.
max
(
R
*
mask_image2
)
white_G
=
np
.
max
(
G
*
mask_image2
)
white_B
=
np
.
max
(
B
*
mask_image2
)
som
=
np
.
sqrt
(
white_R
**
2
+
white_G
**
2
+
white_B
**
2
)
white_R
=
white_R
/
som
white_G
=
white_G
/
som
white_B
=
white_B
/
som
out_image
[:,
:,
0
]
=
out_image
[:,
:,
0
]
/
(
white_R
*
np
.
sqrt
(
3
))
out_image
[:,
:,
1
]
=
out_image
[:,
:,
1
]
/
(
white_G
*
np
.
sqrt
(
3
))
out_image
[:,
:,
2
]
=
out_image
[:,
:,
2
]
/
(
white_B
*
np
.
sqrt
(
3
))
return
white_R
,
white_G
,
white_B
,
out_image
...
...
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