texts: Ripple in a SciPy Butterworth SOS Filter

texts:
I have a script using SciPy for checking the RMS of various Butterworth Bandpass Filters of varying orders.
I would expect the RMS values to increase and decrease linearly and consistently as you get closer and further from the passband, but this is not what happens at all. The RMS fluctuates dependent on the frequency, for instance, in the example below, 162Hz has a much higher RMS than 158, despite 162 being further from the high-pass cut-off of 133Hz. This appears to be a cyclical pattern, and independent of the order, but I am not good enough with matplotlib to create a pretty chart that visually represents this issue. The exact cycle also appears to be very dependent on the buffer size.
I am using https://www.szynalski.com/tone-generator/ to test tones, and here is my code:
import numpy as np
import scipy.signal
import pyaudio

def normalize(block):
    array = np.frombuffer(block, dtype=np.float32)
    return array

def get_rms(samples: np.array) -> float:
    """Get the RMS of an array of audio samples

    Args:
        samples: the samples to get the RMS from

    Returns:
        float: the RMS
    """
    samples_array = np.array(samples)
    return np.sqrt(np.mean(samples_array ** 2))  # type:ignore

def design_filter(lowcut, highcut, fs, order=3):
    nyq = 0.5 * fs
    low = lowcut / nyq
    high = highcut / nyq
    sos = scipy.signal.butter(order, [low, high], btype="band", output="sos")
    return sos

def main():
    sample_rate = 44100
    buffer_size = 2048

    filters = {}
    for i in range(10):
        sos = design_filter(101, 133, sample_rate, i)
        zi = scipy.signal.sosfilt_zi(sos)
        filters[i] = [sos, zi]

    stream = pyaudio.PyAudio().open(
        format=pyaudio.paFloat32,
        channels=1,
        rate=sample_rate,
        input=True,
        frames_per_buffer=buffer_size,
    )

    update_every = 3
    update = 0
    while True:
        block = stream.read(buffer_size)

        if update_every == update:
            update = 0
            samples = normalize(block)

            # blank out terminal
            print(chr(27) + "[2J")
            # move cursor to to left
            print(chr(27) + "[1;1f")

            print("rms")
            print(int(get_rms(samples) * 200) * "-")

            for order, tup in filters.items():
                print(f"Order: {order}")
                bandpass_samples, zi = scipy.signal.sosfilt(tup[0], samples, zi=tup[1])
                tup[1] = zi.copy()
                print(int(get_rms(bandpass_samples) * 200) * "-")
        else:
            update += 1

if __name__ == "__main__":
    main()

UPDATE
After looking at some more examples and messing with my code, it appears that it is more related to the buffer size than I initially thought.
If buffer_size == sample_rate the ripple (?, oscillation? noise?) does not happen at all (this is wrong, see below). Also, there is seemingly a relationship between factors of buffer_size and sample_rate that relates to the division. Not sure why this is, and I am able to work around it, but if anyone knows why this happens it would be good to know, for sure.
UPDATE 2
It appears that the above is incorrect. There is some transient noise that appears every period. Having a larger period decreases the relative impact of that noise, but it does not eliminate it, and it does not allow for a work around of the issue by increasing the buffer size and then chopping up the filter output later to get the granularity back.


texts: OpenCV: Problem at creating a Skeleton of Lines

texts:
I need to get the lines from a photographie of a sheet of paper. While recherching, I came along this, where one answer referred to this blog entry.
Now I am having trouble with this approach. I have implemented it as follows (with the c++-interface of OpenCV:

// the image has to be grayscale
if (image.channels() != 1)
{
    cv::cvtColor(image, image, cv::COLOR_BGR2GRAY);
}

// we need to enhance the lighting before we can threshold the photography
cv::equalizeHist(image, image);
// a binary image is needed
cv::threshold(image, image, threshold, 255, cv::THRESH_BINARY);
cv::imwrite("thresholdedImage.jpg", image);

// the resulting skeleton
cv::Mat skeleton(image.size(), CV_8UC1, cv::Scalar(0,0,0));
// needed if in-place processing is not possible
cv::Mat temp(image.size(), CV_8UC1);
// eroded image is saved here
cv::Mat eroded;
// needed for morphological transforms (erodation, dilation)
cv::Mat element = cv::getStructuringElement(cv::MORPH_CROSS, cv::Size(3,3));

bool done = true;
int i = 0;
while(done)
{
    // eroding + dilating = opening
    cv::erode(image, eroded, element);
    cv::dilate(eroded, temp, element);
    cv::subtract(image, temp, temp);
    cv::bitwise_or(skeleton, temp, skeleton);
    eroded.copyTo(image);

    done = (cv::countNonZero(image) == 0);
    ++i;
}

For proof of concept, I decide to use a computer-made drawing for testing purposes, to eliminate issues with lighting at this early stage. This can be seen here:

The threshold is correct, but unfortunately the skeleton looks very strange:

I have drawn the skeleton after 100 iterations, where it looked like this:

Do you have any suggestions?


texts: How to find phase difference between 2 signals, one has an unknown function

texts:
I have a system that is forced by a sinusoidal function with specific amplitude, phase and frequency ( all these are known ahead of time). I get a deformation of sinusoidal form as well (think of a damped harmonic response), and I would like to find the phase lag. I was advised to use correlation but I don't have the function that produces the response, only gathered data. This what I am doing but honestly I am not confident in my findings:

    y =[] %this is the gathered data, first column is time, second is deformation
    frequency =1000; %Hz,i know this for a fact
    t=y(:,1);        %just getting the time to produce a sine wave for calibrating

    fs =  14*frequency; %this is random, i m just making sure i m above 2*frequency.
    Nfft = fs ;

    sine_wave = 1+sin(2*pi*frequency*t + pi/2);%I need to 1 + for physical reasons

    FFT_sine_wave =fft(sine_wave,Nfft)/Nfft; %FFT of sine_wave
    FFT_Y2 =fft(y(:,2),Nfft)/Nfft;           %FFT of response

    magsine_wave = abs(FFT_sine_wave);       %magnitude of sine_wave
    magY2 = abs(FFT_Y2);                     %magnitude of response

    f=linspace(-fs/2, fs/2, Nfft);           %frequency vector

   [old_max_sine_wave index_sine_wave] = max(magsine_wave);
   magsine_wave(index_sine_wave) = -Inf;  %getting rid of the DC offset

    [old_max_Y2 index_Y2] = max(magY2);
    magY2(index_Y2) = -Inf;

    [maxAmp_sine_wave index_sine_wave] = max(magsine_wave); %Finding new amplitudes
    [maxAmp_Y2 index_Y2] = max(magY2);

    new_ang = angle(FFT_sine_wave);    %getting the angles of sin wave

    ang_miew = new_ang(8002)*(180/pi)+180 % 8002 is where f = 1000 Hz falls in frequency
                                          %vector, so i use the index to find angle

    amp_miew = 2*abs(FFT_sine_wave(index_sine_wave)) %this gives me the correct amplitude

     new_angY2 = angle(FFT_Y2)*(180/pi);  %same reasoning as above
     ang_miewY2 = new_angY2(8002)+180

Please help me out, if any of you need the y vector that gives the time and deformation please let me know. I am in dire need of help!
Thank you in advance


texts: reconstructing time-stretched signals for filtering purposes

texts:
I would like to know if it's possible to reconstruct the original time domain signal from it's time-stretched version? Is there any algorithm out there that can do this? Python, Matlab, etc?

I want to isolate certain sound events in the signal, however, the events are really close together, that it's hard to filter. A solution that I had in mind was to stretch the signal, filter this time-stretched signal and then reconstruct back by back stretching using inverse stretching factor to get the original length.

The algorithm will of course have to keep the correct pitch at all times. Is this possible or not?


texts:
I am trying to implement a karaoke scoring algorithm and, for a particular song, have the note information (done by a professional) that indicates what note occurs in which part of the lyric.

When I use a pitch detector and plot the pitch values for the portion of the lyric where a single note is held, the pitch varies a lot in the beginning (for the first few pitch values), hits a steady value (that roughly corresponds with the note that needs to be sung) and again shows a lot of variation before it transitions to the next note. I want to derive a single pitch value that is representative of the pitch value when the note is held steadily.

How do I go about it? Is this a problem of pitch smoothing (median)?

I am using a pitch algorithm based on the G.729 pitch detector with a pitch smoothing algorithm that seems to work really well (so far) on speech and on male singers singing in the presence of background music (very low volume).


texts: Recording square waves at sample frequency

texts:
For a project I am working on, I need to incorporate GPS data into an audio file. As things currently are, the easiest way for me is to record the audio in a multi-channel .wav file, and add the GPS data as a square wave in a separate channel.
GPS data will be binary, i.e. either an arbitrary high or low signal for an arbitrary time period. I do not need to reconstruct an analog value.
My question is: at which frequency will I be able to faithfully record a square wave, >= Nyquist frequency or >= the sampling frequency?
Edit: elaborating on the setup I have in mind
I am preparing a series of binaural recordings of me walking around town in hours nobody is around. A modified headphone will act as two separate microphones, going into two separate channels of a handheld recorder.
I will use my cellphone as a GPS device. My idea is to translate that GPS data into a series of pulses and output it to the phones' jack, which I then will connect to the handheld recorder. I prefer to have this data on a separate audio channel, because I like to keep the recorded audio as clean as possible, and because extracting data embedded in audio channels is beyond my capabilities at the moment.
This is what I came up with (note: this is a mock-up)

As both encoding and decoding the GPS data is going to be a custom job, i have a lot of liberty in writing the 'protocol'.
Again, what is the fastest rate at which i could toggle the data signal? Is it the sampling frequency of the audio file, because I am only interested in a binary representation? Or am I missing something very obvious? Bear in mind, this is my first step in signal processing.


texts: state space formulation of a sinusoidal system

texts:
Let $f=A\sin{\omega t}=x_1$ and $\dot{f}=A\omega\cos{\omega t}=\dot{x}_1=x_2$. Let the output be $y=cA\omega$, where $c=1$ is a constant. I want to represent this in a state space formulation:

$\dot{x}=\underline{A}x+\underline{B}u$

$y=\underline{C}x+\underline{D}u$

What will $C$ be? I tried: $A\omega=\frac{A}{t}\arcsin{\frac{x_1}{A}}$, but does this make sense? Another possibility is $A\omega=\frac{-x_2}{\cos{\omega t}}$. Which one should I choose?


texts: Examples where non-linear phase filters are used

texts:
I stumbled apon this old question:
Why is a linear phase important?

There the explanation of why linear-phase processing (filtering) is important is very clear. Also the effects on waveforms due to linear and non-linear phase processing are very well illustrated. My question is the following: why then would someone use non-linear phase filters at all? Can someone give examples where one does not care at all about phase? Are there any advantages in using non-linear phase filters and why is not everybody using only linear-phase signal processing?


texts: Is sampling a Fourier transformed signal and fourier transforming a sampled signal the same?

texts:
I'm having a hard time understanding an assignment that states:

  Draw the complex spectrum of the sampled signal $f(t)$ (periodic and continuous). Do this, by first calculating the Fourier transformation and sample it afterwards by multiplying with the impulse train.

The way I understand it, I need to calculate $$\begin{equation*} \mathcal{F}\left[f(t) \cdot \sum_{k=-\infty}^{\infty}\delta(t-kT)\right]
\end{equation*}$$
however the second sentence suggests this is the same as
$$\mathcal{F}[f(t)] \cdot \sum_{k=-\infty}^{\infty}\delta(t-kT)
$$
However, Wikipedia says this is not the case and instead suggests
$$\begin{equation*}\mathcal{F}\left[f(t) \cdot \sum_{k=-\infty}^{\infty}\delta(t-kT)\right] = \mathcal{F}[f(t)] *\left[\frac{1}{T} \cdot \sum_{k=-\infty}^{\infty}\delta\left(t-\frac{k}{T}\right)\right]
\end{equation*}$$
are maybe both formulas correct? and how do I draw a complex spectrum? is it 3D?


texts:
I have an SDR receiver I'm interested in making into a FMCW radar. The bandwidth is somewhat narrow as it only samples at 64 MSPS.

There is a problem in that without a bunch of embedded programming the RX and TX chains won't have their timing synchronized. Basically the up-conversion oscillator is synchronized but the DSP portion on the TX and RX lines won't be.

What I'm wondering is, is there a way to use the initial signal sent from the transmitter and received by the receiver through direct LOS to establish timing offset for the reflected signal? Given that the RX and TX antenna will be close together you could use this to synchronize the system.

Also I'm not sure what the processing would consist of though(or if it's even viable), most FMCW radar mix the transmitting signal with the reflected signal and then downconvert to produce to a local beat. I would be attempting to do this through DSP and have a much narrower bandwidth useable.


