Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ImageINSA_Tanguy
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
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
Tanguy.Raufflet
ImageINSA_Tanguy
Commits
d80e8a2a
Commit
d80e8a2a
authored
1 year ago
by
Tanguy Raufflet
Browse files
Options
Downloads
Patches
Plain Diff
Correction issue 104 : zero-crossing
parent
991577ad
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/Operations/ZeroCrossingOp.cpp
+28
-22
28 additions, 22 deletions
app/Operations/ZeroCrossingOp.cpp
app/Operations/ZeroCrossingOp.h
+2
-2
2 additions, 2 deletions
app/Operations/ZeroCrossingOp.h
with
30 additions
and
24 deletions
app/Operations/ZeroCrossingOp.cpp
+
28
−
22
View file @
d80e8a2a
...
...
@@ -26,7 +26,6 @@
#include
<cmath>
#include
"ZeroCrossingOp.h"
#include
"../Tools.h"
using
namespace
imagein
;
...
...
@@ -40,42 +39,48 @@ bool ZeroCrossingOp::needCurrentImg() const {
void
ZeroCrossingOp
::
operator
()(
const
imagein
::
Image_t
<
double
>*
img
,
const
std
::
map
<
const
imagein
::
Image_t
<
double
>*
,
std
::
string
>&
)
{
QDialog
*
dialog
=
new
QDialog
(
QApplication
::
activeWindow
());
auto
*
dialog
=
new
QDialog
(
QApplication
::
activeWindow
());
dialog
->
setWindowTitle
(
QString
(
qApp
->
translate
(
"ZeroCrossingOp"
,
"Zero crossing"
)));
dialog
->
setMinimumWidth
(
180
);
QFormLayo
ut
*
layout
=
new
QFormLayout
();
a
ut
o
*
layout
=
new
QFormLayout
();
dialog
->
setLayout
(
layout
);
QDoubleSpinBox
*
thresholdBox
=
new
QDoubleSpinBox
();
auto
*
thresholdBox
=
new
QDoubleSpinBox
();
thresholdBox
->
setRange
(
0.
,
65536.
);
layout
->
insertRow
(
0
,
qApp
->
translate
(
"ZeroCrossingOp"
,
"Threshold : "
),
thresholdBox
);
QDialogButtonBox
*
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
,
Qt
::
Horizontal
,
dialog
);
auto
*
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
,
Qt
::
Horizontal
,
dialog
);
layout
->
insertRow
(
3
,
buttonBox
);
QObject
::
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
dialog
,
SLOT
(
accept
()));
QObject
::
connect
(
buttonBox
,
SIGNAL
(
rejected
()),
dialog
,
SLOT
(
reject
()));
QDialog
::
DialogCode
code
=
static_cast
<
QDialog
::
DialogCode
>
(
dialog
->
exec
());
auto
code
=
static_cast
<
QDialog
::
DialogCode
>
(
dialog
->
exec
());
if
(
code
!=
QDialog
::
Accepted
)
return
;
double
threshold
=
thresholdBox
->
value
();
//
parametre de l'algorithme
double
threshold
=
thresholdBox
->
value
();
//
algorithm setting set by the user
//Creation de l'image Résultat, de même taille que les images de départ
Image_t
<
double
>*
result
=
new
Image_t
<
double
>
(
img
->
getWidth
(),
img
->
getHeight
(),
img
->
getNbChannels
(),
0.
);
//image resultat
//Creation of the result image of the same size than the input one
auto
*
result
=
new
Image_t
<
double
>
(
img
->
getWidth
(),
img
->
getHeight
(),
img
->
getNbChannels
(),
0.
);
//image resultat
double
currentPix
;
double
neighboorPix
;
//Algorithme de traitement
//Processing algorithm
//Step 1 : navigate through every pixels
for
(
unsigned
int
c
=
0
;
c
<
img
->
getNbChannels
();
++
c
)
{
for
(
unsigned
int
j
=
2
;
j
<
img
->
getHeight
()
-
2
;
++
j
)
{
for
(
unsigned
int
i
=
2
;
i
<
img
->
getWidth
()
-
2
;
++
i
)
{
for
(
unsigned
int
j
=
1
;
j
<
img
->
getHeight
()
-
1
;
++
j
)
{
for
(
unsigned
int
i
=
1
;
i
<
img
->
getWidth
()
-
1
;
++
i
)
{
bool
edge
=
false
;
for
(
unsigned
int
k
=
i
-
1
;
k
<
i
+
1
;
++
k
)
{
for
(
unsigned
int
l
=
j
-
1
;
l
<
j
+
1
;
++
l
)
{
if
(
img
->
getPixelAt
(
i
,
j
,
c
)
<=
0
&&
img
->
getPixelAt
(
k
,
l
,
c
)
>
0
)
{
double
dist
=
std
::
abs
(
img
->
getPixelAt
(
i
,
j
,
c
)
-
img
->
getPixelAt
(
k
,
l
,
c
));
if
(
dist
>
threshold
)
edge
=
true
;
currentPix
=
img
->
getPixelAt
(
i
,
j
,
c
);
//Step 2 : Navigate through the neighborhood of the current pîxel
for
(
unsigned
int
k
=
i
-
1
;
k
<=
i
+
1
;
++
k
)
{
for
(
unsigned
int
l
=
j
-
1
;
l
<=
j
+
1
;
++
l
)
{
neighboorPix
=
img
->
getPixelAt
(
k
,
l
,
c
);
//Step 3 : Is it an edge or not ?
if
(
currentPix
<=
0
&&
neighboorPix
>
0
&&
std
::
abs
(
currentPix
-
neighboorPix
)
>
threshold
)
{
edge
=
true
;
}
}
}
...
...
@@ -85,12 +90,13 @@ void ZeroCrossingOp::operator()(const imagein::Image_t<double>* img, const std::
}
}
// Maintenant, on élimine les contours isolés.
Image_t
<
double
>*
result2
=
new
Image_t
<
double
>
(
*
result
);
//image resultat
//Generation of a new image with a clean of isolated edges
auto
*
result2
=
new
Image_t
<
double
>
(
*
result
);
//image resultat
for
(
unsigned
int
c
=
0
;
c
<
result2
->
getNbChannels
();
++
c
)
{
for
(
unsigned
int
j
=
2
;
j
<
result2
->
getHeight
()
-
2
;
++
j
)
{
for
(
unsigned
int
i
=
2
;
i
<
result2
->
getWidth
()
-
2
;
++
i
)
{
for
(
unsigned
int
j
=
1
;
j
<
result2
->
getHeight
()
-
1
;
++
j
)
{
for
(
unsigned
int
i
=
1
;
i
<
result2
->
getWidth
()
-
1
;
++
i
)
{
if
(
result2
->
getPixelAt
(
i
,
j
,
c
)
>
127
)
{
if
(
result2
->
getPixelAt
(
i
-
1
,
j
,
c
)
==
0
&&
result2
->
getPixelAt
(
i
,
j
-
1
,
c
)
==
0
...
...
This diff is collapsed.
Click to expand it.
app/Operations/ZeroCrossingOp.h
+
2
−
2
View file @
d80e8a2a
...
...
@@ -27,9 +27,9 @@ class ZeroCrossingOp : public DoubleOperation
public:
ZeroCrossingOp
();
void
operator
()(
const
imagein
::
Image_t
<
double
>*
,
const
std
::
map
<
const
imagein
::
Image_t
<
double
>*
,
std
::
string
>&
);
void
operator
()(
const
imagein
::
Image_t
<
double
>*
,
const
std
::
map
<
const
imagein
::
Image_t
<
double
>*
,
std
::
string
>&
)
override
;
bool
needCurrentImg
()
const
;
bool
needCurrentImg
()
const
override
;
};
#endif // ZEROCROSSINGOP_H
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