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
14239949
Commit
14239949
authored
12 years ago
by
Sacha Percot-Tétu
Browse files
Options
Downloads
Patches
Plain Diff
Added zero crossing operation
parent
5bac771f
No related branches found
Branches containing commit
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
+112
-0
112 additions, 0 deletions
app/Operations/ZeroCrossingOp.cpp
app/Operations/ZeroCrossingOp.h
+35
-0
35 additions, 0 deletions
app/Operations/ZeroCrossingOp.h
with
147 additions
and
0 deletions
app/Operations/ZeroCrossingOp.cpp
0 → 100644
+
112
−
0
View file @
14239949
/*
* Copyright 2011-2012 INSA Rennes
*
* This file is part of EIImage.
*
* EIImage is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EIImage is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EIImage. If not, see <http://www.gnu.org/licenses/>.
*/
#include
<QDialog>
#include
<QFormLayout>
#include
<QComboBox>
#include
<QDoubleSpinBox>
#include
<QDialogButtonBox>
#include
<QApplication>
#include
"ZeroCrossingOp.h"
#include
"../Tools.h"
using
namespace
std
;
using
namespace
imagein
;
ZeroCrossingOp
::
ZeroCrossingOp
()
:
DoubleOperation
(
Tools
::
tr
(
"Zero crossing"
).
toStdString
())
{
}
bool
ZeroCrossingOp
::
needCurrentImg
()
const
{
return
true
;
}
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
());
dialog
->
setWindowTitle
(
QString
(
dialog
->
tr
(
"Zero crossing"
)));
dialog
->
setMinimumWidth
(
180
);
QFormLayout
*
layout
=
new
QFormLayout
();
dialog
->
setLayout
(
layout
);
QDoubleSpinBox
*
thresholdBox
=
new
QDoubleSpinBox
();
thresholdBox
->
setRange
(
0.
,
65536.
);
layout
->
insertRow
(
0
,
dialog
->
tr
(
"Threshold : "
),
thresholdBox
);
QDialogButtonBox
*
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
());
if
(
code
!=
QDialog
::
Accepted
)
return
;
double
threshold
=
thresholdBox
->
value
();
//parametre de l'algorithme
//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
//Algorithme de traitement
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
)
{
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
=
abs
(
img
->
getPixelAt
(
i
,
j
,
c
)
-
img
->
getPixelAt
(
k
,
l
,
c
));
if
(
dist
>
threshold
)
edge
=
true
;
}
}
}
if
(
edge
)
result
->
setPixel
(
i
,
j
,
c
,
255.
);
}
}
}
// Maintenant, on élimine les contours isolés.
Image_t
<
double
>*
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
)
{
if
(
result2
->
getPixelAt
(
i
,
j
,
c
)
>
127
)
{
if
(
result2
->
getPixelAt
(
i
-
1
,
j
,
c
)
==
0
&&
result2
->
getPixelAt
(
i
,
j
-
1
,
c
)
==
0
&&
result2
->
getPixelAt
(
i
+
1
,
j
,
c
)
==
0
&&
result2
->
getPixelAt
(
i
,
j
+
1
,
c
)
==
0
&&
result2
->
getPixelAt
(
i
+
1
,
j
+
1
,
c
)
==
0
&&
result2
->
getPixelAt
(
i
+
1
,
j
-
1
,
c
)
==
0
&&
result2
->
getPixelAt
(
i
-
1
,
j
+
1
,
c
)
==
0
&&
result2
->
getPixelAt
(
i
-
1
,
j
-
1
,
c
)
==
0
)
{
result2
->
setPixelAt
(
i
,
j
,
c
,
0.
);
}
}
}
}
}
outDoubleImage
(
result
,
"contours bruts"
);
outDoubleImage
(
result2
,
"contours nettoyes"
);
}
This diff is collapsed.
Click to expand it.
app/Operations/ZeroCrossingOp.h
0 → 100644
+
35
−
0
View file @
14239949
/*
* Copyright 2011-2012 INSA Rennes
*
* This file is part of EIImage.
*
* EIImage is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EIImage is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EIImage. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ZEROCROSSINGOP_H
#define ZEROCROSSINGOP_H
#include
<Operation.h>
class
ZeroCrossingOp
:
public
DoubleOperation
{
public:
ZeroCrossingOp
();
void
operator
()(
const
imagein
::
Image_t
<
double
>*
,
const
std
::
map
<
const
imagein
::
Image_t
<
double
>*
,
std
::
string
>&
);
bool
needCurrentImg
()
const
;
};
#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