texts: Determining the mean of of a sampled signal (improvements to time averaging method)

texts:
I am sampling a signal at 1kHz, which is essentially a single-frequency sinusoid with a DC offset (and a small amount of noise). I don't know the precise frequency of the sinusoid (it is at most 10Hz), and I want to record the mean value of the signal.

Currently I take samples for an arbitrary number of seconds and find the average value (with a longer sample time corresponding to a lower error value, clearly):

$$
\langle x \rangle = \frac{1}{N} \sum_{i=0}^N x_i
$$

I feel like there should be a better way to do this, however, given that I know something about the form of the signal (namely, it consists of a single-frequency sine wave). If I could determine the frequency, then averaging over a complete number of periods would be an improvement.

Using a FFT to find the frequency seems to be tricky though, since (as far as I can tell) the discrete fourier transform will yield values that are periodic in the frequency domain (ie. the discrete frequencies returned are $ f =i \times f_s \mathbin{/} N$, where $ f_s $ is the sampling frequency; $ f $ is thus always periodic within the $ N $ samples I've measured).

Can anyone suggest a good way to do this - either via FFT, or a better method of mean-determination?


texts:
I am trying to understand where does the convolution fit in Discrete Fourier Transform. I know that convolution is producing a third signal from two other signals. I also know that DFT transforms one signal from time to frequency domain.

So, what is the relationship between the two (if any)?


texts: Do we have aliasing with this chip rate and transmission bandwidth

texts:
A particular communication system I came across defines chip time to be 0.57 ns and consequently chip rate is 1760 MHz.

The transmission bandwidth is 2.16 GHz.

I am wondering, do we suspect to have aliasing? Given the fact that the chip rate is smaller than the bandwidth of transmission? In other words shouldnt the sampling rate (which I assume is 1760 MHz) be at least greater than 2.16 GHz so as to prevent aliasing?

Thanks


texts: What is the Implementation of a Low, Mid or High Tone Dodge or Burn in GIMP?

texts:
In The GIMP, and also in photoshop, you have the DODGE/BURN tool to enhance colors in shaded or highlighted regions, which would otherwise be blackish or whiteish. I found empirically that this filter is a good preprocessing step for a computer vision task I am implementing.

I found here that there are 6 formulas which simply map RGB values to other RGB values independently of channel or pixel location. According to the link the transformation is y=x+0.25*sin(x) for midtone dodging.

However, I could not verify this with the gimp source code, an excerpt from gimpoperationdodgemode.c:

gboolean
gimp_operation_dodge_mode_process_pixels (gfloat              *in,
                                      gfloat              *layer,
                                      gfloat              *mask,
                                      gfloat              *out,
                                      gfloat               opacity,
                                      glong                samples,
                                      const GeglRectangle *roi,
                                      gint                 level)
{
  const gboolean has_mask = mask != NULL;

  while (samples--)
    {
      gfloat comp_alpha, new_alpha;

      comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
      if (has_mask)
    comp_alpha *= *mask;

      new_alpha = in[ALPHA] + (1.0 - in[ALPHA]) * comp_alpha;

      if (comp_alpha && new_alpha)
    {
      gint   b;
      gfloat ratio = comp_alpha / new_alpha;

      for (b = RED; b < ALPHA; b++)
        {
          gfloat comp = in[b] / (1.0 - layer[b]);
          comp = MIN (comp, 1.0);

          out[b] = comp * ratio + in[b] * (1.0 - ratio);
        }
    }
      else
    {
      gint b;

      for (b = RED; b < ALPHA; b++)
        {
          out[b] = in[b];
        }
    }

      out[ALPHA] = in[ALPHA];

      in    += 4;
      layer += 4;
      out   += 4;

      if (has_mask)
    mask++;
    }

  return TRUE;
}

The essence of the code would boil down to these two lines. The other code is for handling transparency of the brush and iterating over pixels and color channels.

gfloat comp = in[b] / (1.0 - layer[b]);
comp = MIN (comp, 1.0);

Suggesting a general formula for all tones and both burn and dodge of  y = x / (1- f(x)). I could not trace the value of layer[b] back to anything sensible, and hence do not know what f(x) is supposed to be.

Moreover, the Wikipedia page on dodge and burn, and general pages about tone mapping, only mention the principle, but not any formulas.

Are there different definitions of dodge and burn filters? What is the definition, in the form of a formula y=g(x), of the gimp tool?


texts: How to apply low-pass filter to an I/Q signal to get baseband signal?

texts:
Can anyone help me with the demodulation technique of a modulated signal? I mixed it with I/Q signal. But I am very confused about low-pass filtering. I am trying to apply a low-pass filter, but I am not getting the baseband signal. What kind of filter can I use to get demodulated baseband signal?

My carrier frequency is $f_c=1 \ \mathrm{GHz}$ and my sampling frequency is $f_s=10 \ \mathrm{GHz}$.


texts: Why I get another spectrum when upconvert an o-qpsk baseband signal with a bladerf compared to a hackrf device?

texts:
I have just start working with bladerf instead of former used hackrf hardware and I need to solve a problem. Currently I use the following bladerf hardware, libraries and firmware:
bladerf (2.0 micro xA9)
libbladeRF version:         2.2.0-2018.12-rc3-2-ppabionic
Firmware version:           2.3.2
FPGA version:               0.10.2 (configured by USB host)
I tried to simply upconvert an oqpsk baseband at 1100 MHz (4 Msps) with bladerf device using
gnuradio (GRC 3.711) block osmocom-sink and I got a unexpected and pretty wierd baseband spectrum compared to hackrf hardware.
For better understanding, I have attached some hardcopies:

From my point of view, I made identical setups for hackrf and bladerf device on osmocom-sink block. Later on downconverting and demodulation works very well with hackrf hardware, with bladerf device it totaly fails.
Any suggestions, I need to check or I just made wrong ? May I need to calibrate the bladerf hardware first for proper baseband processing ?
Many thanks in advance.
Best regards
calenberger


texts: Alternative function for MatLab iztrans to Octave?

texts:
I am trying to compute the reverse Z transform on Ocatve and I get the following error:
error: 'iztrans' undefined near line 1, column 1
The code I am running is the following:
syms z
F = z % Some function implementation
iztrans(F)


texts: From a 44kHz audio signal, how could I extract 32 evenly spaced frequency bands?

texts: Assume I have an array of floating points that contain the last 8192 samples played. How would I convert that array to 32 frequency bins that are spaced from 0Hz - Nqyst?


texts: Discrete Time Fourier Transform Pair Discrepancy

texts:
When taking the DTFT of a discrete-time signal $x[n]=a \times u[n]$, the book "Signals and Systems" by Chi-Tsong Chen claims that the result is $\frac 1 {1-a \cdot e^{-j \cdot \omega \cdot T}}$; however, many other sources claim the DTFT is $\frac 1 {1-a \cdot e^{-j \cdot \omega}}$ without the T term.

The book I have states that $x[n]=x(nT)$ by definition and the DTFT by definition is

$$X(\omega)= \sum_{n=-\infty}^{+\infty}x(nT)e^{-j \omega n T}$$.

Can someone explain the reason for the differences?

Thank you for your time.


texts: BandPass and StopBand FIR filters (Hamming) is not working

texts:
I have two groups of 3 frequencies of tone (music),
First Group

Tones: 39 (77.7817 Hz), 40 (82.4069 Hz) and 41 (87.3070 Hz).

Second Group

Tones: 83 (987.7666 Hz), 84 (1046.5022 Hz) and 85 (1108.7305 Hz).

These groups work independently (the frequencies aren't mixed between them)

ToneB: Tone Back  39 or 83
ToneH: Tone Half  40 or 84
ToneF: Tone Fore  41 or 85

ToneB < ToneM < ToneF

I made two WAV files combining these 3 frequencies (one for the first group, and one for the second group).
I want to filter them:

Low Pass (Allowing ToneB, Denying ToneB and ToneF)
High Pass (Allowing ToneF, Denying ToneB and ToneB)
Band Pass (Allowing ToneB, Denying ToneB and ToneF)
Band Stop (Denying ToneB, Allowing ToneB and ToneF)

The Tones are separates by Math.Pow(2,1/12) // or 2^(1/12)

ToneF = ToneH*Math.Pow(2,1/12)
ToneB = ToneH*Math.Pow(2,-1/12)

Now I decided that the Cut Frequencies are established by Math.Pow(2,1/24)

First Group

Then CutFreq between Tone39 and Tone40 is 80.060925 Hz
Then CutFreq between Tone40 and Tone41 is 84.821595 Hz

Second Group

Then CutFreq between Tone83 and Tone84 is 1016.710373 Hz
Then CutFreq between Tone84 and Tone85 is 1077.167118 Hz

If N is Order (or lenght) of Hdn(): Impulse Response
But making subtraction, the N Between (ToneB and ToneH) would be different to the N Between (ToneH and ToneF).

                   |------------- dDelta ------------|
                   |                                 |
 Fa                |               Fc                |               Fb
  |----------------|----------------|----------------|----------------|

  |                |                |                |                |
  0               1/48             1/24             3/48             1/12
  |                |                |                |                |
-1/12            -3/48            -1/24            -1/48              0

According to this:

Fc = Fa*Math.Pow(2,1/24)    or    Fc = Fb*Math.Pow(2,-1/24)

Now to calculate N, I will use Hamming Windows:

int SampleRate = 32000;
double dHammingFact = (double)3.3*SampleRate;
double dDeltaFore = Math.pow(2.0, 3.0/48.0) - Math.pow(2.0, 1.0/48.0);
double dDeltaBack = Math.pow(2.0, -1.0/48.0) - Math.pow(2.0,-3.0/48.0);

dDelta can be dDeltaFore or dDeltaBack

Simulating this:

N = RoundUpEven(dHammingFact/(Fc*dDelta))  //Rounding to Ceil Even number

So we have:

First Group

FcLP = ToneB(39)*Math.Pow(2,1/24)   //Low Pass
FcHP = ToneB(41)*Math.Pow(2,-1/24)  //High Pass
FcBPb = ToneB(39)*Math.Pow(2,1/24)   //Band Pass Back
FcBPf = ToneB(41)*Math.Pow(2,-1/24)  //Band Pass Fore
FcBSf = ToneB(39)*Math.Pow(2,1/24)   //Band Stop Back
FcBSf = ToneB(41)*Math.Pow(2,-1/24)  //Band Stop Fore

N(Tone39 and Tone40) = 45669
N(Tone40 and Tone41) = 43107

Second Group

FcLP = ToneB(83)*Math.Pow(2,1/24)   //Low Pass
FcHP = ToneB(85)*Math.Pow(2,-1/24)  //High Pass
FcBPb = ToneB(83)*Math.Pow(2,1/24)   //Band Pass Back
FcBPf = ToneB(85)*Math.Pow(2,-1/24)  //Band Pass Fore
FcBSf = ToneB(83)*Math.Pow(2,1/24)   //Band Stop Back
FcBSf = ToneB(85)*Math.Pow(2,-1/24)  //Band Stop Fore

N(Tone83 and Tone84) = 3597
N(Tone84 and Tone85) = 3395

Obviously, highest N will be used.

my filters works fine for Low Pass Filter, High Pass Filter (First and Second Groups)
But, checking with Pass Band and Stop Band (First and Second Groups) fails...

Now let's go to see the result of FIRST Group:

spectrum wav file with only the three frequencies of the First group

LowPass Filter first group

HighPass Filter first group

BandPass Filter first group

BandStop Filter first group

Now let's go to see the result of SECOND Group:

spectrum wav file with only the three frequencies of the Second group

LowPass Filter second group

HighPass Filter second group

BandPass Filter second group

BandStop Filter second group

How Can I to solve this?
Are very narrow my bands in relation with SamplingFrequency?


texts: Why Are There Two Different Common $ 3 \times 3 $ Kernels for the Laplacian?

texts:
I find both of these 3x3 Laplacian kernels to be commonly used:

 0 -1  0
-1  4 -1
 0 -1  0

and:

-1 -1 -1
-1  8 -1
-1 -1 -1

Is there a reason to choose one or the other? What's the difference between them?

(My math is not good enough to understand the Wikipedia article, so I can't figure it out myself from reading that. Googling is failing me for this one.)


texts:
I am tasked with designing the logic for an automatic gain control. It won't be a traditional AGC in that it has to run on a computer and continuously modifying the volume is not possible in the same way as it is in hardware. It will be more of a "roughly set the input gain for me automatically if it's way off" than an AGC per se. However, I plan to approach the design in the same way.

This will be used primarily for voice/speech, so what I want to do is prevent incoming silence (when the speaker is not speaking) from causing the gain to be set too high. I would like to avoid anything as complex as voice activity detection as well as complex ad-hoc methods that involve deriving more than a few simple parameters -- at least for now.

Are there any simple tricks I can use to to help with this problem, or is the best approach to use full-fledged voice activity detection?


texts: FFT of a $N$-length real sequence via FFT of a $N/2$-length complex sequence

texts:
I am doing FFT. The one way I did is to put real part in one array and the imaginary part as zeros and then calculated the FFT. But this take up lots of resources.
Now I want to calculate FFT by Dividing Real Input by 2 in the form of ODD and EVEN samples and put even in real array and odd in Imaginary array. Then calculate the FFT. But after the FFT calculation how can I combine them to get the same results as I got when I used imaginary as zero's.

Any idea??


texts: Overall system IR: How to do arithmetic with $\delta$ functions?

texts:
When finding the overall system impulse,

how to do arithmetic with $\delta$ functions?

E.g.
\begin{align}
h[n]&=h_1[n]\star h_2[n]\\
&=\sum_{k=-\infty}^{\infty} h_1[k]h_2[n-k]\\
&=\sum_{k=-\infty}^{\infty} \left(2\delta[k-2]-3\delta[k+1])(\delta[n-k-1]+2 \delta[n-k+2]\right)\\
&=\sum_{k=-\infty}^{\infty} (2\delta[k-2]\delta[n-k-1]+2\delta[k-2]2 \delta[n-k+2]-3\delta[k+1]\delta[n-k-1]-3\delta[k+1]2 \delta[n-k+2])
\end{align}

The two middle terms are convolutions. But what about the two other? What to do with them?

Or am I supposed to leave the indices there, rather than evaluating the $\delta$ functions?


texts: Detect marker orientation inside an image

texts:
I've been reading how augmented reality works and how markers are detected. Anyway I can't find any resource that would help me in detecting an arbitrary complex image as, for instance, a book's cover.

I don't think that falls into the "template matching" field since I would also need its orientation to perform AR rendering on it.

What algorithms are used to detect an arbitrarily complex marker into an image and have its transformation extracted as well?


texts: M-point FFT Amplitude of N-samples of a sinusoid

texts:
Suppose you have N samples of a sinusoid of frequency $f_0$.

$$
x[n] = A\sin[2\pi (f_0/f_s)n ]
$$

Suppose you take an M-point FFT (where M may be greater than N) of your N samples of x. What will the amplitude of the peak of the spectrum be?

Reference: http://www.designnews.com/author.asp?section_id=1419&doc_id=236273&print=yes


texts: ADALM-PLUTO SDR with gnuradio on Macbook

texts:
I am looking to interface PlutoSDR with gnuradio on a macbook. I have gnuradio-companion installed, however, plutosdr blocks (source and sink) don't show up in it. Also tried installing iio-oscilloscope but didn't seem to work.
Online help for gnuradio+PlutoSDR+macbook is limited compared to Linux, Windows etc. platforms.
Is there anyone who has successfully made PlutoSDR work with gnuradio or iio-oscilloscope on a macbook? Please outline the steps. Thank you.


texts: How to find the convolution kernel in frequency domain?

texts:
I have a two vectors of spatial data (each about 2000 elements in length). One is a convolved version of the other. I am trying to determine the kernel that would produce such a convolution. I know that I can do this by finding the inverse Fourier transform of the ratio of the Fourier transforms of the output and input vectors. Indeed, when I do this I get more or less the shape I was expecting. However, my kernel vector has the same dimensionality as the two input vectors when in reality the convolution was only using about one fifth (~300-400) of the points. The fact that I am getting the right shape but the wrong number of points makes me think that I am not using the ifft and fft functions quite correctly. It seems like if I were really doing the right thing this should happen naturally. At the moment I am simply doing;

FTInput = fft(in);
FtOutput = fft(out);
kernel = ifft(FtOutput./FTInput).

Is this correct and it's up to me to interpret the output vector correctly or have I oversimplified the task? I'm sure it's the latter, I'm just not sure where.


texts: In pulse code modulation what is pulse word represent?

texts: we study lot of things in PCM we do sampling quantization encoding etc but we never come across pulse so what is pulse word represent in PCM


texts:
I have a signal, in which i want to detect the period of the peaks, that exist within this signal: for example : After each 5mm or (5 seconds depending on the sampling rate and speed of my motor) i have a peak in my motor current.
I though of using the FFT, but then i had some problems with the sampling rate which lead me to look for the ununiform fft, but i wasnt very successfull.
I also tried using the Savitzky golay filter to smooth the data, since i read that it actually helps finding peaks within the signal, but not the period.
I tried appliying the FFT to the smoothed data, but I wasn't able to find any frequence.
So i was wondering is there is an algorithm that detects the periodicity of peaks within a signal.
 this is the Normal Signal plot .

 The signal in display(20mm/s) has been smoothed using the Savitzky golay filter, with a window of 51.


texts: how to deal with signal to make it suitable for kalman filter

texts:
I want to build a navigation system with gyroscope/odemeter and gps. I have konwn there is a famous method called kalman filter for this application. And now, I have done some experiment in matlab with kalman filter to get hide state vector which included vehicle's current postion/velocity/heading etc. But out of my expection, the result is not very good even more bad than origin data which comes from gps. May be you could guess the reason why they are so so bad. Yes, gyroscope and odemeter have uncertained error also as gps, so that's why you use kalman filter to deal with them. In some case that's useful enough.
But in some scenario case that's not working. Because the character of original data can't match with requriment of kalman filter. As I probably know, it suppose that filter works under the condition of which your data noise is white gaussian or some other types. so many artical tell me you must have good knowledge to character of this noise, but on the other hand they don't tell me how to know it. that's just my problem and ask you in here. how to do it and how to deal with it for kalman filter?


texts: Estimating the Variance of Noise Using Median Function Applies on the Gradient of the Image

texts:
By investigating the implemented code of an accepted paper, I encounter with following relation to estimate the variance of noise in an image:

$$ \sigma = \frac{median (|\nabla^hx-median(\nabla^hx)|)}{2*.6745},\tag{1}$$
where $\nabla^h$ compute horizontal derivative of $x$.

I know the variance of some samples can be estimated by $\frac{1}{n}\Sigma_{i=1}^n (x_i-\mu)^2$, but I cannot understand $(1)$ as well as the magic number $.6745$.
Any help will be appreciated.


texts: Possible to get transfer function coefficients from window?

texts:
I am hoping to use scipy.signals.filtfilt() to smooth some signals in Python, and wanted to build the filter based on a window like a hanning window or whatever.  E.g.:
import scipy.signal.windows as windows
window = windows.hann(filter_width)

But standard filters don't just take in windows, they take in numerator and denominator transfer function coefficient arrays a and b:
data_smoothed = scipy.signal.filtfilt(b, a, data_noisy)

Is there a way to calculate the transfer function coefficients a and b from a window? I like filtfilt() more than straight-up convolution with the window because it has a lot of useful features baked in.


texts: I am using WARP V3 board to receive microwave oven leakage. I placed an antenna outside the door of the oven. I plotted a time series absolute received data. The sampling rate of the rx data is 40Mhz. Microwave opeates ar 2.4Ghz centre freq. As plotted, I can see the spikes which are the magnetron emissions. However each magnetron bunch is followed by a random patch of amplified data as u can see the continuous blue plots. I cannot understand what that signifies?


texts: Entropy of enhanced image more than the original image

texts:
It is said that the entropy of an image is the information that it contains. Let us assume, that the entropy of an image f(x,y) is E1. If we enhance f(x,y), we get an enhanced image g(x,y), whose entropy is let us say E2. Now, is $E2 \le E1$ always? According to me, the above relation should always hold true, as how can an enhanced image contain more information than the original image. Also, it is just the count value at each bin of the histogram that changes when a histogram is equalized using certain technique but overall the total count value of all the bins remains same. So $E1 \ge E2$ should always hold true but I have just seent that E2 will be greater than E1 if we enhance the image using CLAHE technique i.e the entropy of the enhanced image will be greater than the original image. I have searched for the explanation and got some interesting links such as
Entropy of an image but none clears my doubt. Kindly give your inputs and explain me where am I getting it wrong. Thanks.

Image used : https://1drv.ms/u/s!ArfYMunvE-HGgbQ5yDBYTj6UfNdWig


texts: Is there a way to see video after applying packet loss

texts: I have encoded a video stream using JM using RTP. Then i have applied rtp_loss on it but after that i am unable to decode video. Like in this example a video with different packet loss percentages are depicted. I want to apply packet loss on H.264 RTP stream than want to decode it. But whenever i want to decode using JM it is unable to handle it. I have heard that Netem could be an option but i am not using Linux. So Is there a way to apply packet loss on video and than see how  video quality is changed after it like in the example link given above?


texts: How to calculate the data rate of IEEE 802.15.4 to be 250kbps?

texts: How to calculate the data rate of IEEE 802.15.4 to be 250 kbps


texts: How to Find Shift Between Two Signals with Cross Correlation?

texts: I have calculated the cross-correlation function between to waveforms. I would like to find the shift between the two waveforms from the peak of the cross-correlation function. I am not really sure how to do that precisely. In this example, I have shifted signal 2 by 1000 Angstroms with respect to signal 1. I want to recover this shift from the CCF.


texts: Non-decaying Harmonics in Vibration Signal

texts:
I am analyzing vibration data collected by an accelerometer positioned in a stamp press machine. The fundamental frequency is around 10 Hz. The problem here is that when I take the FFT of the data I see harmonics of the fundamental frequency until 5000 Hz every 10 Hz (of course). I would expect some visible harmonics in low-frequency but with a decaying behavior until, at some point, it disappears. I attached 2 figures. The first one with a zoom from 0 to 1000 Hz and the other from 4000-5000 hz. Note that the Harmonics dominate the signal.

And here is a sample of the data:

I have being trying to convince myself that is normal but I can´t. What do you guys think? Can it be an effect of something that I should discard?

Thank you!


texts:
I wanted to determine the PDF of a Stochastic Process. I am familiar with the concept of PDF for a Random Variable which maps the outcomes to its probabilities but I am not able to find the PDF of a Random/Stochastic process. I have the solution but it’s pretty hard to visualize it. The solution which I have contains the PDF of the Stochastic process in each time intervals due to its nature.

Below is the stochastic process:

$x^{(l)}(t)= \operatorname{rect}((t-T_o)/T)$

Where To is uniformly distributed in the range
$|T_o|\leq T$

Now I want to determine the PDF of this random process. Hence I split the Random Process in three intervals:

$|t_o|\geq 3T/2$
$|t_o|\leq T/2$
$T/2\leq |t_o|\leq 3T/2$

The reason why its split into three intervals is that based on the condition of $T_o$, the process cannot occur after $3T/2$. And in between $-T/2$ and $T/2$ most of the processes occur and it has a decreasing slope between $T/2$ and $3T/2$.

Proceeding to the PDF, here is what I have as the solution:

Here is what I guess about the plot:

Region 1:

$|t_o|\geq 3T/2$

Here no processes occur and hence probability of 0 (no processes occur is 1). The probability of occurrence is 0.

Region 2:

$|t_o|\leq T/2$

Here most processes occur. But in this region, given the condition, I can change the process as:

$\operatorname{rect}(t-T_o)\leq T/2$

Here I need to choose the values of To so that the shift lies in this region(2). Hence could choose the value 0 till 1. At 1 it goes to region 1. Since I can choose any values between 0 and 1, I can assign each half the probability.

Region 3:

$T/2\leq |t_o|\leq 3T/2$

In this region, I need to choose the value with the probability of:
$(1/4)+(t_o/2T)$ to get zero shift and $(1-((1/4)+(t_o/2T)))$ to get a shift.

I am not quite sure of the above reasoning behind this graph of PDFs based on which I had made the above conclusions in each regions. Do the graphs of the PDFs need to be interpreted in a different way?

If anyone could provide the reasoning behind any one region (region 2 is highlighted) and how to plot the PDF in that region (region 2), I could formulate the others in a similar fashion.


texts: Extended kalman filter for accelerometer data on shaking table

texts: I am using an accelerometer to record the motion of a shake table (a rocking table) which moves forward and backward in one direction. The signal is very noisy and decided to use Extended Kalman Filter. What equation should i use for the model?


texts: Relationship between order of filter and amplitude/phase response

texts:
I am learning about digital filters, for example a lowpass butterworth filter.

In many languages, the implmentation requires specification of the order of the filter, which I believe is the number of terms in the closed form equation that generates each filtered sample, given the original samples and previously generated samples.

What I haven't been able to find (at a sufficiently ELI5 level) is how the order affects the frequency and phase response of the filter.

Does a higher order simply mean a better approximation to the optimal filter with (cutoff, stopband) ? Do higher orders mean different or less severe phase differences?

Finally, I'd assume that it affects performance somewhat as well.


texts: What is the index modulation in OFDM and Subcarrier Index modulation?

texts:
I'm new here, I'd like to ask about the OFDM-IM (OFDM - Index modulation), what is it and how it works?  Is it the same as SIM-OFDM?

I checked white papers, I see it's using the index of sub-carriers for transmitting bit too. But what does it mean by the index of sub-carriers?

Could you please explain it in clear way? or share any article where I can understand it well.

I'm currently trying to understand R. Abu-alhiga and H. Haas, "Subcarrier-index modulation OFDM," 2009 IEEE 20th International Symposium on Personal, Indoor and Mobile Radio Communications, Tokyo, 2009, pp. 177-181.


texts:
How is iterative refinement is applied to the estimate obtained by Lucas-Kanade algorithm? I am familiar with the following steps:

Estimate velocity at each pixel using one iteration of Lucas and Kanade estimation
Warp one image toward the other using the estimated flow field
Refine estimate by repeating the process

I am not able to get the meaning of above steps, more specifically, step (2) and what "warping one image toward the other" means.

Is it related to pyramidal implementation of Lucas-Kannade method? Can somebody please provide an explanation for this step?


texts: Compression algorithm to compress image relative to similar image

texts:
Is there an algorithm which can take advantage of a previous image in order to compress the next image with a level of compression / quality than otherwise?

I have an app which takes a photo of the sky ever few minutes and then uploads that to a single server. The camera is immovable.

It occurs to me that if I could references (previous image) then I should be able to compress losslessly at a higher rate.

So, I expect that when my local app starts it would upload the full image. The next time it takes an image it would feed (previous_image, new_image) to the compression algorithm, and I'd basically get the diff between the two. The algorithm should be intelligent about subtle color changes and movement (e.g., a cloud). Now local_app and server both have a copy of new_image (local_app has the original and server has the re-constructed) and in the next cycle local_app would feed (new_image, newer_image) to the algorithm.

I assume that this is much how video compression work, but short of recreating a two-frame video and then using a standard video compression algorithm, I haven't found an approach for this.

Something already implemented in python would be ideal. :)


texts: Term for integral multiples of fundamental period?

texts:
As we know that a signal has fundamental frequency and integral multiples of fundamental frequency are known as harmonics

I am curious about the term that will be used for integral multiples of fundamental time period?What is that term?


texts:
I'm working on this idea of choosing best cover image from given db for image steganography(hiding secret image inside cover).
I've started with calculating cross-correlation matrix between images in db
 with given secret image(there are images with different content/texture, like secret could be a building while cover image could be a face and so...).
So first of all i'm not sure if cross-correlation is a proper choice!? but anyway how can i interpret cross-correlation matrix for image similarity? should i only rely on maximum of the result matrix or mean would do better comparison?
What other comparison methods would you recommend for this problem?
I was thinking of binary similarity measures but i'm not sure...(i guess i need proper features first).
Thanks.

I'm using scipy.signal.correlate2d for calculating cross-correlation matrix.


texts: Correction of amplitude after zero padding for upsampling purposes

texts:
I have time sequence in which the data is sampled at 0.8 Hz. The data is related to chromatography (chemical analysis), that is why the sampling frequency is relatively low. The instrument cannot sample faster at this moment.
I was exploring the idea of upsampling by zero padding in the frequency domain as follows in MATLAB.
FFT_S=fft(Signal); % FFT of Signal of Interest

FFT_ZP=[FFT_S(1:length(t)/2,1); zeros(1000,1); FFT_S(length(t)/2+1:end,1)]; % Zero padding with 1000 zeros.

Signal_Up=real(ifft(FFT_ZP)); % Upsampled data

The original data consists of 716 points. The upsampled data has 1716 points but the amplitude has reduced - which is undesirable.
Is there a simple multiplying factor to correct the amplitude in MATLAB based on total number of points before and after upsampling?
EDIT:
Fortunately for this analytical chemistry purpose the trade offs of zero padding are not relevant. Qualitatively, in order to keep the amplitude the same, I found that if we double the sampling rate, the amplitude after inverse fft had to be multiplied by 2, if we triple the sampling rate by zero padding, the amplitude had to be multiplied by 3. Ignoring the trade offs, there must be a generalized method to correct the final amplitude based on the initial and final number of data points?
Thanks.


texts: How can both Gaussian and salt & pepper noise be removed from an image?

texts: An image is corrupted by Gaussian noise,then salt & pepper noise. How can you eliminate it and why?


texts: Composition of interpolation and decimation matrices

texts:
I understand that interpolation is a linear transformation of a signal vector that combines interleaving the elements of the input vector with zeros followed by a filtering operation to remove any newly introduced signal components.

Call the matrix that does this interpolation $U$. It is $M\times{N}$ matrix that maps a $N$-element input vector onto a longer $M$-element output vector with $M>N$.

A similar matrix for decimation, $V$, can be formed. A $P\times{M}$ matrix with $P<M$ that maps an $M$-element input vector onto a shorter $P$-element output vector.

The composition of these interpolation and decimation matrices $VU$ has dimension $P\times{N}$.

How do I construct this $P\times{N}$ matrix explicitly, without needing to multiply these separate $U$ and $V$ matrices?

The advantage in avoiding the intermediate $M$-dimensional space is because, if I want to resample a $127$-length vector to a $128$-length vector, I have $N=127$, $P=128$, but $M=127\times128 = 16256$, which would require a huge amount of extra computation.


texts: Mean Square Error and Gibbs oscillations

texts:
While studying the convergence of Fourier transform, I got to know two conditions.

$$\sum_{n=-\infty}^{\infty}|x(n)|<\infty$$
$$\sum|x(n)|^{2} \leq [\sum|x(n)|]^{2}$$

While I was reading the text, I found this paragraph quite confusing. I didn't understood this.

  If a sequence is not absolutely summable but has finite energy, one may employ a type of convergence in which the series converges so the mean square error is 0. The "attendant Gibbs oscillations" at a discontinuity are of practical significance in filter design.

I don't know what Gibbs oscillations mean here. So if someone could please explain the meaning of this paragraph (taken for DSP by Alan V. Oppenheim).


texts: Convolution between two vectors. Length and normalization

texts:
I have an RIR vector $h[n]$ with $N$ samples and an audio source $x[n]$ with $M$ samples. I wish to simulate a 5 seconds audio segment with $x[n]$ randomly located within (timewise).

Using MATLABs conv(x,h) I am getting a result with vales in the range $[-0.3852,0.3242]$.

Using pythons np.convolve(x,h) I get a result with vales in the range $[-12621.9,10624.08]$, which also sounds bad on the headset (I am assuming due to cutoffs).

I do not know where is the difference comming from, as both $h$ and $x$ are the same before the convolution. Normalizing the output of the python version by:

output=np.convolve(x,h)
output=output/len(output)

fixes the values. This is true for normalizing by either len(output), len(x) or len(h).

Now I am confused about the best method of action.

For a 5-second segment recording, do I have to generate a 5 - second length $h$?
Is it best to first pad both $h$ and $x$ with zeros and then convolve or should I convolve and than allocate randomly within a 5 seconds zeros vector?
Is it at all reasonable to normalize here?
with respect to the former 3 questions, do I normalize by len(output), len(x), len(h) or the number of samples within a 5 seconds segment?

I am aware that there may be more than one correct answer. I am looking for the pros and cons of each course of action and what is the best way to achieve my target.


texts: Geometric explanation of a methodology in the article about Image Denoising

texts:
In article Ghimpeteanu G., et al. - A Decomposition Framework for Image Denoising Algorithms, I found as below:

  Let $\displaystyle I : \Omega \subset \mathbb{R}^2\mapsto \mathbb{R}$ be a gray-level image, and $(x, y)$ be the standard coordinate system of $\mathbb{R}^2$.We denote by $Ix
 \hspace{.2cm}resp.Iy$ the derivative of $I$ with respect to $x
 \hspace{.2cm}resp. y$, and by $\nabla I$ the gradient of $I$ . Our
  image decomposition model for $I$ is a two-stages approach: first, we
  construct an orthonormal moving frame $(Z_1, Z_2, N)$ of $(\mathbb{R}^3,\|
\|_2)$ over $\Omega$ that encodes the local geometry of $I$ . Then, we
  compute the components $(J^1, J^2, J^3)$ of the $\mathbb{R}^3-$valued function
  $(0, 0, I )$ in that moving frame. More precisely, we consider a
  scaled version $\mu I$ of $I$ , for $\mu \in ]0, 1]$, and its graph,
  which is the surface $S$ in $\mathbb{R}^3$ parametrized by $\psi : (x, y)
