Commit bccae99b authored by Robin Stampa's avatar Robin Stampa
Browse files

lowpass/highpass feature added

parent d5e4a723
Images/input.png

75.6 KB | W: | H:

Images/input.png

956 KB | W: | H:

Images/input.png
Images/input.png
Images/input.png
Images/input.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment