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
0076d0ad
Commit
0076d0ad
authored
12 years ago
by
Sacha Percot-Tétu
Browse files
Options
Downloads
Patches
Plain Diff
Added the BFlit operation
parent
b82c1bcf
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/BFlitOp.cpp
+129
-0
129 additions, 0 deletions
app/Operations/BFlitOp.cpp
app/Operations/BFlitOp.h
+36
-0
36 additions, 0 deletions
app/Operations/BFlitOp.h
with
165 additions
and
0 deletions
app/Operations/BFlitOp.cpp
0 → 100644
+
129
−
0
View file @
0076d0ad
/*
* 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
<QRadioButton>
#include
<QGroupBox>
#include
<QHBoxLayout>
#include
<QPushButton>
#include
<QDialogButtonBox>
#include
<QSpinBox>
#include
<QDoubleSpinBox>
#include
<QLabel>
#include
"BFlitOp.h"
#include
"../Tools.h"
using
namespace
std
;
using
namespace
imagein
;
BFlitOp
::
BFlitOp
()
:
Operation
(
Tools
::
tr
(
"BFlit"
).
toStdString
())
{
}
bool
BFlitOp
::
needCurrentImg
()
const
{
return
true
;
}
Image
*
bflit
(
const
Image
*
image
,
unsigned
int
nPointSide
,
unsigned
int
nIteration
);
void
BFlitOp
::
operator
()(
const
imagein
::
Image
*
image
,
const
std
::
map
<
const
imagein
::
Image
*
,
std
::
string
>&
)
{
QDialog
*
dialog
=
new
QDialog
();
dialog
->
setWindowTitle
(
dialog
->
tr
(
"Parameters"
));
dialog
->
setMinimumWidth
(
180
);
QFormLayout
*
layout
=
new
QFormLayout
(
dialog
);
QSpinBox
*
nPointBox
=
new
QSpinBox
(
dialog
);
QSpinBox
*
nIterBox
=
new
QSpinBox
(
dialog
);
const
unsigned
int
nPointImg
=
image
->
getWidth
()
*
image
->
getHeight
();
nPointBox
->
setRange
(
0
,
nPointImg
/
2
-
1
);
nPointBox
->
setValue
(
nPointImg
/
4
);
nIterBox
->
setValue
(
1
);
layout
->
insertRow
(
0
,
"Number of point on each side : "
,
nPointBox
);
layout
->
insertRow
(
1
,
"Number of iteration : "
,
nIterBox
);
QPushButton
*
okButton
=
new
QPushButton
(
dialog
->
tr
(
"Validate"
),
dialog
);
okButton
->
setDefault
(
true
);
layout
->
addWidget
(
okButton
);
QObject
::
connect
(
okButton
,
SIGNAL
(
clicked
()),
dialog
,
SLOT
(
accept
()));
QDialog
::
DialogCode
code
=
static_cast
<
QDialog
::
DialogCode
>
(
dialog
->
exec
());
if
(
code
!=
QDialog
::
Accepted
)
{
return
;
}
Image
*
resImg
=
bflit
(
image
,
nPointBox
->
value
(),
nIterBox
->
value
());
this
->
outImage
(
resImg
);
}
inline
int
sq
(
int
x
)
{
return
x
*
x
;
}
Image
*
bflit
(
const
Image
*
image
,
unsigned
int
nPointSide
,
unsigned
int
nIteration
)
{
Image
*
resImg
=
new
Image
(
*
image
);
/* filtrage bimodal */
/* determination de lmin et lmax sur l'histogramme */
Histogram
histo
=
image
->
getHistogram
();
int
lMin
=
0
,
lMax
=
255
;
for
(
unsigned
int
n
=
0
;
n
<
nPointSide
;
n
+=
histo
[
++
lMin
]);
for
(
unsigned
int
n
=
0
;
n
<
nPointSide
;
n
+=
histo
[
--
lMax
]);
Image
*
bufImg
=
new
Image
(
resImg
->
getWidth
(),
resImg
->
getHeight
(),
resImg
->
getNbChannels
());
for
(
unsigned
int
n
=
0
;
n
<
nIteration
;
++
n
)
/* boucle sur le nombre d'itrations */
{
for
(
Image
::
iterator
it
=
resImg
->
begin
(),
jt
=
bufImg
->
begin
();
it
<
resImg
->
end
();
++
it
,
++
jt
)
{
*
jt
=
*
it
;
}
for
(
unsigned
int
c
=
0
;
c
<
image
->
getNbChannels
();
++
c
)
{
for
(
unsigned
int
j
=
1
;
j
<
image
->
getHeight
()
-
1
;
++
j
)
{
for
(
unsigned
int
i
=
1
;
i
<
image
->
getWidth
()
-
1
;
++
i
)
{
/* sauvegarde des 4 points voisins dans lumc[i] */
Image
::
depth_t
north
=
bufImg
->
getPixel
(
i
,
j
-
1
,
c
);
Image
::
depth_t
south
=
bufImg
->
getPixel
(
i
,
j
+
1
,
c
);
Image
::
depth_t
east
=
bufImg
->
getPixel
(
i
-
1
,
j
,
c
);
Image
::
depth_t
west
=
bufImg
->
getPixel
(
i
+
1
,
j
,
c
);
/* calcul des distances d1 et d2 */
const
int
d1
=
sq
(
north
-
lMin
)
+
sq
(
south
-
lMin
)
+
sq
(
east
-
lMin
)
+
sq
(
west
-
lMin
);
const
int
d2
=
sq
(
north
-
lMax
)
+
sq
(
south
-
lMax
)
+
sq
(
east
-
lMax
)
+
sq
(
west
-
lMax
);
if
(
d1
<=
d2
)
/* test des distances d1 et d2 */
{
const
Image
::
depth_t
value
=
min
(
north
,
min
(
south
,
min
(
east
,
west
)
)
);
resImg
->
setPixel
(
i
,
j
,
c
,
value
);
}
else
{
const
Image
::
depth_t
value
=
max
(
north
,
max
(
south
,
max
(
east
,
west
)
)
);
resImg
->
setPixel
(
i
,
j
,
c
,
value
);
}
}
}
}
}
/* fin de la boucle sur le nombre d'itrations */
delete
bufImg
;
return
resImg
;
}
This diff is collapsed.
Click to expand it.
app/Operations/BFlitOp.h
0 → 100644
+
36
−
0
View file @
0076d0ad
/*
* 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 BFLITOP_H
#define BFLITOP_H
#include
"Operation.h"
#include
"Image.h"
class
BFlitOp
:
public
Operation
{
public:
BFlitOp
();
void
operator
()(
const
imagein
::
Image
*
,
const
std
::
map
<
const
imagein
::
Image
*
,
std
::
string
>&
);
bool
needCurrentImg
()
const
;
};
#endif // BFLITOP_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