\mapsto (x, y,μ I (x, y))$

See snapshot-

Please someone explain (possibly visualize geometrically) 4th and 5th line of the excerpt. i.e

  Our image decomposition model for $I$ is a two-stages approach: first, we construct an orthonormal moving frame $(Z_1, Z_2, N)$ of $(\mathbb{R}^3,\| \|_2)$ over $\Omega$ that encodes the local geometry of $I$ . Then, we compute the components $(J^1, J^2, J^3)$ of the $\mathbb{R}^3-$valued function $(0, 0, I )$ in that moving frame.


texts: What is spatial correlation and spatial convolution?

texts: What does the term spatial correlation and spatial convolution mean with respect to digital image processing ?


texts: What measurement errors occur in an inteferogram?

texts:
This question is bordering on physics, but it is the signal side that I am interested in so I hope this is the correct forum.

I am very familiar with instrumental noise sources in CCD based spectrographs and what their signal properties are. I have come to realise how important understanding noise sources are in order to effectively mitigate for them.

Now I am taking an interest in FTIR which uses an interferometer to do the measurement and would like to understand how measurement errors manifest in the interferogram and how they manifest after the FT.

My suspicion is that the variations due to the technical act of measurement will share some aspects with CCD instruments but also present some sources that are very different. For example, spectrograph-CCD systems are affected by e.g. pixel-to-pixel shot noise, fixed pattern response, read out noise, spectra of optics (blank signal), dark signal, vibrations, alignment etc.

