Thanks to all. The displacement map optimization, making a 1xheight DM and replicating it to widthxheight, reduced the processing time from 504 seconds to 66 for real-world images.
For those who are interested, the modified Makefile fragment is
time sndfile-spectrogram --dyn-range=$(DYN_RANGE ...
Search found 13 matches
- 2012-09-07T12:03:54-07:00
- Forum: Users
- Topic: How to perform logarithmic distortion on one axis
- Replies: 16
- Views: 17280
- 2012-08-14T06:45:27-07:00
- Forum: Users
- Topic: How to perform logarithmic distortion on one axis
- Replies: 16
- Views: 17280
Re: How to perform logarithmic distortion on one axis
convert -size $(WIDTH)x$(LOG_HEIGHT) xc: pattern.png \
-virtual-pixel White \
-interpolate NearestNeighbor \
-fx "freq = $(MIN_FREQ_OUT) * pow($(MAX_FREQ_OUT) / $(MIN_FREQ_OUT), ($(MAX_Y_OUT) - j) / $(MAX_Y_OUT)); \
yy = $(MAX_Y_IN) - freq * $(MAX_Y_IN) / $(MAX_FREQ_IN); \
v.p{i,yy ...
- 2012-08-14T06:40:33-07:00
- Forum: Users
- Topic: How to perform logarithmic distortion on one axis
- Replies: 16
- Views: 17280
Re: How to perform logarithmic distortion on one axis
Yes. log(freq-50) goes to log(0), not log(1).
I'll spare you the workings, but this seems to be the correct reverse mapping:
y_in = (((exp(y_out / max_y_out) - 1) / (base - 1)) * (max_freq_out - min_freq_out) + min_freq_out) * max_y_in / max_freq_in
for which a test run from 0 to 1023 step 93 ...
I'll spare you the workings, but this seems to be the correct reverse mapping:
y_in = (((exp(y_out / max_y_out) - 1) / (base - 1)) * (max_freq_out - min_freq_out) + min_freq_out) * max_y_in / max_freq_in
for which a test run from 0 to 1023 step 93 ...
- 2012-08-13T15:14:59-07:00
- Forum: Users
- Topic: How to perform logarithmic distortion on one axis
- Replies: 16
- Views: 17280
Re: How to perform logarithmic distortion on one axis
Oh. I just tried that:
$ cat >> logaxis.c << \EOF
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
main(int argc, char **argv)
{
int max_freq_in = 22050;
int max_y_in = 8191;
double min_freq_out = 50;
double max_freq_out = 3150;
int max_y_out = 1024;
int y;
printf(" Out In\n ...
$ cat >> logaxis.c << \EOF
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
main(int argc, char **argv)
{
int max_freq_in = 22050;
int max_y_in = 8191;
double min_freq_out = 50;
double max_freq_out = 3150;
int max_y_out = 1024;
int y;
printf(" Out In\n ...
- 2012-08-13T14:45:31-07:00
- Forum: Users
- Topic: How to perform logarithmic distortion on one axis
- Replies: 16
- Views: 17280
Re: How to perform logarithmic distortion on one axis
[quote="martinwguy"]i.e. to map from input pixel coords to output pixel coords it would be
Inlining freq and rearranging that...
y_out = log(((y_in * max_freq_in / y_max_in) - 50) * base / (3150 - 50)) * y_max_out
exp(y_out / y_max_out) = ((y_in * max_freq_in / y_max_in) - 50) * base / (3150 - 50 ...
Inlining freq and rearranging that...
y_out = log(((y_in * max_freq_in / y_max_in) - 50) * base / (3150 - 50)) * y_max_out
exp(y_out / y_max_out) = ((y_in * max_freq_in / y_max_in) - 50) * base / (3150 - 50 ...
- 2012-08-13T09:28:10-07:00
- Forum: Users
- Topic: How to perform logarithmic distortion on one axis
- Replies: 16
- Views: 17280
Re: How to perform logarithmic distortion on one axis
i.e. to map from input pixel coords to output pixel coords it would be
freq = y_in * max_freq_in / y_max_in
if freq < 50 or freq > 3150 skip
y_out = log((freq - 50) * base / (3150 - 50)) * y_max_out
?
freq = y_in * max_freq_in / y_max_in
if freq < 50 or freq > 3150 skip
y_out = log((freq - 50) * base / (3150 - 50)) * y_max_out
?
- 2012-08-13T09:23:57-07:00
- Forum: Users
- Topic: How to perform logarithmic distortion on one axis
- Replies: 16
- Views: 17280
Re: How to perform logarithmic distortion on one axis
ok, (50 gives 1 and 3150 gives base) logs to 0..1
try
(freq - 50) * base / (3150 - 50)
when freq == 50, this gives 0
when freq == 3150, this gives base * (3150 - 50) / (3150 - 50)
(3150 - 50) / (3150 - 50) = 1 so that times base gives base.
Does that sound right?
try
(freq - 50) * base / (3150 - 50)
when freq == 50, this gives 0
when freq == 3150, this gives base * (3150 - 50) / (3150 - 50)
(3150 - 50) / (3150 - 50) = 1 so that times base gives base.
Does that sound right?
- 2012-08-13T09:11:45-07:00
- Forum: Users
- Topic: How to perform logarithmic distortion on one axis
- Replies: 16
- Views: 17280
Re: How to perform logarithmic distortion on one axis
> y_out = (log(freq/50)/log(base * freq/3150)) {gives 0..1
this was also garbage. the top of the division is 0 at f=50 and the bottom is 1.0 at f=3150, but the result of the division is eomething else.
flail, flail
this was also garbage. the top of the division is 0 at f=50 and the bottom is 1.0 at f=3150, but the result of the division is eomething else.
flail, flail
- 2012-08-13T09:08:14-07:00
- Forum: Users
- Topic: How to perform logarithmic distortion on one axis
- Replies: 16
- Views: 17280
Re: How to perform logarithmic distortion on one axis
> going from pixel 0 to pixel y_max_out, each step should add (log(freq/50)/log()/y_max_out
This was garbage, please ignore
M
This was garbage, please ignore
M
- 2012-08-13T09:06:27-07:00
- Forum: Users
- Topic: How to perform logarithmic distortion on one axis
- Replies: 16
- Views: 17280
Re: How to perform logarithmic distortion on one axis
OK, the math is this:
the input is a borderless WxH spectrogram as per above, where the vertical axis represents from 0 to 22500Hz linearly.
the output should have a logarithmic vertical axis from 50Hz to 3150 (well, log_min and log_max, let's say, and min_freq_in and max_freq_in for those others ...
the input is a borderless WxH spectrogram as per above, where the vertical axis represents from 0 to 22500Hz linearly.
the output should have a logarithmic vertical axis from 50Hz to 3150 (well, log_min and log_max, let's say, and min_freq_in and max_freq_in for those others ...
- 2012-08-13T07:31:13-07:00
- Forum: Users
- Topic: How to perform logarithmic distortion on one axis
- Replies: 16
- Views: 17280
Re: How to perform logarithmic distortion on one axis
Thanks. I'm still deciding whether it's best to do this or modify the spectrogram program, which already has an unimplemented --log-freq option.
But I'll take your idea into account. I had wondered if such a thing were doable, having seen passing references to it in the docs
Cheers, I'll let you ...
But I'll take your idea into account. I had wondered if such a thing were doable, having seen passing references to it in the docs
Cheers, I'll let you ...
- 2012-07-23T11:26:21-07:00
- Forum: Users
- Topic: How to perform logarithmic distortion on one axis
- Replies: 16
- Views: 17280
Re: How to perform logarithmic distortion on one axis
Many thanks for the reply and pointers into the docs.
The x axis of the spectrogram represents time progressing through the piece of music (2m56s or 176 seconds in the example image) and the y axis is frequency from 0 (at the bottom) to 22050Hz (at the top) while the brightness of each pixel in any ...
The x axis of the spectrogram represents time progressing through the piece of music (2m56s or 176 seconds in the example image) and the y axis is frequency from 0 (at the bottom) to 22050Hz (at the top) while the brightness of each pixel in any ...
- 2012-07-22T08:25:03-07:00
- Forum: Users
- Topic: How to perform logarithmic distortion on one axis
- Replies: 16
- Views: 17280
How to perform logarithmic distortion on one axis
Hi!
Can anyone suggest how to perform the following distortion with IM?
I have a spectrogram of a piece of music (produced by sndfile-spectrogram) that has a linear frequency axis, which means that adjacent semitones are close and closer together as you go into the bass range, while the top half ...
Can anyone suggest how to perform the following distortion with IM?
I have a spectrogram of a piece of music (produced by sndfile-spectrogram) that has a linear frequency axis, which means that adjacent semitones are close and closer together as you go into the bass range, while the top half ...