Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ortner, Joshua
ai4hdr_backend
Commits
f72b0ca6
Commit
f72b0ca6
authored
Jan 21, 2021
by
josh
Browse files
cleaning up readme
parent
6525fc9a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Scripts/__pycache__/ai4hdr_utils.cpython-36.pyc
View file @
f72b0ca6
No preview for this file type
Scripts/ai4hdr_utils.py
View file @
f72b0ca6
...
...
@@ -179,37 +179,39 @@ def importAndProcess( imgPath: str, dbPath: str, newImgName: str ):
os
.
mkdir
(
imgSlicedSizePath
)
os
.
mkdir
(
imgMSSizePath
)
# Step 4: Slice
sliceResults
=
sliceImage
(
imgArr
,
(
size
,
size
)
)
# Step 5: Save slices
for
res
in
sliceResults
[
"slicedImages"
]:
i
=
res
[
0
]
j
=
res
[
1
]
slicedImg
=
res
[
2
]
finalFileName
=
"{}-{}-{}"
.
format
(
newImgName
,
i
,
j
)
sliceSizePath
=
imgSlicedSizePath
.
joinpath
(
"{}.{}"
.
format
(
finalFileName
,
fileExt
)
)
print
(
"SAVING IMAGE:"
,
sliceSizePath
)
cv2
.
imwrite
(
str
(
sliceSizePath
),
slicedImg
)
# Step 6: Mean Shift
(
segmentedImage
,
labelsImage
,
numberRegions
)
=
meanShiftSegmentation
(
slicedImg
)
# Step 7: Save MS results
segColorPath
=
imgMSSizePath
.
joinpath
(
"{}-color-seg.{}"
.
format
(
finalFileName
,
fileExt
)
)
labelImgPath
=
imgMSSizePath
.
joinpath
(
"{}-labels-image.{}"
.
format
(
finalFileName
,
fileExt
)
)
print
(
"SAVING IMAGE:"
,
segColorPath
)
print
(
"SAVING IMAGE:"
,
labelImgPath
)
# scale labelsImage to [0,255]
labelsImage
=
labelsImage
.
astype
(
float
)
labelsImage
/=
labelsImage
.
max
()
labelsImage
*=
255
# save results to image files
cv2
.
imwrite
(
str
(
segColorPath
),
segmentedImage
)
cv2
.
imwrite
(
str
(
labelImgPath
),
labelsImage
)
if
imgArr
.
shape
[
0
]
>=
size
and
imgArr
.
shape
[
1
]
>=
size
:
# Step 4: Slice
sliceResults
=
sliceImage
(
imgArr
,
(
size
,
size
)
)
# Step 5: Save slices
for
res
in
sliceResults
[
"slicedImages"
]:
i
=
res
[
0
]
j
=
res
[
1
]
slicedImg
=
res
[
2
]
finalFileName
=
"{}-{}-{}"
.
format
(
newImgName
,
i
,
j
)
sliceSizePath
=
imgSlicedSizePath
.
joinpath
(
"{}.{}"
.
format
(
finalFileName
,
fileExt
)
)
print
(
"SAVING IMAGE:"
,
sliceSizePath
)
cv2
.
imwrite
(
str
(
sliceSizePath
),
slicedImg
)
# Step 6: Mean Shift
(
segmentedImage
,
labelsImage
,
numberRegions
)
=
meanShiftSegmentation
(
slicedImg
)
# Step 7: Save MS results
segColorPath
=
imgMSSizePath
.
joinpath
(
"{}-color-seg.{}"
.
format
(
finalFileName
,
fileExt
)
)
labelImgPath
=
imgMSSizePath
.
joinpath
(
"{}-labels-image.{}"
.
format
(
finalFileName
,
fileExt
)
)
print
(
"SAVING IMAGE:"
,
segColorPath
)
print
(
"SAVING IMAGE:"
,
labelImgPath
)
# scale labelsImage to [0,255]
labelsImage
=
labelsImage
.
astype
(
float
)
labelsImage
/=
labelsImage
.
max
()
labelsImage
*=
255
# save results to image files
cv2
.
imwrite
(
str
(
segColorPath
),
segmentedImage
)
cv2
.
imwrite
(
str
(
labelImgPath
),
labelsImage
)
...
...
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