Skip to content
Snippets Groups Projects
Commit 09cf730b authored by Robin Stampa's avatar Robin Stampa
Browse files

Completed

parent bccae99b
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment