As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I am trying to add AWGN to my audio file. I convert my wav file to byte array. I am trying to add 10dB AWGN to this array. In matlab there is imnoise which adds AWGN to image. In java is there any library? Thanks in advance.
If you actually need the additive Gaussian white noise output similar to that of Matlab's imnoise function, this is the extent of the code that you need to implement in Java:
B = A+MU+STD*randn(size(A))
where A is your input data, B is your output of the same size, MU is the mean of the noise, and STD is the standard deviation. Independent and identically distributed (IID) Gaussian white noise is added to each component of A. This calculation needs to be done in floating point (as many of Matlab's image processing routines are).
The randn function produces normal random variates. You can use java.util.Random.nextGaussian() to produce these. If you need some extra speed, try a Java implementation of the Mersenne Twister algorithm.
Not sure if i got the question correctly. Ist that the thing your are looking for and then just regulate the db over whatever player you are using?
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I need a stable Java library that I can pass a huge string to (e.g., a few chapters from Moby Dick) and get "word count"-like stats:
Number of paragraphs
Number of sentences
Number of words
Number of characters
Preferably something internationalizable/localizable but not required. I figured Apache Commons would have something like this, but after a thorough search it does not.
I could write this myself but it would probably be buggy and take a lot of time; plus I don't want to reinvent the wheel if it already exists. I am thinking of using Apache Tika but cannot confirm if it will do what I need. It seems to handle word count, but not the others. Thanks in advance.
Take a look at Apache Tika. It might serve your requirements
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I would like to encode/decode an image in an encoding like base64. However, I'm not using base64 because the encoded result is too large: I want the encoded size to be small.
I've searched Google many times, but have not found any useful information for my requirement.
Can anyone help me to find a more compact encoding than base64?
If your requirement is that the encoded image must be printable in ASCII, then Base64 is probably a good generic bet. If your requirement is really to have as small a binary representation of your image as possible, look into JPEG and PNG (depending on the type of image, requirement of lossy/lossless etc). If you have a lot of time on your hands and want to fiddle with mathematics, try fractal compression?
As others have commented, if your requirement is to store an image in a database, most/all RDBMS provide some form of BLOB to achieve just that.
Cheers,
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'll preface this comment by saying that I understand how a hash table works however I'm not sure how I would go about implementing one from scratch using only primitives.
Would anyone be able to provide a Java code implementation of a hash table using only arrays?
How would I even start writing a hash table in Java?
How would I code a linked-list hash table again using only primitives?
Cheers!
The code given by the OpenJDK can be pretty hard to understand, so I'll write a short idea how to do it...
One way I did it recently was to use the array itself as a symbol table. The indices of the array will then be the keys (hash-keys) and the elements the value (whatever you want to store). Since arrays have a fixed size and hash-keys can be any integer we are faced with a challenge: to crop the hash-values so they are in the same range as the size of the array. If, say the array has a length of 5, the keys needs to be between 0 and 4. Otherwise we would place values into slots outside of the array => lots and lots of exceptions.
This challenge becomes especially fun when you'd like to avoid collisions...
A lot of help can be found on this page on princeton.
Good luck!
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I heard one of my colleagues saying that Java handles recursion more efficiently than c or C++, I was just curious what why is it able to do so? I mean what is "under the hood" process that makes this happen.
All efforts appreciated.
The usual issue around recursion (not 100% sure this is what your colleague was referring to) is whether 'it' (the compiler, the JIT, the runtime, whatever) can (and does) implement 'tail call optimization'. The goal is that instead of having the code make 'real' calls (introducing a new frame onto the call stack) that recurse (either into the same function or through the same 'cycle' of functions), you can get the same effect without doing so.
The wikipedia page is pretty decent on describing it.
http://en.wikipedia.org/wiki/Tail_call
If it's correct it's because the JIT compilation is able to optimize a recursion better than the C compiler. http://en.wikipedia.org/wiki/Just-in-time_compilation
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am doing a study (as part of a course requirement) on the new Fork-Join framework in Java 7 and analyze the performance improvement compared to the conventional threading mechanism. What are the kinds of divide and conquer algorithms that are guaranteed to run faster with the new fork join framework. Can you suggest any non-trivial algorithm I can work on to analyze the performance difference.
You can try N body problem: http://en.wikipedia.org/wiki/N-body_problem
or
You can try parallel sort
Maybe linear algebra problems would be a good fit: LU or QR decomposition, forward-back substitution, an eigenvalue solution method like Jacobi iteration, etc.
Finite element solution of problems in solid mechanics, heat transfer, and fluid mechanics are significant sources of these kinds of problems.