How do the following present in both the interferogram and the FT?

random noise (i'm guessing its very different to shot noise in CCDs, not only pixel-to-pixel)
vibrations (physical or thermal)
mechanical whiplash

As I am not familiar with the technological errors associated with an interferometer I'm sure I've not anticipated some sources, so please educate me  on any other sources of variation due to the technology (not the sample or sample-technology interface)

I've tried some searches but not found any useful resources so any good resources would be appreciated


texts:
I am trying to better understand the first-order low pass filter:

Summary:

Per wikipedia,  a first order low pass filter yields the following in discrete time:
$$
\frac{Y(s)}{U(s)}= \frac{\omega_{c}}{s+\omega_{c}}
$$
yields
$$
y[k] = \left(\frac{\omega_c T_{s}}{1+\omega_{c} T_{s}}
\right) u[k]+\left(\frac{1}{1+\omega_c T_{s}}\right) y[k-1]
$$
or
$$
y[k] =\alpha \, u[k] \ + \ (1 - \alpha)y[k-1]
$$

where

$
\begin{array}{cclc}
\omega_{c}
&:&
\text{Cutoff angular frequency of filter}
&
[\frac{rad}{s}]
\\
T_{s}
&:&
\text{Sampling period}
&
[s]
\\
\end{array}
$

Question 1:

Even though this filter is in discrete time, does it still model an analog ($s$-plane) filter?

If I wanted to use a discrete computing system to filter in real-time,
would I need to use the digital ($z$-plane) equivalent?
If so, what is the general process for performing this?
My best guess is:

Determine digital cutoff frequency $\omega_d$.
Convert to analog cutoff frequency $\omega_a =
      \frac{2}{T} \cdot \mathrm{tan}(\omega_d \cdot \frac{T}{2})$.
Determine transfer function for (first-order low-pass) analog filter
using analog cutoff frequency $\omega_a$.
Transform to transfer function for digital filter
using bilinear transform $z = \frac{2}{T} \cdot \frac{z-1}{z+1}$

Relation to exponential smoothing:

On the same page, exponential smoothing is referenced.
The exponential smoothing page describes an exponential weighted average as:
$$
y[k] =\alpha u[k]+\left(1 - \alpha\right)y[k-1]\quad\text{where}\quad\alpha = 1 - e^{-\omega_{c} \cdot T_{s}}$$

Question 2:

How is it possible to relate the first-order low-pass filter alpha
with the exponential smoothing alpha?


texts: Performing inverse DFT after taking conjugate of the result of DFT

texts:
The following is a question I got in my school assignment.

  Pick an image and follow the operations

  Multiply image by (−1)x+y.
  Compute the DFT.
  Take the complex conjugate of the transform.
  Compute the IDFT.
  Multiply the real part of the result by (−1)x+y .

  Compare the input image and output image.

I've written the code for transforms and the mentioned operation using numpy and python. (Used np.fft.fft2)

Can someone help me explain (mathematically)
why the output image appears as it does? How does part (c) affect the transform? Also the multiplying by -1^(x+y) does not make any difference. Why?
I'm a beginner in signal processing. Any help is appreciated.

The output I got is this:

import numpy as np

img = plt.imread("Q2.tif")
N,M = np.shape(img)
i, j = np.meshgrid(np.arange(M), np.arange(N))
mult_factor = np.power( np.ones((N,M)) * -1 , i + j )
tmp = img * mult_factor
print("Calculating DFT")
dft = np.fft.fft2(tmp)
print("Calculating inverse DFT")
idft = np.fft.ifft2(dft.conj())
out_img = np.abs((mult_factor * idft.real) + (1j * idft.imag))


texts: What distance metric can I use for comparing image features in a nearest neighbour algorithm?


texts:
I'm having a some trouble with an assignment I have to do. I don't come from electrical engineering background and would appreciate any help I can get.

"A voice signal is band-limited to 3.3 kHz. What is the Nyquist frequency? It is sampled using a guard band of 1.4 kHz is applied and converted to digital data with 7 bits per sample. What is the resulting data rate?"

I calculated the Nyquist frequency using the formula $$f_{Ny} = \frac{1}{2}f_s = \frac{1}{2}3300\text{ Hz} = 1650\text{ Hz}.$$

Is this correct? Moving along I have no idea how to do the last part of the question, my lecturer didn't have any examples of this type of question so I'm really lost. Or else if someone could point me to a source that will show me how to do this question, that would be great too.


texts: FFT on continuous fifo data - Is y axis magnitude sum of all samples?

texts: I'm running an fft once a second on a buffer of data 60 seconds long. The data is sampled at 558Hz and is placed into the fifo buffer once per second. FFT is numpy.rfft. The data is scaled to psia prior to fft. From the research I have done so far (found several previous questions on this) the unit of the fft magnitude will also be in psia. But I am unsure of how I should interpret this magnitude. Is it a sum of the entire sample? Something else? My intuition says it is a sum of the entire sample. Where if I had say a peak at 25Hz of 30psia on the 60 second buffer, if I wanted to know the peak over a 1 second sample I would divide by 60. My sensor data is only varying by about 2-3 psi when plotted in time domain so that got me wondering how the fft y-data could be orders of magnitude larger than the pk-pk difference of input signal. Or maybe I'm thinking about this totally wrong, I am pretty ingorant on this : )


