I have a numpy array of values and I wanted to scale (zoom) it. With floats I was able to use scipy.ndimage.zoom but now my array contains complex values which are not supported by scipy.ndimage.zoom. My workaround was to separate the array into two parts (real and imaginary) and scale them independently. After that I add them back together. Unfortunately this produces a lot of tiny artifacts in my 'image'. Does somebody know a better way? Maybe there also exists a python library for this? I couldn't find one.
Thank you!
This is not a good answer but it seems to work quite well. Instead of using the default parameters for the zoom method, I'm using order=0. I then proceed to deal with the real and imaginary part separately, as described in my question. This seems to reduce the artifacts although some smaller artifacts remain. It is by no means perfect and if somebody has a better answer, I would be very interested.
Related
I am in the process of converting a codebase from Matlab to Python and noticed that generateMesh gets called on some polygons before carrying out a finite element analysis.
What I need to get as an output is a list of all the elements and nodes, with their respective coordinates. I don't need any GUI, just the output nodes and elements information.
The best solution I came across is something like this done with gmsh. I know gmsh is a pretty big library and I am afraid it might be a little too much for my needs. Is there any other package you'd suggest?
Triangular meshes are fine for the moment, but I would like the package to support tetrahedral meshes as well in case it's needed in the future.
Thank you
edit: I forgot to mention that I am only dealing with 2D geometries, as the triangular and tetrahedral elements imply.
I need help to choose me a method which I can apply to my problem. Problem is I have 2 images like this
First image and Second image.
You can see these are images with same same lines, not all lines. I would like you to suggest me a method how to approach this problem. I need to have best match possible and to have the coordinates for these to images how to put them together again, without matching them or using an algorithm again. Btw I prefer python like a programing language for this problem and please do not suggest patented method like surf etc.
Thank you for all answers and help from you.
Have a nice a day.
I need to have best match possible and to have the coordinates for these to images how to put them together again, without matching them or using an algorithm again
I'm not sure what exactly you mean by the highlighted part, but what you're describing seems to be an image stitching problem, or a least part of one.
OpenCV has a class that implements a stitching pipeline.
If you are only interested in finding the correspondences and not the combined image, you could have a look here, where they explain a feature matcher and extractor.
Note, however, that the performance of these feature extractors depends a lot on the parameters you set, so you might have to tune them a bit before it works well.
I have a python x-array dataset with dimensions x,y,t and at least two variables at each coordinate. I was wondering if there exists any x-array method that can help "project" or "composite" values on an axis of my choice.
The figure I drafted up below is an example of what I mean by compositing on a time axis. In the figure, only most recent finite values are considered in the final product. If no finite value is found in a specified interval, then the composite value is nan. This is similar to stacking raster layers in photoshop or gimp.
What I've learned in my recent x-array explorations is that more than often the solution to x-array problems involves avoiding manual dissection of x-array data-structures(however tempting it may be).
I was wondering if python x-array had a built in way of handling problems like compositing? Any tips on how I should go about approaching this problem? I'm primarily looking for either more knowledge about x-arrays or a solution to the compositing problem.
Unfortunately, we don't yet have this functionality built-in to xarray yet (contributions would be welcome!). See https://github.com/pydata/xarray/issues/835 for the issue tracker. Eventually, this will probably go under the name of combine_first.
I'm trying to get a sense of the spatial frequencies present in a series of images I want to analyze. I decided to do this with the numpy.fft.fft2 function, but apparetly the output can't be plotted - can you help me figure out what's wrong?
Apparently this is happening because the output contains values like 0.+0.j which` matplotlib can't deal with. But I don't know how to change them to something it can deal with either.
Here's a minimal example with my issue.
Matplotlib can only handle real values. Your options are to take the real or imaginary parts of the results, or magnitude and maybe even phase. These can be done with numpy.real or numpy.imag, or numpy.abs and numpy.angle.
Ultimately, I guess it just depends on what you want to know about your FFT. People are usually most interested in the magnitude of FFT data, which suggests abs. This gives you an idea of the "power" in the various frequencies.
Quick question, I'm looking for a python function that performs the equivalent job that matlab's imfill.m does. I realize that python has openCV but I have been unable to get that to work properly and am trying to find a substitute for it. The part of imfill that I'm trying to replicate is the 'holes' part of it.
I have a mask that I've generated but I'm trying to fill in all regions that are surrounded by 'land' and leave only the water regions unfilled in.
If this isn't clear enough please let me know and I can try and be more specific. Thank you for your time.
I was able to find a function within scipy that performed similar to what imfill does. It's called binary_fill_holes and it can be found here for anyone that is having the same problem as myself.
Although I can't take full/any real credit for finding it since it was answered here to one of my other questions PIL Plus/imToolkit replacements by unutbu.