Permutations of matrix columns - manim

I'm wondering is there a way to apply a permutation matrix to a matrix object in Manim? Specifically I want to swap two columns so for example the 3rd column and the 2nd column switch places?
Thank you in advance!

Related

How to plot a 2D vector field on ruby on rails?

I have not been able to find a way to plot a vector field on ruby on rails. I want to introduce 2 parameters and a simple function and obtain something like this:vector field
In case that it is not possible, is there away to plot a simple arrow on XY axis like this:
single vector
Thank you!

Stereo-Processing, Census Based

Hi I'm currently trying to implement a stereo matching algorithm in c and I'm having trouble to understand a part in the
paper.
My Problem is the part after the subpixel calculation on page 17. I don't understand it how to get the subpixel disparity map for both directions. Also I'm a little bit confused if my cost aggregation is correct. It's recommended to use a 5x5 windows and sum the values over this block. Do I sum all values in this 5x5 block or do I add every second in every second row, like I did for the census transformation? Thanks for the help!

Array Conditional Filtering (ArrayFire)

I have two arrays A (2D image) and B (1d intensity values) and trying to make third one (2D) with will be size of A but contain only values of A that B has. What will be the the right way to do that without moving data to the host?
PS: Trying to find a way to work with result of function 'regions' (mask out certain regions and keep others).
Thanks.

How to make the labels of superpixels to be locally consistent in a gray-level map?

I have a bunch of gray-scale images decomposed into superpixels. Each superpixel in these images have a label in the rage of [0-1]. You can see one sample of images below.
Here is the challenge: I want the spatially (locally) neighboring superpixels to have consistent labels (close in value).
I'm kind of interested in smoothing local labels but do not want to apply Gaussian smoothing functions or whatever, as some colleagues suggested. I have also heard about Conditional Random Field (CRF). Is it helpful?
Any suggestion would be welcome.
I'm kind of interested in smoothing local labels but do not want to apply Gaussian smoothing functions or whatever, as some colleagues suggested.
And why is that? Why do you not consider helpful advice of your colleagues, which are actually right. Applying smoothing function is the most reasonable way to go.
I have also heard about Conditional Random Field (CRF). Is it helpful?
This also suggests, that you should rather go with collegues advice, as CRF has nothing to do with your problem. CRF is a classifier, sequence classifier to be exact, requiring labeled examples to learn from and has nothing to do with the setting presented.
What are typical approaches?
The exact thing proposed by your collegues, you should define a smoothing function and apply it to your function values (I will not use a term "labels" as it is missleading, you do have values in [0,1], continuous values, "label" denotes categorical variable in machine learning) and its neighbourhood.
Another approach would be to define some optimization problem, where your current assignment of values is one goal, and the second one is "closeness", for example:
Let us assume that you have points with values {(x_i, y_i)}_{i=1}^N and that n(x) returns indices of neighbouring points of x.
Consequently you are trying to find {a_i}_{i=1}^N such that they minimize
SUM_{i=1}^N (y_i - a_i)^2 + C * SUM_{i=1}^N SUM_{j \in n(x_i)} (a_i - a_j)^2
------------------------- - --------------------------------------------
closeness to current constant to closeness to neighbouring values
values weight each part
You can solve the above optimization problem using many techniques, for example through scipy.optimize.minimize module.
I am not sure that your request makes any sense.
Having close label values for nearby superpixels is trivial: take some smooth function of (X, Y), such as constant or affine, taking values in the range [0,1], and assign the function value to the superpixel centered at (X, Y).
You could also take the distance function from any point in the plane.
But this is of no use as it is unrelated to the image content.

OpenCV: Make a Difference-of-Gaussian

Is there a simple way of making DoG kernel to filter a image. I know it is possible to generate the kernels manually and then substract them from each other, but isn't there a smarter way to do this?
Another way of doing it is to create the analytic formula for your kernel, with the needed parameters, and calculate the position of every pixel inside.
getDoG(i,j, sigma1Big, sigma2Big, sigma1Small, sigma2small,
rotationBig, rotationSmall, kernelSize, ...);
Do not ask me for the formula :)
But the easiest way is to make two kernels with the correct parameters and subtract them.
Do not forget to normalize the kernel (shift the values so that the sum of all kernel values is 1)

Resources