texts: Fourier Transform of the Hilbert Transform of cos(t) (using Fourier time-shifting property)

texts:
If $x(t)=cos(t)=\frac{1}{2}e^{jt}+\frac{1}{2}e^{-jt}$, then $X(\omega)=\pi \delta(\omega-1)+\pi \delta(\omega+1)$. If $y(t)=cos(t-\frac{\pi}{2})=\frac{1}{2}e^{j(t-\frac{\pi}{2})}+\frac{1}{2}e^{-j(t-\frac{\pi}{2})}=\frac{1}{2}e^{jt-j\frac{\pi}{2}}+\frac{1}{2}e^{-jt+j\frac{\pi}{2}}$, then $Y(\omega)=\frac{e^{-j\frac{\pi}{2}}}{2}F\{e^{jt}\}+\frac{e^{j\frac{\pi}{2}}}{2}F\{e^{-jt}\}=-j\pi \delta(\omega-1)+j\pi \delta(\omega+1)$. $y(t)$ is the Hilbert transform of $x(t)$. This makes sense so far.

The trouble is when I try to evaluate $Y(\omega)$ using the time-shift property of the Fourier transform. $Y(\omega)=F\{x(t-\frac{\pi}{2})\}=X(\omega)e^{-j\omega\frac{\pi}{2}}=(\pi \delta(\omega-1)+\pi \delta(\omega+1))e^{-j\omega\frac{\pi}{2}}$. If I were to plot the phase of $Y(\omega)$, then we would see a line with slope $-\pi/2$. This does not seem to match the Hilbert Transform.


texts: From a physics perspective, why does D/A quantization error result in a noise floor?

texts:
For the last week or so I have been trying to understand how quantization error results in the noise floor outside of a mathematical perspective and I haven't really had any luck finding a source that discussed quantization noise without using equations to show where quantization error comes from.  I certainly have nothing against using math proofs but I was hoping to understand why quantization noise existed rather than how to calculate it.  I think I’ve been able to work through it but I was hoping someone would be able to double check my work or point me in the right direction if I’m missing something.

So here is how I figure it so far:
Because the sample rate is allowing us to have a perfect recreation of the frequency of the wave the bit depth only determines the range of values available for the amplitude of a wave being converted to a digital signal.

When the original signal gets rounded to the nearest bit it creates slight changes in the amplitude which result in a slightly altered waveform at each sample.  This new waveform is basically the same as the sum of our original signal and a new frequency.  So if we were to duplicate this in an analog signal we could do it by adding additional frequencies at very small amplitudes to our signal 44.1 thousand times a second (or whatever the sample rate is).  The lower the bit depth the bigger these changes to our original waveform will be, and so the larger the amplitude of the added waves will be raising the “noise” floor.

If you sampled a waveform that allowed for a slower sample rate, say sampling a 10 Hz wave 20 times a second.  Instead white noise as a result of quantization error would you hear a quick succession of random frequencies paired with your original wave (which would obviously be to low to hear)?

If you can follow my logic up to this point I have one additional question because in my tests changing the phase of my sampled analog wave doesn't seem to change the frequencies of the quantization error like I thought it would. Am I making a mistake in my test?


texts: Viterbi Algorithm - Selecting survivor paths which both contain the same Hamming distance

texts:
To my (limited) knowledge, when determining which survivor path to choose to produce an error-corrected output of a binary Viterbi decoder, the path with the smallest Hamming distance is the most likely estimation of the transmitted signal.

I have come across an example where I am presented with two survivor paths, both with the same smallest Hamming distance. Is there a method of determining which path to then pick? Or is there no method of doing so?


texts: Filter pixels with respect to specific wavelength frequencies

