Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SingleImageFourierTransform
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
Container 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
Robin Stampa
SingleImageFourierTransform
Commits
bccae99b
Commit
bccae99b
authored
4 years ago
by
Robin Stampa
Browse files
Options
Downloads
Patches
Plain Diff
lowpass/highpass feature added
parent
d5e4a723
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Images/check.png
+0
-0
0 additions, 0 deletions
Images/check.png
Images/input.png
+0
-0
0 additions, 0 deletions
Images/input.png
Images/result.png
+0
-0
0 additions, 0 deletions
Images/result.png
SingleImageFourierTransform.cpp
+84
-17
84 additions, 17 deletions
SingleImageFourierTransform.cpp
with
84 additions
and
17 deletions
Images/check.png
deleted
100644 → 0
+
0
−
0
View file @
d5e4a723
9.93 KiB
This diff is collapsed.
Click to expand it.
Images/input.png
+
0
−
0
View replaced file @
d5e4a723
View file @
bccae99b
75.6 KiB
|
W:
|
H:
956 KiB
|
W:
|
H:
2-up
Swipe
Onion skin
This diff is collapsed.
Click to expand it.
Images/result.png
deleted
100644 → 0
+
0
−
0
View file @
d5e4a723
8.48 KiB
This diff is collapsed.
Click to expand it.
SingleImageFourierTransform.cpp
+
84
−
17
View file @
bccae99b
...
...
@@ -70,7 +70,7 @@ int main()
int
phase_ERR
=
0
;
long
phase_width
;
long
phase_height
;
unsigned
char
*
phase_data
=
readpng
(
"Images/input.png"
,
&
phase_ERR
,
&
phase_width
,
&
phase_height
);
unsigned
char
*
phase_data
=
readpng
(
"Images/input
_phase
.png"
,
&
phase_ERR
,
&
phase_width
,
&
phase_height
);
if
(
!
phase_data
)
{
bAmplitudeWithPhase
=
false
;
...
...
@@ -102,42 +102,109 @@ int main()
}
fftw_execute
(
forward_plan
);
unsigned
char
*
result_data
=
new
unsigned
char
[
image_length
];
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_before.png"
,
result_data
,
image_width
,
image_height
);
//find maximum
double
max
=
0
;
for
(
long
i
=
0
;
i
<
image_length
;
i
++
)
{
if
(
max
<
own_abs_2
(
signal_t
[
i
])
/
image_length
&&
i
!=
0
)
max
=
own_abs_2
(
signal_t
[
i
])
/
image_length
;
result_data
[
i
]
=
d2uc_converter
(
own_abs_2
(
signal_t
[
image_switch_index
(
i
,
image_width
,
image_height
)])
/
image_length
);
}
writepng
(
"Images/check_before_scaled.png"
,
result_data
,
image_width
,
image_height
);
unsigned
char
*
result_data
=
new
unsigned
char
[
image_length
];
// --------------------------- LOWPASS
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*255/max;
//result_data[i] = d2uc_converter(own_abs_2(signal_t[image_switch_index(i, image_width, image_height)]) / image_length);
result_data
[
i
]
=
own_abs_2
(
signal_t
[
image_switch_index
(
i
,
image_width
,
image_height
)])
/
image_length
;
if
(
result_data
[
i
]
>
0
&&
false
)
printf
(
"%d at %d, %d
\n
"
,
result_data
[
i
],
i
%
image_width
,
i
/
image_width
);
}
writepng
(
"Images/
result
.png"
,
result_data
,
image_width
,
image_height
);
writepng
(
"Images/
check_lowpass
.png"
,
result_data
,
image_width
,
image_height
);
for
(
long
i
=
0
;
i
<
image_length
;
i
++
)
{
own_polar_to_kart
(
signal_t
[
image_switch_index
(
i
,
image_width
,
image_height
)]
,
sqrt
(
result_data
[
i
]),
own_arg
(
signal_t
[
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
);
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
);
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/
check
.png"
,
result_data
,
image_width
,
image_height
);
writepng
(
"Images/
result_highpass
.png"
,
result_data
,
image_width
,
image_height
);
//delete[] result_data;
delete
[]
result_data
;
free
(
image_data
);
free
(
phase_data
);
delete
[]
signal_s
;
delete
[]
signal_t
;
return
0
;
...
...
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