Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Crack_Detection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Jan-Christopher Schmidt
Crack_Detection
Commits
777430aa
Commit
777430aa
authored
1 year ago
by
rohezal
Browse files
Options
Downloads
Patches
Plain Diff
added stats for NN
parent
497345c4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CMakeLists.txt
+1
-1
1 addition, 1 deletion
CMakeLists.txt
include/functions.h
+4
-0
4 additions, 0 deletions
include/functions.h
src/functions.cpp
+59
-2
59 additions, 2 deletions
src/functions.cpp
src/islands.cpp
+1
-1
1 addition, 1 deletion
src/islands.cpp
with
65 additions
and
4 deletions
CMakeLists.txt
+
1
−
1
View file @
777430aa
...
...
@@ -3,7 +3,7 @@ project( DisplayImage )
find_package
(
OpenCV REQUIRED
)
include_directories
(
${
OpenCV_INCLUDE_DIRS
}
)
SET
(
CMAKE_CXX_FLAGS
"-std=c++1
1
"
)
SET
(
CMAKE_CXX_FLAGS
"-std=c++1
7
"
)
file
(
GLOB CPP_FILES
${
PROJECT_SOURCE_DIR
}
/src/*.cpp
...
...
This diff is collapsed.
Click to expand it.
include/functions.h
+
4
−
0
View file @
777430aa
...
...
@@ -4,9 +4,12 @@
#include
<opencv2/imgproc.hpp>
#include
<opencv2/highgui.hpp>
#include
<map>
#include
<variant>
#include
"island.h"
#include
"islands.h"
extern
float
contrastAlpha
;
// = 5.8f;
extern
float
contrastBeta
;
// = -2.8f;
extern
float
contrastAlpha2
;
// = 5.6f;
...
...
@@ -32,6 +35,7 @@ cv::Mat calculateHSVContrastImage(cv::Mat img);
cv
::
Mat
matMaxf
(
cv
::
Mat
a
,
cv
::
Mat
b
);
cv
::
Mat
fillSobel
(
cv
::
Mat
sobel
,
cv
::
Mat
contrast
);
cv
::
Mat
fillSobelRash
(
cv
::
Mat
&
sobel
,
cv
::
Mat
&
hsvValue
);
std
::
map
<
std
::
string
,
std
::
variant
<
int
,
float
,
size_t
>
>
getStats
(
const
cv
::
Mat
&
islandImage
);
std
::
vector
<
std
::
vector
<
cv
::
Vec2i
>>
calculateIslandsAccelerationStructure
(
const
cv
::
Mat
&
_image
);
...
...
This diff is collapsed.
Click to expand it.
src/functions.cpp
+
59
−
2
View file @
777430aa
...
...
@@ -408,8 +408,11 @@ cv::Mat applyCrackFilter2(cv::Mat img, cv::Mat& contrast_image)
temp
.
convertTo
(
filledImage
,
CV_8UC1
,
255
);
//imwrite(filepath+"filled32Bit.png", temp);
//imwrite(filepath+"filled.png", filledImage);
//imwrite(filepath+"filled32Bit.png", temp);
imwrite
(
filepath
+
"filled.png"
,
filledImage
);
getStats
(
filledImage
);
return
filledImage
;
}
...
...
@@ -588,3 +591,57 @@ std::vector<std::vector<cv::Vec2i> > calculateIslandsAccelerationStructure(const
}
return
acceleration_structure
;
}
std
::
map
<
std
::
string
,
std
::
variant
<
int
,
float
,
size_t
>
>
getStats
(
const
Mat
&
islandImage
)
{
std
::
map
<
std
::
string
,
std
::
variant
<
int
,
float
,
size_t
>
>
stats
;
cv
::
Mat
stats_opencv
;
cv
::
Mat
labels
;
cv
::
Mat
centroids
;
cv
::
connectedComponentsWithStats
(
islandImage
,
labels
,
stats_opencv
,
centroids
);
std
::
vector
<
std
::
size_t
>
number_of_pixels
;
for
(
size_t
i
=
0
;
i
<
labels
.
rows
;
i
++
)
{
number_of_pixels
.
push_back
(
stats_opencv
.
at
<
int
>
(
Point
(
CC_STAT_AREA
,
i
)));
}
const
int
number_of_islands
=
labels
.
rows
;
std
::
sort
(
number_of_pixels
.
begin
(),
number_of_pixels
.
end
());
stats
[
"number_of_islands"
]
=
number_of_islands
;
if
(
number_of_islands
>
3
)
{
return
stats
;
}
int
median_islands_size
=
0
;
const
int
largest_island_size
=
number_of_pixels
.
back
();
const
int
large_average_size
=
(
number_of_pixels
[
number_of_pixels
.
size
()
-
1
]
+
number_of_pixels
[
number_of_pixels
.
size
()
-
2
]
+
number_of_pixels
[
number_of_pixels
.
size
()
-
3
])
/
3
;
int
small_island_size
=
large_average_size
/
100
;
int
large_island_size
=
large_average_size
/
10
;
int
number_of_small_islands
=
0
;
int
number_of_large_islands
=
0
;
for
(
size_t
i
=
0
;
i
<
number_of_pixels
.
size
();
i
++
)
{
number_of_small_islands
+=
number_of_pixels
[
i
]
<
small_island_size
?
1
:
0
;
number_of_large_islands
=
number_of_pixels
[
i
]
>=
large_island_size
?
1
:
0
;
}
stats
[
"number_of_large_islands"
]
=
number_of_large_islands
;
stats
[
"number_of_small_islands"
]
=
number_of_small_islands
;
//number of big islands under each other in y direction
return
stats
;
}
This diff is collapsed.
Click to expand it.
src/islands.cpp
+
1
−
1
View file @
777430aa
...
...
@@ -3,7 +3,7 @@
extern
char
const
*
title
;
void
show
(
cv
::
Mat
image
){
return
;
return
;
cv
::
namedWindow
(
title
,
cv
::
WINDOW_NORMAL
);
cv
::
imshow
(
title
,
image
);
//cv::resizeWindow(title, 1000, 1000);
...
...
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