texts:
I'm not sure if this is possible, but let's say you had access to the original raw sampled digital pixels from a sensor, captured with nothing between the sensor and the lenses, i.e.  Anti aliasing filter, colour filter array etc etc removed. Would it be possible to filter the raw pixels in relation to the original wavelength frequencies?

Thanks


texts:
I've been learning about the FFT and about the usefulness of windowing functions. A problem I'm running into is the affect of windowing functions on the amplitude of signals in the FFT. For example, lets say I have a signal that is equal to:

y = 5.0 * sin(50.0 * 2.0 * pi * x) + 1.0 * sin(80.0 * 2.0 * pi * x)

And then I want to perform an FFT and receive the following plot:

Then if I perform a kaiser windowing function of the 14th degree, I receive the following FFT:

What I'm wanting to do is the following: Given a signal, I want to extract a wave out of it of a frequency I approximately know. To do this, I'd like to apply a windowing function to make it clearer what the frequency is I'm trying to extract but not lose information about the amplitude of wave I'm trying to extract. Is this possible? Like a way to reverse the amplitude decrease from the windowing function.


texts:
I read various papers about the log polar transform and its application on template matching with images and have some questions:

In "Image Registration Using Log Polar Transform and Phase Correlation to Recover Higher Scale" the authors say:
"In this algorithm first the sense image is downscaled by the factor of 2. Log-Polar algorithm gives best result for any value of rotation and translation but it will not work if the scale is more than 1.8 or 2, as the frequency components alters at high scale [7]." In the referenced paper "IMAGE REGISTRATION USING LOG-POLAR TRANSFORM AND  PHASE CORRELATION" the authors only mention at the end that their results are verified with a scaling factor up to 2.0, there is no mention at all about altering frequency components at high scale.
Then I read through http://cvpr.uni-muenster.de/teaching/ss08/seminarSS08/downloads/Wentker-Vortrag.pdf . He says that the polar transform is unable to detect scales > 2, the log transform doesn't have it. This clearly contradicts the first paper, which says the log polar transform can only go to scales < 2.
So does the log polar transform normally only work up to scale 2.0?
Regarding question 1, what exactly is the reason that it only works up to a scale of 2? The altering frequency components are mentioned, but I don't know what they really mean with that and it is never explained in any of the papers I found, only that this value exists.
In the presentation http://cvpr.uni-muenster.de/teaching/ss08/seminarSS08/downloads/Wentker-Vortrag.pdf page 22, we have the normal, polar and log-polar transformed image. The polar image has the black areas, which are parts that can't be mapped to the original image because it would be outside of its boundaries. However, these areas have nearly disappeared in the log polar image. Why is that? I tested various Logpolar implementations using OpenCV, Python, another example is Scale and Rotation invariant Template Matching and all the time, the log polar images looks more like the middle image and not like the right one.
What exactly is happening here? Why does the third image look so different, compared to other log polar images which look more like the second?

I hope you can answer my questions.


texts: How do derivative masks work for finding edges in image?

texts:
As I know, masks like follow are derivative mask,

but I don't get it why they can detect edges and which one of them can find vertical edges and which one can find harizontal edges?


texts: Is it possible to detect that sound source is playback of a recording?

texts:
I have been trying to find an article where it is described how real-time (or close to real-time) signal processing from a microphone is able to detect that an audio source is playback of a recording rather than natural source thanks to (for example) missing frequencies in lossy encoding. Ideally it would be something about voice authentication tampering / voice assistant trigger words filtering. I am sure there is lots on the subject, however I am quite new to the field and can't seem to be able to come up with the right keywords for my googling.

Thanks


texts:
I have to compute an HSV histogram of a colored image.  Is it same as an H-S histogram?

I have found H-S histogram computation code everywhere. What is the method to change an H-S histogram to an HSV?


texts: I have some biomedical signals. If I calculate their magnitude spectrums, I see power-line interference at 50 Hz. I was excepting a harmonic at 100 Hz, but it turns out there is none. However, there is a harmonic at 150 Hz. Is this common or should I worry that I have done something wrong?


texts:
I'm learning to draw magnitude bode plots from transfer functions:

$$ H(s) = \frac{sRC}{sRC+1} $$

So I can see that I have a zero at s = 0, which corresponds to 0 Hz. I know this will add a +20dB/dec slope for all frequencies in a logarithmic plot. I'm struggling to figure where the gain will start at the left side of my plot. I can kind of cheat a little bit because I know that this is a passive high pass filter, so I can start at the right side of the plot and call that 0dB, move to the left, and then apply my 20dB/dec slope once I pass the break frequency of the pole. But if the transfer function was more complicated and I didn't already know what to expect, what would I do?


texts: GPS | Retain Signal Tracking after Noise Bound

texts:
I have an IF data, 2 seconds signal sample from only one GPS satellite, I know the PRN number of the satellite.
IF Freq = 4.092e6 Hz
Sampling Freq = 16.368e6 Hz
IF data length = 2 seconds
Total sample = 32.736e6

During the first second period, there is no noise, and SoftGNSS SDR can acquire and begin tracking the signal.
However, after 1 second, noise is bonded on the signal. The tracking function loses the signal mostly. The output has distortion a lot.
Here are the figures;

IF signal

Tracking result

The tracking ends at 1.3 seconds because I only process 1.3 seconds.
I tried to adjust DLL and PLL parameters (Damp. ratio, noise bandwidth), but no handle it. Maybe my parameters were wrong. Could you redirect me about it?


texts: How does chessboard configuration affect camera calibration?

texts: When calibrating a camera with a chessboard, are more squares better or worse? When would you use more or less? And how does the size of the blocks effect the calibration results?


texts: How do you determine the properties of a differential equation?

texts: If I was given a differential equation of the form $$y'(t) + a(t)y(t) = x(t)$$ how would I be able to decide its linearity, time-invariance, and causality?


texts: Finding the friction coefficient by using experimental data

texts:
I have the differential system equation with some unknown parameters (friction coefficients)
Also I have experimental data. What I want is to determine the friction coefficients which best fit the experimental data. How to do it using the Mathematica, I know there NDSolve and FindFit functions, but they can't be used here? And what are the general approaches of this problem?

Edit 1:
Here is the model:

$$k_1 (x_3[t]-x_1[t])+a_1 \left(x_3'[t]-x_1'[t] \right)+M_1 x_1''[t]=0$$
$$k_2 (x_3[t]-x_2[t])+a_2 \left(x_3'[t]-x_2'[t]\right)+M_2 x_2''[t]=0$$

$$\begin{eqnarray}
& k_3 x_3[t]-k_1 (x_3[t]-x_1[t])-k_2 (x_3[t]-x_2[t])
\\& + a_3 x_3'[t]-a_1 \left(x_3'[t]-x_1'[t]\right)-a_2 \left(x_3'[t]-x_2'[t]\right)
\\& +C_1 x_3''[t]=0
\end{eqnarray}$$


texts: How to get the data (pointwise frequency, amplitude and phase) in a FFT performed on ImageJ?

texts:
How to find pointwise readouts of the amplitude, frequency and phase of the DFT underpinning the FFT image?

Once an image is FFT-ed in ImageJ, placing the cursor over any points on the FFT plot results in an output of values at the bottom of the main menu, as in this example:

According to the documentation it simply outputs the location of the cursor:

  If the mouse is over an active frequency domain (FFT) window, its
  location is displayed in polar coordinates. The angle is expressed in
  degrees, while the radius is expressed in pixels per cycle (p/c). The
  radius is expressed in [units] per cycle (e.g. mm/c) if the spatial
  scale of the image was defined using Analyze/Set Scale.

I don't know if there is any additional information within this line to link to the actual sine (or cosine) wave at this particular point in the Fourier plot:

r = .18 p/c (644), theta = 55.12 deg, value = 121

Some playing with ImageJ has given me some preliminary intuition of what these numbers signify. Picking up extreme positions of the cursor as it hovers over the FFT image or plot (yellow cross on the following images) makes it easier to interpret. First, placing the cursor very close to the bright dot in the center and along the x axis yields the following read-out:

This is the slowest frequency in the image, and corresponds to 1 cycle from side-to-side. The image is 256 x 256, and hence, the frequency is 256 pixels / cycle.

What happens if we move the cursor a tiny bit further away to the left along the x axis:

Right, now the frequency has doubled to 4 cycles from side-to-side, which corresponds to 64 pixels/cycle, which (given enough patience and skepticism) can be proven by magnifying and counting the pixels:

What happens at the Nyquist limit:

The limit is 2 pixels/cycle for 128 cycles.

The direction, naturally can be at any angle around the clock face:

and if we select a darker pixel (as in this case), the value will consequently be low.

It gets interesting at the corners, where the PT tells us that the maximum number of cycles will be $\frac{\sqrt{256^2+256^2}}{2}=181$:

There ought to be an easier method, but awaiting a formal answer this would possibly get the job done:

The read-out of the information captured on the image may go like this:

At the point with the cross hairs on the frequency space:

  $\text{Freq.} = 2.245$ pixels/cycle - on a $256^2$ image, $256/2.245 = 114$ cycles in the direction of...

  $\text{Orientation} = \theta = 48.2^\circ$

  $\text{Amplitude} = \vert X[k]\vert=\sqrt{X_\text{Re}^2+X_\text{Im}^2}=\sqrt{-244.868^2+456.238^2}=384.95$

  $\text{Phase} =\arctan\left(\frac{X_\text{Im}}{X_\text{Re}}\right)=\arctan\left(\frac{456.238}{-244.868}\right)=-61.78^\circ$

whether this is correct, and whether there is an easier way to get this info without having to calculate on the side these values, or having to use several separate, and disjointed (FFT and Complex) output windows, justifies keeping the post open.


texts: Reverse Engineering Bessel LPF (sample frequency needed)

texts:
I have the following sourcecode. For all I know, it should be a Bessel LPF at 10Hz. Is there a way to get the sampling frequence out of this?

double LPF(register double value) {
    static double buf[4];
    register double tmp, fir, iir;
    tmp= buf[0]; memmove(buf, buf+1, 3*sizeof(double));
    iir= val * 1.865660386328251e-06;
    iir -= 0.9048452950692862*tmp; fir= tmp;
    iir -= -1.898666438223082*buf[0]; fir += buf[0]+buf[0];
    fir += iir;
    tmp= buf[1]; buf[1]= iir; val= fir;
    iir= val;
    iir -= 0.8712702520352774*tmp; fir= tmp;
    iir -= -1.866439169696869*buf[2]; fir += buf[2]+buf[2];
    fir += iir;
    buf[3]= iir; val= fir;
    return val;
}


texts: Interpolation of a gray scale image in matlab

texts: I want to fill the black areas with the value of neighboring pixels. Kind of interpolation. Can any one suggest me how Can I do in matlab.


texts: Determining pulse shape for Viterbi Equalization

texts:
I believe I understand well enough how the Viterbi algorithm can reverse the effects of ISI when the combined impulse response (transmit filter, multipath, receive filter) is known. I've read How I Learned to Love the Trellis by Bernard Sklar, and I also asked about it in a previous question: Applying Viterbi algorithm to compensate for ISI in PSK31.

But how can this technique be applied when the channel distortion isn't known? From my superficial understanding of equalizing algorithms like CMA, they attempt to infer the channel distortion and compensate for it dynamically. My particular interest is HF channels, which would certainly seem to benefit from some dynamic adjustment.

