Optimized 2D convolution library in C for CPU [closed] - python

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I am doing convolutions with a large amount of small images (3636 or so) and small filters (33 to 5*5). So an FFT-based solution is not what I am looking for. Perhaps a highly optimized and tuned implementation (with SSE/AVX, multithreading) is better for me.
However, convolution is not included in BLAS. And FFT libraries (FFTW) do not have a convolution function. I tried scipy.signal.convolve2d, and it is even slower than my naive C implementation.
Is there a dedicated convolution library optimized for small kernels on CPU? It will be better if it automatically switches to FFT on large kernels.
I am coding in Python, but a C/C++ library is OK as long as I can import it with ctypes. My GPU is too old to give any speedup.
Related questions:
Fast 2D convolution implementation?
Fast way to implement 2D convolution in C
Fastest 2D convolution or image filter in Python
They are all talking about FFT, but not vectorization.

Related

Is there a way to write a multidimensional C array to .npy format with C code, so that we could read the array in python numpy later? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 11 months ago.
Improve this question
I am doing some scientific computation, and I produce data with a C program and analyses using python. I want to export an array from C to python.
So far what I am doing is to write the C array, which is multidimensional (More than 2), into a csv file, and reading it from python np.genfromtxt and unwrapping it using the .reshape method. I think it would be a huge improvement if I could directly write a .npy file and call np.load. Is there any library in C that could do this?
The NPY file format is an internal file format of Numpy. While there are few (non-standard) libraries like this or this or even this, the file format is relatively simple and documented by Numpy here. It can change in the future and the libraries may not be up to date.
Alternatively, a better solution is certainly to load/save your file using the HDF5 standard. It is widely supported by many fast/HPC libraries and supported by Numpy too (see this related post for more information). HDF5 also provide more advanced features like reading a slice or parallel read/writes for HPC applications.

Python Libraries for Exact (Weighted) Maximum Independent Sets [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
I'm trying to get some approximation ratios for the Maximum Independent Set Problem and so I need some exact solutions !
I've found libraries written in C++ (i.e https://github.com/iPapatsoris/Maximum-Independent-Set)
but wondered if there were any directly in Python. I know of the `networkx' maximal indepedent set function but these are only approximations.
I realise it's far from the most efficient language to use but I'm only solving small Erdős–Rényi graphs (N<20).
In addition to this, are there any libraries that solve this for the weighted problem, where some nodes matter more than others?
This is the only python library I could find:
https://github.com/pchervi/Graph-Coloring/blob/master/Coloring_MWIS_heuristics.py
I haven't checked that it works correctly however.
I've been using KaMIS instead, which is a C++ implementation.
https://github.com/KarlsruheMIS/KaMIS

Linear algebra with Pyomo [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I'm trying put my optimization problem into Pyomo, but it is strongly dependent upon standard linear algebra operations - qr, inverse, transpose, product. Actually, this is Kalman filter problem; recursive linear algebra for long time series. I failed to find pyomo functions to implement it like I could in tensor flow. Is it possible?
Connected questions:
Am I right that numpy target function is practically not usable in pyomo?
Is there a better free optimization solution for the purpose? (scipy cannot approach efficiency of Matlab by far, tensor flow is extremely slow for particular problem, though I do not see why, algorithmic differentiation in Matlab was reasonably fast though not fast enough)
Many thanks,
Vladimir
Pyomo is mainly a package for optimization. i.e. specifying data -> building problem -> sending to the solver -> wait for solver's results -> retrieving solution. Even if it can handle matrix-like data, it cannot manipulate it with matrix operations. This should be done using a good external library, before you send your data to Pyomo. Once you have all your matrixes ready to be used as data in your optimization model, then you can use Pyomo for optimization.
That being said, you should look into finding a library that fits your needs to build your data, since your data values must be static, once you provide it as an input to your model.
Also, keep in mind that Pyomo, like any optimization tools, is deterministic. It is not meant to do data analysis or data description, but to provide a way to find one optimal solution of a mathematical problem. In your case, Pyomo is not meant to do the Kalman filter problem, but to give you the solution of minimizing the mean square error.

Noise Reduction in an Audio file using Python [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
We can perform noise reduction using Open-source Software like Audacity, which is commonly used for the purpose. Please click the below link for reference.
denoising with audacity image
Is there a python library that can perform a similar function?
If you want to reduce noise the audacity way, to my understanding, you should program your algorithm using scipy filters provided by scipy library.
Besides that pyaudio is one dedicated library for audio analysis and here is a kickstart tutorial.
If you are not restricted only to Python, you can check out on Essentia. This is by far an exhaustive library for music and audio analysis.
Nutshell: While python libraries provide functionalities, it is you who should code your noise reduction algorithm (tailored to your needs). May be you can follow the audacity's approach.
You can refer this question for better, technical/implementation, clarity: Noise reduction on wave file
Good luck! Try to be precise and post questions focusing on implementation pertaining to programming languages rather than generic things.
As a general guideline:
Understand the behavior of your noise and then you can choose your noise removal strategy accordingly.May be you need a simple low pass filter or high-pass filter.

Getting entropy of image in python / scikit image? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I note that Matlab has a straightforward function for getting the entropy of an image. I need something similar for python. Scikit image has an entropy filter, which outputs the image using the least amount of bits needed to do so (at least, I think it does). I assume that to do this it calculates the entropy, but I can't seem to access it as a scalar value.
Before I code a function to do this manually, does anyone know if already exists and I'm somehow missing it? Or for that matter, some existing code that they'd recommend?
If you don't mind shelling out to ImageMagick you can do it like this:
convert someImage.png -format '%[entropy]' info:
0.907238
Not sure how you do it with the ImageMagick Python bindings, but it is probably possible.

Categories