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
45e0d3a5
Commit
45e0d3a5
authored
12 years ago
by
Sacha Percot-Tétu
Browse files
Options
Downloads
Patches
Plain Diff
Added the FFT operation
parent
b92787cf
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/FFTOp.cpp
+87
-0
87 additions, 0 deletions
app/Operations/FFTOp.cpp
app/Operations/FFTOp.h
+35
-0
35 additions, 0 deletions
app/Operations/FFTOp.h
with
122 additions
and
0 deletions
app/Operations/FFTOp.cpp
0 → 100644
+
87
−
0
View file @
45e0d3a5
/*
* 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
"ImgWidget.h"
#include
"FFTOp.h"
#include
"../Tools.h"
#include
"../Algorithms/FFT.h"
#include
<cmath>
using
namespace
std
;
using
namespace
imagein
;
FFTOp
::
FFTOp
()
:
Operation
(
Tools
::
tr
(
"Discrete Fourier transform"
).
toStdString
())
{
}
bool
FFTOp
::
needCurrentImg
()
const
{
return
true
;
}
void
FFTOp
::
operator
()(
const
imagein
::
Image
*
image
,
const
map
<
const
imagein
::
Image
*
,
string
>&
)
{
unsigned
int
width
=
nearestUpPower2
(
image
->
getWidth
());
unsigned
int
height
=
nearestUpPower2
(
image
->
getHeight
());
Image_t
<
double
>*
magnitudeImg
=
new
Image_t
<
double
>
(
width
,
height
,
image
->
getNbChannels
());
Image_t
<
double
>*
phaseImg
=
new
Image_t
<
double
>
(
width
,
height
,
image
->
getNbChannels
());
// Image_t<double>* realImg = new Image_t<double>(width, height, image->getNbChannels());
// Image_t<double>* imagImg = new Image_t<double>(width, height, image->getNbChannels());
complex
<
double
>**
data
=
new
complex
<
double
>*
[
width
];
for
(
unsigned
int
i
=
0
;
i
<
width
;
++
i
)
data
[
i
]
=
new
complex
<
double
>
[
height
];
for
(
unsigned
int
c
=
0
;
c
<
image
->
getNbChannels
();
++
c
)
{
for
(
unsigned
int
j
=
0
;
j
<
image
->
getHeight
();
++
j
)
{
for
(
unsigned
int
i
=
0
;
i
<
image
->
getWidth
();
++
i
)
{
data
[
i
][
j
]
=
static_cast
<
double
>
(
image
->
getPixel
(
i
,
j
,
c
));
}
}
for
(
unsigned
int
j
=
image
->
getHeight
();
j
<
height
;
++
j
)
{
for
(
unsigned
int
i
=
image
->
getWidth
();
i
<
height
;
++
i
)
{
data
[
i
][
j
]
=
0
;
}
}
FFT2D
(
data
,
width
,
height
,
1
);
for
(
unsigned
int
j
=
0
;
j
<
height
;
++
j
)
{
for
(
unsigned
int
i
=
0
;
i
<
width
;
++
i
)
{
const
double
real
=
data
[
i
][
j
].
real
();
const
double
imag
=
data
[
i
][
j
].
imag
();
const
double
magnitude
=
sqrt
(
real
*
real
+
imag
*
imag
);
const
double
phase
=
atan2
(
imag
,
real
);
const
unsigned
int
cw
=
width
/
2
;
const
unsigned
int
ch
=
height
/
2
;
const
unsigned
int
ci
=
i
>=
cw
?
i
-
cw
:
i
+
cw
;
const
unsigned
int
cj
=
j
>=
ch
?
j
-
ch
:
j
+
ch
;
magnitudeImg
->
setPixel
(
ci
,
cj
,
c
,
magnitude
);
phaseImg
->
setPixel
(
ci
,
cj
,
c
,
phase
);
// realImg->setPixel(ci, cj, c, real);
// imagImg->setPixel(ci, cj, c, imag);
}
}
}
this
->
outDoubleImage
(
phaseImg
,
" - FFT (phase)"
,
true
,
false
);
this
->
outDoubleImage
(
magnitudeImg
,
" - FFT (magnitude)"
,
true
,
true
);
// result.push_back(new DoubleImgWidget(phaseImg, " - FFT : phase", true, false));
// result.push_back(new DoubleImgWidget(magnitudeImg, " - FFT : magnitude", true, true));
// result.push_back(new DoubleImgWidget(realImg, " - FFT : real", true, true));
// result.push_back(new DoubleImgWidget(imagImg, " - FFT : imag", true, true));
}
This diff is collapsed.
Click to expand it.
app/Operations/FFTOp.h
0 → 100644
+
35
−
0
View file @
45e0d3a5
/*
* 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 FFTOP_H
#define FFTOP_H
#include
<Operation.h>
class
FFTOp
:
public
Operation
{
public:
FFTOp
();
void
operator
()(
const
imagein
::
Image
*
,
const
std
::
map
<
const
imagein
::
Image
*
,
std
::
string
>&
);
bool
needCurrentImg
()
const
;
};
#endif // FFTOP_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