However, in my study of Viterbi equalization so far, I've not found an explanation of how the unknown impulse response of the channel is found. Without that information, the best we can accomplish is to compensate for known elements like the receive and transmit filters. And in a case with no inherent ISI (like RRC filters on each end), then does Viterbi equalization have any value at all?


texts: Information to be transmitted being a stochastic process?

texts:
I am reading Digital Communication, 3rd edition by Barry & Lee,

Book's Webpage:
enter link description here

This is an excerpt taken from this book (mentioned above) from Chapter 3, Page # 57, 1st Para, 1st Line.

It says,

 Although modulation and demodulation are deterministic,the information to be
 transmitted over a communication system, as well as the noise encountered in the
 physical transmission medium,is random or stochastic.

I understand Noise being a random process but how the information to be transmitted could be a random process.
I mean do we not know the nature of information to be transmitted by us ahead of any transmission ?

Please elucidate this.


texts: Is there a formula that converts scientific note names to piano key numbers? As an example, given A4 it would output 49.


texts: Why does subbing $s = j\omega$ into the Laplace transform of a cosine wave yield a purely imaginary result?

texts:
The Laplace transform of a cosine starting at $t=0$ is given by

$$F(s) = \frac{s}{s^2 + \omega_0^2}$$

If I sub in $s = j\omega$, I get the Fourier transform of a cosine starting at $t=0$:

$$F(j\omega) = \frac{j\omega}{\omega_0^2 - \omega^2}$$

As this is a purely imaginary result it shows that the input function is made up of only sine waves and must therefore be odd.

This doesn't make sense as a cosine wave starting at $t=0$ is neither odd nor even, so $F(j\omega)$ should have both real and imaginary parts.

I find a similar issue when using a sine wave starting at $t=0$ which returns a purely real function of frequency:

$$F_2(j\omega) = \frac{\omega_0}{\omega_0^2 - \omega^2}$$

What is it that I'm misunderstanding?


texts:
So I'm trying to figure out a method to do spectral factorization, where we take some function $X(D) = (1+cD)(1+cD^{-1})$. I believe this is used in equaliation I can do this if I just plugging in numbers until i get something that works, but that doesn't seem like the best way to go about it. Lets look at the following example:

$$X(D) = \frac{.19}{(1+.9D)(1+.9D^{-1})}+\frac{1}{10} = \frac{.371+.09D^{-1} +.09D}{(1+.9D)(1+.9D^{-1})}$$

The bottom part is easy, because it's already factorized into the form we want, so it's the top part that's the hard part. I can come up with the following answer but trying random numbers until I start getting close to what I want:

$$ X(D) =  \frac{.3477(1+.2588D)(1+.2588D^{-1})}{(1+.9D)(1+.9D^{-1})} = cY(D)Y^*(D^{-*})$$
where $Y(D) = \frac{(1+.2588D)}{(1+.9D)}$ and $c= .3477$.

I've tried searching for a method of doing this, but I just can't find one that makes sense and that works every time.

I've tried getting it in the form of $D(D^2 + bD + c)$ where the $D^2$ term has a coefficient of 1, and $b$ and $c$ are constants, and then try factoring that into two parts, but it just doesn't seem to be working out for me. I'd appreciate any advice!


texts: Cross-correlation peaks in acoustic multi-path conditions

texts:
Consider a speaker and a microphone are placed in a multi-path environment and the audio signal to be transmitted is LFM(chirp) signal, the time of arrival of the audio signal is computed by cross-correlation at the receiver side. My question is:

If there are severe reflection, reverberation phenomenons but the direct-path propagation acoustic signal is also received. When doing cross-correlation, will the first correlation peak (which is supposed to belong to direct path propagation signal) shift due to reflections & reverberations?

thank you very much


texts: Gaussian noise generator algorithm trouble

texts:
I stumbled upon the following algorithm for Gaussian noise generation and I just can't figure out how this is supposed to work at all.
The algorithm is as follows:

First of all: $j = \arg\min_i (q_1 - p[i])$ does not depend on $q_1$ and therefore yields the same result every time - I assume $\arg\min_i (|q_1 - p[i]|)$ is what's really meant here.
But then there's more: I can safely assume that $q_1$ is distributed linearly within $[0,1]$, otherwise I could just scale that, round afterwards and wouldn't have so much hassle.
In this case I got another problem: As $q_1$ is linearly distributed, choosing $j$ near to zero (which is what $\mu=0$ would implicate) is not particularly likely, so I suspect the resulting distribution is not a normal distribution.

