Downsampling a 23 bit number to 8 bits

  • Thread starter Thread starter nashed
  • Start date Start date
  • Tags Tags
    Bit Bits
Click For Summary

Discussion Overview

The discussion revolves around the challenge of downsampling a 23-bit number to an 8-bit output in the context of a system performing Fourier approximations in VHDL. Participants explore various methods to manage data representation while minimizing distortion and maintaining signal integrity.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning
  • Conceptual clarification

Main Points Raised

  • Some participants clarify that downsampling typically refers to changing the sample rate rather than the bit depth.
  • There are suggestions to keep the output signal within the display range, with considerations for whether the display can handle more than 8 bits.
  • One approach proposed involves taking the logarithm of the 23-bit number if the output is in dB, while another suggests scaling the dataset based on its maximum value.
  • Participants discuss the implications of simply outputting the last 8 bits, noting that this may discard significant data.
  • Alternative methods include using a 23-bit OR operation to track significant bits for scaling the output effectively.
  • Concerns are raised about the potential for distortion when reducing bit depth, with suggestions for low-pass filtering to mitigate this issue.
  • Some participants mention that sampling with finite resolution introduces noise, which may affect the signal-to-noise ratio (SNR) depending on the specific application.
  • There is a discussion about the need for scaling the output amplitude, especially when using integer coefficients in the Fourier synthesis process.
  • References are made to established techniques in video bit reduction and data compression, suggesting that these concepts may apply to the current problem.
  • Terminology and definitions are questioned, particularly regarding what is meant by "sampling a 23-bit number" and the implications of downsampling and bit reduction.

Areas of Agreement / Disagreement

Participants express various viewpoints on the methods for downsampling and the implications of bit reduction, indicating that multiple competing views remain. The discussion does not reach a consensus on the best approach or the definitions of key terms.

Contextual Notes

Limitations include the dynamic nature of the dataset affecting the maximum value, the potential for distortion when reducing bit depth, and the ambiguity in the OP's terminology regarding sampling and downsampling.

nashed
Messages
56
Reaction score
5
I'm trying to build a system that receives coefficients and performs a Fourier approximation, I need to write the system in VHDL so I'm using tables to simulate sin functions, they output an 8 bit number which is the sin of the input, then I need to multiply each sin with it's given coefficient and to prevent overflow I output a 16 bit number, next I want to sum over all the sins I have and I've determined that I need to output a 23 bit number to prevent overflow, now I need to output the result to a display which expects an 8 bit number and I'm stuck at this step as I'm not sure how to sample my 23 bit number so I get the correct shape of the function without distortions.
 
Engineering news on Phys.org
Stricktly speaking, down-sampling involves changing the sample rate, not the bit depth.
You need to keep the signal in range on the screen. Can you display more than 8 bit data?
If your output is to be in dB then you might take the log (to the base two) of the 23 bit number.
If your output must be linear you will need to search for the maximum and scale the dataset.
display(i) = 255 * value(i) / maximum.
The process gain of the transform will increase the dynamic range of the output spectrum by the square root of the number of input samples.
 
Baluncore said:
Stricktly speaking, down-sampling involves changing the sample rate, not the bit depth.
You need to keep the signal in range on the screen. Can you display more than 8 bit data?
If your output is to be in dB then you might take the log (to the base two) of the 23 bit number.
If your output must be linear you will need to search for the maximum and scale the dataset.
display(i) = 255 * value(i) / maximum.
The process gain of the transform will increase the dynamic range of the output spectrum by the square root of the number of input samples.

Thanks for the reply! I was going for something similar, thing is my dataset is dynamic which means my maximum will change in real time, I suppose the easy solution is to always output the last 8 bits, am I correct?
 
nashed said:
I suppose the easy solution is to always output the last 8 bits, am I correct?
You could just display the most significant 8 bits but you will be throwing away much of your data.

If you do not have a fast multiply function then, rather than tracking the maximum, consider doing a 23 bit OR of all the data values into a common register that started out zero. After the accumulate, the first set bit will tell you how many bits to shift the output to show the most useful 8 bits.
 
Talk about a quart into a pint pot!
For really drastic bit reduction is could be worth using floating point arithmetic.
nashed said:
so I get the correct shape of the function without distortions.
Hardly 'without distortions' but what level of distortion would be acceptable?
You could always low pass filter the high res data, which would reduce apparent distortion.
There are so many possibilities but the best one would depend upon your actual requirement and what complexity (and delay) you can accept for the processing.
 
Sampling with finite resolution also introduces noise into even ideal signals (like a sine wave read from a table). It can be shown that the noise is additive white Gaussian. Whether the reduction in SNR is significant depends on your particular experiment.
 
nashed said:
I'm trying to build a system that receives coefficients and performs a Fourier approximation,
This appears to be a Fourier Synthesis exercise, computed in hardware using integers only.
Unless there is some intelligent control of the integer input coefficients, the output amplitude will need to be scaled.
 
Baluncore said:
This appears to be a Fourier Synthesis exercise, computed in hardware using integers only.
Unless there is some intelligent control of the integer input coefficients, the output amplitude will need to be scaled.
Raised Cos analysis is what's done for video bit reduction. I think it's chosen for speed and for the subjective qualities of the result (relevant here). There is a load of stuff about MPEG coding and its history (and Jpeg, too). The questions of scaling, blocking and interpolation have all been addressed since digital transmission of sound and vision have been implemented. No need to reinvent a wheel, I think.
 
sophiecentaur said:
No need to reinvent a wheel, I think.
I thought that this was an introductory exercise in VHDL. There was no OP mention of fast transform algorithms or data compression.
 
  • #10
Baluncore said:
There was no OP mention of fast transform algorithms or data compression
I think there is problem here with terminology and definitions in the OP. As usual on PF, the terms were picked up and run with before the OP made it clear what was actually wanted. For instance, what is meant by "sampling a 23 bit number"?
Data compression must be involved here if the OP also requires "downsampling" and a reduction in bits (per sample??). You can downsample many signals without loss if you are prepared to use more bits per sample or you can reduce the word size if you increase the sample rate. Trying to do both has to introduce distortion of some sort, The clever thing is to make the distortions as invisible, subjectively, as possible. That's why I was thinking in terms of MPEG techniques.
It would help if the task were defined more clearly. It is probably a very specific thing that the OP has been given.
 

Similar threads

Replies
1
Views
2K
Replies
9
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
20
Views
3K
  • · Replies 12 ·
Replies
12
Views
11K
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
10K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K