How to apply a m-dim filter on a image across multiple channel? - indexing

So, I have to apply a Gaussian filter on a RGB image. So, I was able to figure out the logic but I am not able to apply the filter on the image.
Basically, what I am trying to do is to multiply a sub-array of shape (1,m) with a sub-array of same size in a row of an image of size n x n, while moving the sub-array (filter) along till the end.
What I am here trying to do is that I want to apply the filter across all the channels (axis2) at once, thus I am trying to broadcast the array in axis2, while keeping all the elements along axis1.
At the end I got this error:
I already tried finding answers which can help me with sweeping this sub-array(filter) across the image but I was unable to get a clear answer.

Related

2d filter that do not cross a line

I want to preform some kind of smoothing filtering with numpy or scipy(or any other python package) on my 2d data set(2d median filter for example) but I don't want the filtering kernel to cross some arbitrary line in my data set.
A Toy example for the data set will look something like:
Essentially I don't want the filter to mix between the positive and negative values across the black line in the toy example. In the general problem the data can contain multiple lines and the lines can have any orientation or length.
I would appreciate any solution or suggestions

Show 2D celldata fields in 3D domains with Paraview

I have a .vtu file composed of tetrahedral and triangular elements (located on an outer surface). I also have a celldata field (for example, nrc1) defined on the triangular elements and being zero in the tetrahedral ones. When I select to plot this field in Paraview, I only see a zero field, corresponding with the 3D elements, but no trace of the field in the 2D elements.
Is there a way to show that 2D field in Paraview?
P.D.: I cannot interpolate the 2D celldata field into a pointdata one, since part of the information (discontinuities,...) would be lost.
There is indeed a conflict between the information on the 3D cells (zeroes) and information on the 2D cells (actual information), where the 2D cells and the 3D cells overlap.
Even though your dataset is valid, mixed dimension dataset are not easy to manage correctly, hence your issue.
In any case, you should extract your 2D cells to be able to visualize your data correctly, here is how I would do it :
Create a new view, click on Spreadsheet view
show your dataset in the spreadsheet view
order by CellType
Manually select all 2D CellType has they will be located together
Add an Extract Selection filter, Apply
You can now visualize your data on this 2D cells only dataset
You could also use Edit->Find Data and select by ID since your cells seems to be ordoned.
Finally, you could write a small Python Programmable Filter to do all that for you completelly automatically, but it is not very easy to implement.

How to refine the Graphcut cmex code based on a specific energy functions?

I download the following graph-cut code:
https://github.com/shaibagon/GCMex
I compiled the mex files, and ran it for pre-defined image in the code (which is rgb image)
I wanna optimize the image segmentation results,
I have probability map of the image, which its dimension is (width,height, 5). Five probability distribution over the image dimension are stacked together. each relates to one the classes.
My problem is which parts of code should according to the probability image.
I want to define Data and Smoothing terms based on my application.
My question is:
1) Has someone refined the code according to the defining different energy function (I wanna change Unary and pair-wise formulation).
2) I have a stack of 3D images. I wanna define 6-neighborhood system, 4 neighbors in current slice and the other two from two adjacent slices. In which function and part of code can I do the refinements?
Thanks

Is there a way to transfer matrix data between blocks in gnuradio?

I have been looking for ways to transfer matrix data from one block to another. I was wondering if it's possible to do the same. What I've thought of till now is converting the numpy matrix to a list, and sending the list through after padding it with the number of rows and columns in the end. After receiving, just reshape the list to a numpy matrix and process as required. But from what I understand, the length of a list must be known while making the blocks.
I'd like to know if it's possible to implement this, or if I'll have to look at it in some other way.
GNU Radio doesn't care what your items actually represent, only their size in bytes.
Therefore, you can define arbitrary item sizes, and put multiple numbers in one item. In fact, what the stream_to_vector and vector_to_stream do is exactly that.
You'd use a output_signature = gr.io_signature(1,1, [gr.sizeofgr_complex] * N_elements) with N_elements being your number of matrix entries.
As a side note: exchanging matrices does reek of things of channel estimates or equalization; these are often more elegantly handled by asynchronous message passing than item streams.

Get an outline shape of multiple smaller shapes

I have an array of arrays containing points that define polygons. These polygons together form another, final shape. What I want, is to only get the outline points of the final shape in the correct order, so I can draw them on screen.
I have tried removing duplicate points (where two shapes meet, they have exact same points) and sorting them around their centroid and then connecting those, but that gives an approximate outline with many deviations (as of course, connecting the points in a clockwise order is not necessarily correct).
So basically, what I want to do is turn this into this.