This algorithm reminds me of inverse transform sampling ( http://en.wikipedia.org/wiki/Inverse_transform_sampling); however it does not appear to be a variant of it. I'm a bit confused here because that's somewhat easy to compute and if p was a cumulative distribution here, I'd understand this one right away.

So basically I'm stuck with understanding this one and looking forward to any hints as to where I'm wrong.

Thank you folks in advance!


texts: Splitting a magnitude across multiple bins in an IFFT

texts:
By Georg-Johann own work, CC BY-SA 3.0.

I’m trying to synthesise a sine wave using an IFFT at a frequency between  bin centre frequencies.

Here are the details

-Samplerate : 44100
-FFT Size   : 512
-SignalFreq : 110 hz
-FreqPerBin : 86.1328125
-Bin1Freq   : 86.1328125
-Bin2Freq   : 172.265625

This desired Signal Frequency means that the signal is at midway between $\textrm{bin}_1$ and $\textrm{bin}_2$ (magnitudes) therefore I am wanting to split the synthesis magnitude across 3 bins: $\textrm{bin}_0 , \textrm{bin}_1$ and $\textrm{bin}_2$.

What am I doing wrong?  Here’s how I’ve approached my calculation.

First I calculated the synthesis frequencies percentage between the bins.
0.554195011337869  = (SignalFreq − Bin1Freq) ÷ (FreqPerBin ÷ 2)
Then I multiplied the percentage by PI ($\pi$) to convert it to radians (note I have assumed that bin centre frequency to the bin frequency midway between $\textrm{bin}_1$ and $\textrm{bin}_2 = \pi$1.74105497627516 = (0.554195011337869 * PI)
Then process it through the $\mathrm{sinc}$ function 0.566059652593099 = Sin(1.74105497627516)/1.74105497627516
Which give me the scaling value of $\textrm{bin}_1$
To calculate bin 2, I take the radian value of $\textrm{bin}_1$ and add PI to it (because this moves the location into the next bin for the $\mathrm{sinc}$ function )4.88264762986495 =  (bin1 radian value) 1.74105497627516 + PI
Process it through the $\mathrm{sinc}$ function-0.201845607081636 = sin(4.88264762986495)/4.88264762986495
Which gives me the a value for $\textrm{bin}_2$.  (I’m assuming this should be the absolute value)
To calculate bin 3, I take the radian value of $\textrm{bin}_1$ and subtract PI from it-1.40053767731463 =  (bin1 radian value) 1.74105497627516 - PI
Process it through the sinc function0.703687584403628 = sin(-1.40053767731463)/-1.40053767731463

My initial magnitude for $\textrm{bin}_1$ was $1.0$ so this means that splitting $\textrm{bin}_1$ across $\textrm{bin}_0, $\textrm{bin}_1 and $\textrm{bin}_2$ looks like this

bin0 = 0.703687584403628
bin1 = 0.566059652593099
bin2 = 0.201845607081636

This doesn’t seem right to me.  It seems like bin0 (apart from this bin wanting to have a value of 0.0) has a value higher than the bin matching the frequency of the signal.

What am I doing wrong?


texts: Autoregressive modeling (linear prediction) of electrical transmission lines?

texts:
I've read that the reflection coefficients in speech processing (as computed by the Levinson-Durbin algorithm for solving the Yule-Walker equations) "represent the fraction of energy reflected back" at each tube junction,[1] assuming the speaker's vocal tract is modeled as a series of uniform lossless acoustic tubes (see Figure 1). Now, I've seen that statement from multiple PDFs online, but did not see it mentioned in my textbook (Rabiner, Schafer - Digital Processing of Speech Signals).

Does this mean we can do autoregressive modeling of electrical transmission lines as well? In other words, does a series of lossless transmission lines form an all-pole filter whose (magnitude) reflection coefficients (one for each junction) and linear-prediction coefficients can be estimated by inputting white noise to the system and then analyzing the output with the Levinson-Durbin algorithm? (Figure 2.)

Figure 1. Approximating a non-uniform acoustic tube using a series of short tubes of uniform cross-section. (Source: Rabiner, Schafer - Digital Processing of Speech Signals p.83.)

Figure 2. A series of lossless transmission lines. (Source: Pozar - Microwave Engineering 4th Ed. p.251.)

[1] http://research.cs.tamu.edu/prism/lectures/sp/l7.pdf


texts: Affine Parameter Optimization using simulated annealing

texts:
I am working on a project to compare images in the database. I use color and gradient orientation as  features of the image and these features are not rotation invariance, therefore to compare well I proposed to warp the images using 5 parameter affine transformation and optimise the 5 parameters to obtain the best match between the images.

For image comparison I use histogram matching distance within the range of 0-1 therefore 1 represents the best match. I set the threshold of match to 0.75 (this is the fitness function).

However, as I am not familiar with simulated annealing method, I am confused if it can be used to optimise the parameters of affine transformation matrix. I read other methods like Genetic algorithm, and cross entropy optizmiation but I found Simulated annealing more understandable but I am not sure if it can do the job.

Although this might be a more theoretical question than coding, I just want to confirm my doubts. I have implemented the codes for simulated annealing and it seems to be working well but not that fast in terms of optimisation. Please confirm if u think that theoretical simulated annealing can be used in my project. I have no problem with my coding so I won't put up any codes.


texts: Perform overlap add with available FFT size smaller than filter coefficients

texts:
I would like to process 12 to 20 seconds of incoming audio at a sample rate of 44100. I must process this audio in real time in an STM embedded kit (perhaps also an Android Smartphone). I'm trying to detect and count the number of occurrences of a signal of roughly 6500 samples inside the incoming audio. The maximum FFT available is of 1024 samples.

I was thinking about applying overlap-add but the number of coefficients would be 6500 and that's larger than maximum FFT size of 1024. I tried to simulate this in Matlab using fftfilt but the function help says:

If you supply a value for n, fftfilt chooses an FFT length, nfft, of 2^nextpow2(n)and a data block length of nfft - length(b) + 1. If n is less than length(b), fftfilt sets n to length(b).

This makes me think that I'm forced to use an FFT of at least 6500 samples (which I can't) and then process 1 incoming audio sample at a time (super inefficient).

What can I do?


texts: Why does my digital upconversion result in two tones?

texts:
I am using Xilinx's RFSoC in I/Q mode. The important point is that in the digital space I have real and complex samples. I take the incoming data and multiply it by a complex sinusoid.

In my test setup I am sampling a 125 MHz sine wave and am mixing it with a 5 MHz sinusoid. I take the mixed signal and pass it out a DAC to view it on a spectrum analyzer. What I would like to see is the 125 MHz digitally upconverted to 130 MHz. What I actually see is two tones: 120 MHz and 130 MHz.

Is there a way, without just filtering the 120 MHz sine wave, to upconvert the 125 MHz tone to 130 MHz by mixing?


texts:
How can you correct the anticlockwise rotation that occurs in the received constellation of a QAM system?

My only idea is to compensate the delay with an advance but this is impossible since you would have to decode the message before receiving it.


texts: Anti-Aliasing and the Fourier Transform, Gonzalez Digital Image Processing

texts:
In Gonzalez book Digital Image Processing, section 4.34 (third edition), he writes:

Unfortunately, except for some special cases mentioned blow, aliasing
is always present in sampled signals because, even if the original
sampled function is band-limited, infinite frequency components are
introduced the moment we limit the duration of the function, which we
always have to do in practice.
For example, suppose that we want to limit the duration of a
band-limited function $f(t)$ (i.e. a function whose Fourier transform
is non-zero only on a closed interval of range of frequencies), to an
interval say $[0, T]$. We can do this by multiplying $f(t)$ by the
function
$h(t)= 1 $ if $t \in [0,T]$, and is $0$ otherwise.
Then from the convolution theorem we know that the transform of this
product $h(t)f(t)$ is the convolution of the transforms of the
functions. Even if the transform of $f(t)$ is band-limited, convolving
it with $F(h(t))=H(\mu)$ will yield a result with frequency components
that are infinite.

This very last statement is what I am not sure about. If the Fourier transform of $f$ is band-limited, then outside of a closed interval, the transformed function will be $0$, and so I am not sure for which frequency components the convolution of the transforms will have infinite frequency. Any insights appreciated.


texts:
Consider a system for which the input $x(t)$ and output $y(t)$ are related by the differential equation $$\frac{d^2y(t)}{dt^2} + \frac{3}{2}\frac{dy(t)}{dt} - y(t) = x(t) \tag{1}$$Determine $h(t)$ for each of the following cases:

The system is stable.
The system is causal.

My attempt: I know that this question can be solved easily using the Laplace transform but I'm trying to solve it in time-domain. Since it's assumed that system is linear, causality is equivalent to:
For any time $t_0$ and any input $x(t)$ such that $x(t) = 0$ for $t \lt t_0$, the corresponding output $y(t)$ must also be zero for $t < t_0$. This is the initial rest condition and we can easily solve $(1)$ by methods like this.
Stability for an LTI system is equivalent to $$\int_{-\infty}^{+\infty}|h(\tau)|d\tau<\infty$$
How this condition can be used to solve $(1)$ in time-domain? Can we get initial conditions using this condition?


texts: Bounds of the difference of a bounded band-limited function

texts:
For a continuous signal (function), we have Bernstein inequality :
$$
 |{df(t)}/dt| \le 2AB\pi
$$
where  $A=\sup|f(t)|$  and $B$ is the bandwidth of $f(t)$. The question is: is there a relationship for a discrete function $x[n]$ like this?
$$
|x[n] -x[n-1] | \le\   \mu\ W
$$
where
$$
X[k] = \sum\limits_{n = 0}^{N - 1} {x[n]{e^{ - j\frac{{2\pi }}{N}nk}}}
$$
is the DFT for  $x[n]$, $X[k]=0$ for $k> W$.


texts:
I have a 1D array of 32 bit floating point numbers representing the current draw of a radio operating over a 40 minute span.  The number of elements in the array is 29 million and change.  There is a signal of interest inside this array that I would like to be able to identify in future signals.  I've copied the part of the array that I am interested in and used a python script to generate a parameterized mask.  I would like to use this mask to look for similar signals in my 40 minute array.  The issue is the amount of time it takes to "sweep" this mask over all the data to see if all the data points fit under the mask.

Generally, I would like to be able to identify signals of interest in large data sets and extract their indices.

I am using Python, numpy, and SciPy.

Images 1 Small signal and mask 2 Full 40 minute radio current draw

Given a signal waveform of interest, what is the most effective way to detect whether that signal exists inside another signal?

Here is a link to the raw data.  It's a zipped csv format.  The values are time and current draw in amps.  Sampling rate of the data:  One sample every 8.192E-05 seconds.  Signal of interest begins around 917.65 seconds and lasts less than one second.

https://www.dropbox.com/s/rw5yt5zv5rpraoh/ExportedData.zip?dl=0


texts: Better way to mute fundamental baseband frequency?

texts:
I'm working on a project to monitor the fluctuations and harmonics present on standard 120VAC mains power. I built an adapter that drops the voltage from 120VAC to 12V and then down to 0.5-0.6 VAC nominal and feeds that into sound card input to convert it to digital form where I can analyze it with gnuradio.

The dominant frequency that is present of course is the fundamental mains power frequency (60Hz here in the US). I want to mute this frequency so I Can study all the other attributes of the signal.

I came up with a way to mute the fundamental 60Hz signal but I don't think it's the best way. My method is simple - it takes the current signal and adds the inverse of the same point on the signal to it. Picture a sine wave and a cosine wave plotted together and when added, they always add up to 0.

The problem is that I suspect this method may be adding artifacts to the output. I suspect so because I created another flow graph with sound card input and output sink and performed the same "add signal to its delayed inverse self" method I mentioned above. What I hear is a very distorted version of the actual input which includes an echo of the input signal.

Aside from the artifacts it does an amazing job of muting the 60Hz fundamental. So maybe it is the best way, but I want to crowd-source this challenge and ask the community for ideas on how to mute the 60Hz fundamental while adding little or no artifacts to the output signal.

Fig. 1: Flow graph and "zoomed out" scope focused on the current signal (blue) and the inverse delayed signal (green):

Fig. 2: Zoomed in scope showing the calculated output (red line). Note that it does appear to show the precise fluctuations of the input signals while muting the fundamental as expected, I'm just suspicious that it's also a somewhat unrealistic representation due to my method of calculation.

EDIT 1:
Thank you @dan-boschen for the notch filter suggestion. To get a notch filter in my gnuradio flow graph, I used a FIR filter with a band_reject taps function (firdes.band_reject(1,samp_rate,56,64,2)). Playing with the start/stop/transition parameters doesn't change much. The fundamental is significantly attenuated but is still present and much stronger than the very minute signal deviations that are present, and can be heard using the other method (both methods are compared in the video through left and right audio channels)

I just uploaded this video to illustrate the gnuradio flow graph, and left and right speaker channel comparison between FIR notch filter along, and FIR filter plus the "add to inverse last cycle" method I came up with.

I suspect the band_reject notch filter is tuned as best it can be. Perhaps there is another level of filtering I can apply. Maybe a series of band_reject filters? Looking for any ideas.


texts: Does instability make an otherwise LTI system nonlinear (or time-variant)?

texts:
I am spinning this question off from the question from johnny.  Matt L. and I have had directly opposite conclusions to johnny's question.

I want to decouple the question from issues of causality and other goofy stuff.

So we have a simple first-order recursive system described with time-domain I/O equation:

$$ y[n] = p \cdot y[n-1] \ + \ x[n] \quad \quad \forall n \in \mathbb{Z} $$

Of course, the Z-transform of this is

$$ Y(z) = p \cdot z^{-1} Y(z) \ + \ X(z) $$

and transfer function

$$ H(z) \triangleq \frac{Y(z)}{X(z)} = \frac{z}{z-p} $$

We would normally identify this as a simple and realizable LTI system with a zero at $0$ and a pole at $p$.  But in the other question, there is an issue regarding linearity and time-invariance for the case when $p=-1 \ $.

For what values $p$ is this system linear?  For what values $p$ is this system time-invariant?

This is, I believe, the kernel of the disagreement I have with Dr. Matt L.


texts: Is there a set formula for calculating FIR coefficients (for a LPF ir 96 taps)?

texts: I need to calculate a series of coefficients for several FIR filters having 96 taps is there a standard or set formula for calculating these, it is a low pass filter.


texts: Proof of weak stationary random process autocovariance always goes to zero?

texts:
Professor told me that if a random process is weak stationary, and it does not feature any periodic component, then its autocovariance always goes to zero.

I can intuitively understand it, however, where can I find the formal proof of such property?


texts: Perfect reconstruction in two-channel filter bank

texts:
[from Discrete-time Signal Processing by Oppenheim and Schafer, 3rd ed.]
I was not able to prove this:

If the analysis and synthesis filters are ideal so that they exactly split the band 0 ≤ |ω| ≤ π
into two equal segments without overlapping, then it is straightforward to verify that
Y(ejω) = X(ejω); i.e., the synthesis filter bank reconstructs the input signal exactly.


texts: Image cleaning - removing all regular shapes ( circles, squares, text, icons etc. )

texts:
I'd like an automatic method to clean images. I've been looking at the GIMP, and its command line (cli) interface, in scheme / lisp. It looks very promising, but I'm a complete novice, so I'd be grateful for advice.

I'm, essentially, wanting to remove all man-made artefacts from a large number of photos - which is why I need to automate it, it's easy enough with just the one.

I'd like to remove anything with a hard-edge (square, rectangle, or part of one), or with a smooth curve (circle, ellipse, or part of one), but not remove naturally curved things, like leaves, or fronds. Actually, since there may be bits of vaguely straight edge, or approximate arcs in the 'natural' figures, I can go further, and say that no straight edge, or arc, will be longer than .5 cm in the original - I hope that helps!

What's special about the areas removed is one of: There is a straight edged border (at least one). There is a border that is the arc of a circle - an interior or exterior border. The items left have irregular borders, with no straight edges and no arcs.

I've attached a before and after photo. In a perfect world, I'd like a script that takes the image on the left, and leaves the image on the right.

Any suggestions of the best way to go?

It'd be nice if the method could be one that can use a GPU.


texts: python; audio; detecting silence in audio signal

texts:
I have real-time audio application written in python, and I have question about detecting silence.
What's the most efficient way to distinguish silence from non-silence, in an input audio signal? By non-silence I mean any sound, even noise. I need to know when silence-period is in the process, as accurately as possible. I don't necessarily ask for some code-algorithm; theoretical tips and explanations would be also useful. I know that silence have low level of oscillations (signal is flat); in numpy.fft.fft output, silence has highest amplitude in [1] bin, and so on, there are several significant things when silence is there.
But using any of these conditions in code,  cannot give me absolutely accurate result to  detect silence and completely split it from sound. Any advanced techniques for this task?


texts: I have been out of touch with DSP for a while. I was trying to refresh my basics and ended up with this doubt on IIR filter stability condition. I understood that for an iir filter to be stable, the poles should be inside the unit circle which was derived from its analog counterpart (i.e poles should be on Left hand of s plane). But then is there any extra condition that poles should be only real? Could it be complex also?


texts: Amplitude in frequency domain not as expected with discontinues time domain signal

texts:
I'm having a problem where I cannot explain why the amplitude in the frequency domain not is as expected.

The scenario:

I have a time domain signal of consisting of two sine waves. on at 5Hz with amplitude 2 and one at 10Hz with amplitude 2. the signal is 10 seconds long. The 5 Hz sine wave is only present the first 5 seconds, and the 10Hz sine is only present in the last 5 seconds.

if I take an FFT of the first 5 seconds the magnitude in the frequency domain at 5Hz is as expected. And again if I take an FFT of the last 5 seconds the magnitude of the last 5 seconds is as expected.

But if I take the FFT of the entire signal both the magnitude at 5 and 10 Hz seems to have halfed in magnitude ? Is this expected or am I doing something wrong.

I'm using MathDotNet in a custom made application.


texts: Differences between $\tt wentropy$ in MATLAB and entropy definition

texts:
MATLAB offer's a Shannon entropy calculation in its wavelet package:

$$
H(X) = -\sum_{i=0}^{N-1} x_i^2\log(x_i^2)
$$

I'm wondering what this formula means, since it has no relation with the probabilities of the symbols in the sequence $x$. It is closer to Spectral Entropy (in the domain of $x$)...