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
bccae99b
Commit
bccae99b
authored
Oct 08, 2020
by
Robin Stampa
Browse files
lowpass/highpass feature added
parent
d5e4a723
Changes
4
Hide whitespace changes
Inline
Side-by-side
Images/check.png
deleted
100644 → 0
View file @
d5e4a723
9.93 KB
Images/input.png
View replaced file @
d5e4a723
View file @
bccae99b
75.6 KB
|
W:
|
H:
956 KB
|
W:
|
H:
2-up
Swipe
Onion skin
Images/result.png
deleted
100644 → 0
View file @
d5e4a723
8.48 KB
SingleImageFourierTransform.cpp
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
;
...
...
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