Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
assignment Programming 2
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
Service Desk
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gastel, L. van (Lex, Student B-BMT)
assignment Programming 2
Commits
d54bcaf3
Commit
d54bcaf3
authored
6 days ago
by
LexvanGastel
Browse files
Options
Downloads
Patches
Plain Diff
vraag 21
parent
46c5b83e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Q2main.py
+25
-5
25 additions, 5 deletions
Q2main.py
with
25 additions
and
5 deletions
Q2main.py
+
25
−
5
View file @
d54bcaf3
...
...
@@ -16,13 +16,14 @@ class ImageProcessor:
return
red_channel
,
green_channel
,
blue_channel
def
convert_to_hsv
(
self
):
return
hsv_image
hsv_image
=
cv2
.
cv2
.
cvtColor
(
self
.
image
,
cv2
.
COLOR_BGR2HSV
)
class
Plotter
:
@staticmethod
def
__init__
(
self
):
pass
@staticmethod
def
plot_image_channels
(
image
,
red
,
green
,
blue
):
fig
,
axes
=
plt
.
subplots
(
2
,
2
,
figsize
=
(
12
,
8
))
...
...
@@ -43,12 +44,31 @@ class Plotter:
axes
[
1
,
1
].
axis
(
"
off
"
)
plt
.
show
()
def
plot_histograms
(
self
,
image
):
return
None
@staticmethod
def
plot_histograms
(
red
,
green
,
blue
):
fig
,
axes
=
plt
.
subplots
(
1
,
3
,
figsize
=
(
15
,
5
))
axes
[
0
].
hist
(
red
.
ravel
(),
bins
=
256
,
color
=
"
red
"
,
alpha
=
0.7
)
axes
[
0
].
set_title
(
'
Red Channel Histogram
'
)
axes
[
0
].
set_xlabel
(
'
Pixel Intensity
'
)
axes
[
0
].
set_ylabel
(
'
Frequency
'
)
axes
[
1
].
hist
(
green
.
ravel
(),
bins
=
256
,
color
=
"
green
"
,
alpha
=
0.7
)
axes
[
1
].
set_title
(
'
Green Channel Histogram
'
)
axes
[
1
].
set_xlabel
(
'
Pixel Intensity
'
)
axes
[
1
].
set_ylabel
(
'
Frequency
'
)
axes
[
2
].
hist
(
blue
.
ravel
(),
bins
=
256
,
color
=
"
blue
"
,
alpha
=
0.7
)
axes
[
2
].
set_title
(
'
Blue Channel Histogram
'
)
axes
[
2
].
set_xlabel
(
'
Pixel Intensity
'
)
axes
[
2
].
set_ylabel
(
'
Frequency
'
)
plt
.
show
()
image_path
=
"
traffic_light_image_1.png
"
processor
=
ImageProcessor
(
image_path
)
red
,
green
,
blue
=
processor
.
get_color_channels
()
Plotter
.
plot_image_channels
(
processor
.
image_rgb
,
red
,
green
,
blue
)
\ No newline at end of file
Plotter
.
plot_image_channels
(
processor
.
image_rgb
,
red
,
green
,
blue
)
Plotter
.
plot_histograms
(
red
,
green
,
blue
)
\ No newline at end of file
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