Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Augmented Reality Chemistry Laboratory
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-189
Augmented Reality Chemistry Laboratory
Commits
68a9552b
Commit
68a9552b
authored
Jun 30, 2021
by
Charuka_IT18114454
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add gussian tresold for python to get correct result from captured image
parent
9e7302b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
app/src/main/python/preprosessgreyscale.py
app/src/main/python/preprosessgreyscale.py
+11
-2
No files found.
app/src/main/python/preprosessgreyscale.py
View file @
68a9552b
import
numpy
as
np
import
numpy
as
np
import
cv2
import
cv2
from
PIL
import
Image
from
PIL
import
Image
,
ImageEnhance
import
base64
import
base64
import
io
import
io
...
@@ -9,8 +9,17 @@ def main(data):
...
@@ -9,8 +9,17 @@ def main(data):
np_data
=
np
.
fromstring
(
decoded_data
,
np
.
uint8
)
np_data
=
np
.
fromstring
(
decoded_data
,
np
.
uint8
)
img
=
cv2
.
imdecode
(
np_data
,
cv2
.
IMREAD_UNCHANGED
)
img
=
cv2
.
imdecode
(
np_data
,
cv2
.
IMREAD_UNCHANGED
)
img_gray
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2GRAY
)
img_gray
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2GRAY
)
pil_im
=
Image
.
fromarray
(
img_gray
)
kernel
=
np
.
ones
((
1
,
1
),
np
.
uint8
)
pil_im
=
cv2
.
dilate
(
img_gray
,
kernel
,
iterations
=
1
)
pil_im
=
cv2
.
erode
(
pil_im
,
kernel
,
iterations
=
1
)
# pil_im = cv2.adaptiveThreshold(cv2.medianBlur(pil_im, 5), 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 31, 5)
pil_im
=
cv2
.
threshold
(
cv2
.
GaussianBlur
(
pil_im
,
(
9
,
9
),
0
),
0
,
255
,
cv2
.
THRESH_BINARY
+
cv2
.
THRESH_OTSU
)[
1
]
pil_im
=
Image
.
fromarray
(
pil_im
)
buff
=
io
.
BytesIO
()
buff
=
io
.
BytesIO
()
pil_im
.
save
(
buff
,
format
=
"PNG"
)
pil_im
.
save
(
buff
,
format
=
"PNG"
)
img_str
=
base64
.
b64encode
(
buff
.
getvalue
())
img_str
=
base64
.
b64encode
(
buff
.
getvalue
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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