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
4bc1f7e8
Commit
4bc1f7e8
authored
12 years ago
by
Sacha Percot-Tétu
Browse files
Options
Downloads
Patches
Plain Diff
Added circular sinus synthesis
parent
e9e32eba
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/Operations/SinusSynthesisOp.cpp
+64
-19
64 additions, 19 deletions
app/Operations/SinusSynthesisOp.cpp
with
64 additions
and
19 deletions
app/Operations/SinusSynthesisOp.cpp
+
64
−
19
View file @
4bc1f7e8
...
...
@@ -27,6 +27,10 @@
#include
<QDialogButtonBox>
#include
<QApplication>
#include
<GrayscaleImage.h>
#include
<QGroupBox>
#include
<QRadioButton>
#include
<QHBoxLayout>
#include
<QLabel>
using
namespace
std
;
using
namespace
imagein
;
...
...
@@ -47,6 +51,14 @@ void SinusSynthesisOp::operator()(const imagein::Image*, const std::map<const im
QFormLayout
*
layout
=
new
QFormLayout
();
dialog
->
setLayout
(
layout
);
QGroupBox
*
radioGroup
=
new
QGroupBox
(
"Direction"
,
dialog
);
QRadioButton
*
linearButton
=
new
QRadioButton
(
dialog
->
tr
(
"Linear"
));
QRadioButton
*
circularButton
=
new
QRadioButton
(
dialog
->
tr
(
"Circular"
));
QHBoxLayout
*
radioLayout
=
new
QHBoxLayout
(
radioGroup
);
radioLayout
->
addWidget
(
linearButton
);
radioLayout
->
addWidget
(
circularButton
);
linearButton
->
setChecked
(
true
);
QSpinBox
*
sizeBox
=
new
QSpinBox
();
sizeBox
->
setRange
(
0
,
65536
);
QSpinBox
*
periodBox
=
new
QSpinBox
();
...
...
@@ -57,16 +69,21 @@ void SinusSynthesisOp::operator()(const imagein::Image*, const std::map<const im
QComboBox
*
colorBox
=
new
QComboBox
();
colorBox
->
addItem
(
dialog
->
tr
(
"256"
));
colorBox
->
addItem
(
dialog
->
tr
(
"2 (Black and white)"
));
layout
->
insertRow
(
0
,
dialog
->
tr
(
"Image size (width=height) : "
),
sizeBox
);
layout
->
insertRow
(
1
,
dialog
->
tr
(
"Signal period (pixel) : "
),
periodBox
);
layout
->
insertRow
(
2
,
dialog
->
tr
(
"Orientation : "
),
angleBox
);
layout
->
insertRow
(
3
,
dialog
->
tr
(
"Niveaux de gris : "
),
colorBox
);
layout
->
insertRow
(
0
,
radioGroup
);
layout
->
insertRow
(
1
,
dialog
->
tr
(
"Image size (width=height) : "
),
sizeBox
);
layout
->
insertRow
(
2
,
dialog
->
tr
(
"Signal period (pixel) : "
),
periodBox
);
QLabel
*
orientationLabel
=
new
QLabel
(
dialog
->
tr
(
"Orientation (°): "
));
layout
->
insertRow
(
3
,
orientationLabel
,
angleBox
);
layout
->
insertRow
(
4
,
dialog
->
tr
(
"Niveaux de gris : "
),
colorBox
);
QDialogButtonBox
*
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
,
Qt
::
Horizontal
,
dialog
);
layout
->
insertRow
(
4
,
buttonBox
);
layout
->
insertRow
(
5
,
buttonBox
);
QObject
::
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
dialog
,
SLOT
(
accept
()));
QObject
::
connect
(
buttonBox
,
SIGNAL
(
rejected
()),
dialog
,
SLOT
(
reject
()));
QObject
::
connect
(
circularButton
,
SIGNAL
(
toggled
(
bool
)),
orientationLabel
,
SLOT
(
setHidden
(
bool
)));
QObject
::
connect
(
circularButton
,
SIGNAL
(
toggled
(
bool
)),
angleBox
,
SLOT
(
setHidden
(
bool
)));
QDialog
::
DialogCode
code
=
static_cast
<
QDialog
::
DialogCode
>
(
dialog
->
exec
());
if
(
code
!=
QDialog
::
Accepted
)
return
;
...
...
@@ -76,23 +93,51 @@ void SinusSynthesisOp::operator()(const imagein::Image*, const std::map<const im
double
angle
=
angleBox
->
value
();
double
period
=
periodBox
->
value
();
double
pi
=
3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117
;
if
(
colorBox
->
currentIndex
()
==
0
)
{
for
(
unsigned
int
j
=
0
;
j
<
resImg
->
getHeight
();
++
j
)
{
for
(
unsigned
int
i
=
0
;
i
<
resImg
->
getWidth
();
++
i
)
{
double
arg
=
i
*
sin
(
angle
/
180.
*
pi
)
+
j
*
cos
(
angle
/
180.
*
pi
);
double
value
=
cos
(
2
*
pi
*
arg
/
period
);
value
=
(
value
+
1.
)
*
128
;
if
(
value
>
255.
)
value
=
255.
;
resImg
->
setPixel
(
i
,
j
,
value
+
0.5
);
if
(
linearButton
->
isChecked
())
{
if
(
colorBox
->
currentIndex
()
==
0
)
{
for
(
unsigned
int
j
=
0
;
j
<
resImg
->
getHeight
();
++
j
)
{
for
(
unsigned
int
i
=
0
;
i
<
resImg
->
getWidth
();
++
i
)
{
double
arg
=
i
*
sin
(
angle
*
pi
/
180.
)
+
j
*
cos
(
angle
*
pi
/
180.
);
double
value
=
cos
(
2
*
pi
*
arg
/
period
);
value
=
(
value
+
1.
)
*
128
;
if
(
value
>
255.
)
value
=
255.
;
resImg
->
setPixel
(
i
,
j
,
value
+
0.5
);
}
}
}
else
{
for
(
unsigned
int
j
=
0
;
j
<
resImg
->
getHeight
();
++
j
)
{
for
(
unsigned
int
i
=
0
;
i
<
resImg
->
getWidth
();
++
i
)
{
double
arg
=
i
*
sin
(
angle
/
180.
*
pi
)
+
j
*
cos
(
angle
/
180.
*
pi
);
double
value
=
cos
(
2
*
pi
*
arg
/
period
);
resImg
->
setPixel
(
i
,
j
,
value
<
0.
?
0
:
255
);
}
}
}
}
else
{
for
(
unsigned
int
j
=
0
;
j
<
resImg
->
getHeight
();
++
j
)
{
for
(
unsigned
int
i
=
0
;
i
<
resImg
->
getWidth
();
++
i
)
{
double
arg
=
i
*
sin
(
angle
/
180.
*
pi
)
+
j
*
cos
(
angle
/
180.
*
pi
);
double
value
=
cos
(
2
*
pi
*
arg
/
period
);
resImg
->
setPixel
(
i
,
j
,
value
<
0.
?
0
:
255
);
else
{
if
(
colorBox
->
currentIndex
()
==
0
)
{
for
(
unsigned
int
j
=
0
;
j
<
resImg
->
getHeight
();
++
j
)
{
for
(
unsigned
int
i
=
0
;
i
<
resImg
->
getWidth
();
++
i
)
{
double
dx
=
i
-
resImg
->
getWidth
()
/
2.
;
double
dy
=
j
-
resImg
->
getHeight
()
/
2.
;
double
arg
=
std
::
sqrt
(
dx
*
dx
+
dy
*
dy
);
double
value
=
cos
(
2
*
pi
*
arg
/
period
);
value
=
(
value
+
1.
)
*
128
;
if
(
value
>
255.
)
value
=
255.
;
resImg
->
setPixel
(
i
,
j
,
value
+
0.5
);
}
}
}
else
{
for
(
unsigned
int
j
=
0
;
j
<
resImg
->
getHeight
();
++
j
)
{
for
(
unsigned
int
i
=
0
;
i
<
resImg
->
getWidth
();
++
i
)
{
double
dx
=
i
-
resImg
->
getWidth
()
/
2.
;
double
dy
=
j
-
resImg
->
getHeight
()
/
2.
;
double
arg
=
std
::
sqrt
(
dx
*
dx
+
dy
*
dy
);
double
value
=
cos
(
2
*
pi
*
arg
/
period
);
resImg
->
setPixel
(
i
,
j
,
value
<
0.
?
0
:
255
);
}
}
}
}
...
...
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