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
46c5b83e
Commit
46c5b83e
authored
3 weeks ago
by
LexvanGastel
Browse files
Options
Downloads
Patches
Plain Diff
vraag 20 2-4
parent
b3446797
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Q2main.py
+35
-7
35 additions, 7 deletions
Q2main.py
traffic_light_image_1.png
+0
-0
0 additions, 0 deletions
traffic_light_image_1.png
with
35 additions
and
7 deletions
Q2main.py
+
35
−
7
View file @
46c5b83e
import
cv2
import
matplotlib.pyplot
as
plt
class
ImageProcessor
:
class
ImageProcessor
:
def
__init__
(
self
,
image_path
):
def
__init__
(
self
,
image_path
):
self
.
image
self
.
image
=
cv2
.
imread
(
image_path
)
self
.
image_rgb
self
.
image_rgb
=
cv2
.
cvtColor
(
self
.
image
,
cv2
.
COLOR_BGR2RGB
)
self
.
image_hsv
def
apply_median_filter
(
self
,
kernel_size
):
def
apply_median_filter
(
self
,
kernel_size
):
return
filterd_image
return
filterd_image
def
get_color_channels
(
self
):
def
get_color_channels
(
self
):
red_channel
=
self
.
image_rgb
[:,
:,
0
]
green_channel
=
self
.
image_rgb
[:,
:,
1
]
blue_channel
=
self
.
image_rgb
[:,
:,
2
]
return
red_channel
,
green_channel
,
blue_channel
return
red_channel
,
green_channel
,
blue_channel
def
convert_to_hsv
(
self
):
def
convert_to_hsv
(
self
):
return
hsv_image
return
hsv_image
class
Plotter
:
class
Plotter
:
@staticmethod
def
__init__
(
self
):
def
__init__
(
self
):
pass
pass
def
plot_image_channels
(
self
,
image
):
def
plot_image_channels
(
image
,
red
,
green
,
blue
):
return
None
fig
,
axes
=
plt
.
subplots
(
2
,
2
,
figsize
=
(
12
,
8
))
axes
[
0
,
0
].
imshow
(
image
)
axes
[
0
,
0
].
set_title
(
"
Original picture
"
)
axes
[
0
,
0
].
axis
(
"
off
"
)
axes
[
0
,
1
].
imshow
(
red
,
cmap
=
"
Reds
"
)
axes
[
0
,
1
].
set_title
(
"
Red channel
"
)
axes
[
0
,
1
].
axis
(
"
off
"
)
axes
[
1
,
0
].
imshow
(
green
,
cmap
=
"
Greens
"
)
axes
[
1
,
0
].
set_title
(
"
Green channel
"
)
axes
[
1
,
0
].
axis
(
"
off
"
)
axes
[
1
,
1
].
imshow
(
blue
,
cmap
=
"
Blues
"
)
axes
[
1
,
1
].
set_title
(
"
blue channel
"
)
axes
[
1
,
1
].
axis
(
"
off
"
)
plt
.
show
()
def
plot_histograms
(
self
,
image
):
def
plot_histograms
(
self
,
image
):
return
None
return
None
\ No newline at end of file
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
This diff is collapsed.
Click to expand it.
traffic_light_image_1.png
0 → 100644
+
0
−
0
View file @
46c5b83e
Image diff could not be displayed: it is too large. Options to address this:
view the blob
.
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