Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Robin Stampa
SingleImageFourierTransform
Commits
09cf730b
Commit
09cf730b
authored
Oct 09, 2020
by
Robin Stampa
Browse files
Completed
parent
bccae99b
Changes
1
Hide whitespace changes
Inline
Side-by-side
SingleImageFourierTransform.cpp
View file @
09cf730b
...
...
@@ -118,16 +118,14 @@ int main()
writepng
(
"Images/check_before_scaled.png"
,
result_data
,
image_width
,
image_height
);
// --------------------------- LOWPASS
// --------------------------- Apply Gaussian Blur
double
sigma
=
15
;
for
(
long
i
=
0
;
i
<
image_length
;
i
++
)
{
int
x
=
i
%
image_width
-
image_width
/
2
;
int
y
=
i
/
image_width
-
image_height
/
2
;
if
(
x
*
x
+
y
*
y
>
image_height
*
image_height
/
400
&&
!
(
x
==
0
&&
y
==
0
))
{
signal_t
[
image_switch_index
(
i
,
image_width
,
image_height
)][
0
]
=
0
;
signal_t
[
image_switch_index
(
i
,
image_width
,
image_height
)][
1
]
=
0
;
}
signal_t
[
image_switch_index
(
i
,
image_width
,
image_height
)][
0
]
=
exp
(
-
(
x
*
x
+
y
*
y
)
/
(
2
*
sigma
*
sigma
))
*
signal_t
[
image_switch_index
(
i
,
image_width
,
image_height
)][
0
];
signal_t
[
image_switch_index
(
i
,
image_width
,
image_height
)][
1
]
=
exp
(
-
(
x
*
x
+
y
*
y
)
/
(
2
*
sigma
*
sigma
))
*
signal_t
[
image_switch_index
(
i
,
image_width
,
image_height
)][
1
];
}
for
(
long
i
=
0
;
i
<
image_length
;
i
++
)
...
...
@@ -135,14 +133,14 @@ int main()
result_data
[
i
]
=
own_abs_2
(
signal_t
[
image_switch_index
(
i
,
image_width
,
image_height
)])
/
image_length
;
}
writepng
(
"Images/check_
lowpass
.png"
,
result_data
,
image_width
,
image_height
);
writepng
(
"Images/check_
after
.png"
,
result_data
,
image_width
,
image_height
);
for
(
long
i
=
0
;
i
<
image_length
;
i
++
)
{
result_data
[
i
]
=
d2uc_converter
(
own_abs_2
(
signal_t
[
image_switch_index
(
i
,
image_width
,
image_height
)])
/
image_length
);
}
writepng
(
"Images/check_
lowpass
_scaled.png"
,
result_data
,
image_width
,
image_height
);
writepng
(
"Images/check_
after
_scaled.png"
,
result_data
,
image_width
,
image_height
);
fftw_execute
(
backward_plan
);
...
...
@@ -151,56 +149,7 @@ int main()
result_data
[
i
]
=
d2uc_converter
(
own_abs_2
(
signal_s
[
i
])
/
image_length
/
image_length
);
}
writepng
(
"Images/result_lowpass.png"
,
result_data
,
image_width
,
image_height
);
// ----------------------------- HIGHPASS
for
(
long
i
=
0
;
i
<
image_length
;
i
++
)
{
signal_s
[
i
][
0
]
=
sqrt
(
image_data
[
i
]);
if
(
bAmplitudeWithPhase
)
{
signal_s
[
i
][
1
]
=
(
double
)
phase_data
[
i
]
*
2
*
M_PI
/
256
;
}
else
{
signal_s
[
i
][
1
]
=
0
;
}
}
fftw_execute
(
forward_plan
);
for
(
long
i
=
0
;
i
<
image_length
;
i
++
)
{
int
x
=
i
%
image_width
-
image_width
/
2
;
int
y
=
i
/
image_width
-
image_height
/
2
;
if
(
x
*
x
+
y
*
y
<=
image_height
*
image_height
/
400
&&
!
(
x
==
0
&&
y
==
0
))
{
signal_t
[
image_switch_index
(
i
,
image_width
,
image_height
)][
0
]
=
0
;
signal_t
[
image_switch_index
(
i
,
image_width
,
image_height
)][
1
]
=
0
;
}
}
for
(
long
i
=
0
;
i
<
image_length
;
i
++
)
{
result_data
[
i
]
=
own_abs_2
(
signal_t
[
image_switch_index
(
i
,
image_width
,
image_height
)])
/
image_length
;
}
writepng
(
"Images/check_highpass.png"
,
result_data
,
image_width
,
image_height
);
for
(
long
i
=
0
;
i
<
image_length
;
i
++
)
{
result_data
[
i
]
=
d2uc_converter
(
own_abs_2
(
signal_t
[
image_switch_index
(
i
,
image_width
,
image_height
)])
/
image_length
);
}
writepng
(
"Images/check_highpass_scaled.png"
,
result_data
,
image_width
,
image_height
);
fftw_execute
(
backward_plan
);
for
(
long
i
=
0
;
i
<
image_length
;
i
++
)
{
result_data
[
i
]
=
d2uc_converter
(
own_abs_2
(
signal_s
[
i
])
/
image_length
/
image_length
);
}
writepng
(
"Images/result_highpass.png"
,
result_data
,
image_width
,
image_height
);
writepng
(
"Images/result.png"
,
result_data
,
image_width
,
image_height
);
delete
[]
result_data
;
free
(
image_data
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment