Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-169
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
2022-169
2022-169
Commits
1eca9508
Commit
1eca9508
authored
Oct 10, 2022
by
Heshani H.U
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
cbabc441
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
preprocessing.py
preprocessing.py
+63
-0
No files found.
preprocessing.py
0 → 100644
View file @
1eca9508
import
numpy
as
np
import
cv2
import
os
import
csv
from
image_processing
import
func
if
not
os
.
path
.
exists
(
"data2"
):
os
.
makedirs
(
"data2"
)
if
not
os
.
path
.
exists
(
"data2/train"
):
os
.
makedirs
(
"data2/train"
)
if
not
os
.
path
.
exists
(
"data2/test"
):
os
.
makedirs
(
"data2/test"
)
path
=
"train"
path1
=
"data2"
a
=
[
'label'
]
for
i
in
range
(
64
*
64
):
a
.
append
(
"pixel"
+
str
(
i
))
#outputLine = a.tolist()
label
=
0
var
=
0
c1
=
0
c2
=
0
for
(
dirpath
,
dirnames
,
filenames
)
in
os
.
walk
(
path
):
for
dirname
in
dirnames
:
print
(
dirname
)
for
(
direcpath
,
direcnames
,
files
)
in
os
.
walk
(
path
+
"/"
+
dirname
):
if
not
os
.
path
.
exists
(
path1
+
"/train/"
+
dirname
):
os
.
makedirs
(
path1
+
"/train/"
+
dirname
)
if
not
os
.
path
.
exists
(
path1
+
"/test/"
+
dirname
):
os
.
makedirs
(
path1
+
"/test/"
+
dirname
)
# num=0.75*len(files)
num
=
100000000000000000
i
=
0
for
file
in
files
:
var
+=
1
actual_path
=
path
+
"/"
+
dirname
+
"/"
+
file
actual_path1
=
path1
+
"/"
+
"train/"
+
dirname
+
"/"
+
file
actual_path2
=
path1
+
"/"
+
"test/"
+
dirname
+
"/"
+
file
img
=
cv2
.
imread
(
actual_path
,
0
)
bw_image
=
func
(
actual_path
)
if
i
<
num
:
c1
+=
1
cv2
.
imwrite
(
actual_path1
,
bw_image
)
else
:
c2
+=
1
cv2
.
imwrite
(
actual_path2
,
bw_image
)
i
=
i
+
1
label
=
label
+
1
print
(
var
)
print
(
c1
)
print
(
c2
)
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