contour | Contour of a Union of Iso-Oriented Rectangles
kandi X-RAY | contour Summary
kandi X-RAY | contour Summary
This project implements, in Swift, the algorithm described by Lipski and Preparata. You can find the technical report describing the algorithm in file Lipski-Preparata.pdf. I, Rob Mayoff, am the sole author of the Swift source code in this repository. I hereby dedicate the code to the public domain in accordance with the CC0 1.0 Public Domain Dedication.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of contour
contour Key Features
contour Examples and Code Snippets
Community Discussions
Trending Discussions on contour
QUESTION
I am trying to reduce lines of code because I realized that I am repeating the same equations every time. I am programming a contour map and putting several sources of intensity into it. Until now I put 3 sources, but in the future I want to put more, and that will increase the lines a lot. So I want to see if it is possible to reduce the lines of "source positions" and "Intensity equations". As you can see the last equation is a logaritmic summation of z1, z2 and z3, is it possible to reduce that, any idea?
...ANSWER
Answered 2021-Jun-15 at 15:45You could iterate over certain parts in a loop.
I tried to keep the same format overall and just rearranged the code to show how you might do it.
QUESTION
I have a concave hull (not convex) that I have the points for eg: A,B,C,D,E
. I've gotten the pairs of points that make up the outer edges. [A,B],[A,E],[C,D],[B,C],[E,D]
. (This is a very simplified version)
I want to get the connected points in order (CW or CCW doesn't matter) so I can use them as a contour.
But the pairs are not ordered, you can see A goes to B, then A goes to E, etc. The only solution I had was searching for each point and its next pair sequentially in a loop
Is there a way to solve this using numpy only in a vectorized manner so that its fast for a large array of edges? I know shapely exists but I have trouble installing it and I'd prefer no external dependancies
this is my code:
...ANSWER
Answered 2021-Jun-15 at 08:27You can do this efficiently with a dictionary:
QUESTION
How can I find the maximum points of the curves generated by the contour plot, and then connect them?
...ANSWER
Answered 2021-Jun-13 at 15:43- Extract the index,
idx
, of the maximum value from each row of arrayXA
- Use
idx
onT
andXA
to extract the x-axis and y-axis values.- Indexing the array is slightly faster than using
y = XA.max(axis=1)
to get themax
XA
values.
- Indexing the array is slightly faster than using
- The shape of
XA
is(8, 120000)
, so there are 8 maximums. I'm not certain why only 7 contour lines are showing.- Use
x[:-1]
andy[:-1]
to not plot the last point.
- Use
QUESTION
I am looking for an application or a tool which is able for example to extract data from a 2D contour plot like below :
I have seen https://dash-gallery.plotly.host/Portal/ tool or https://plotly.com/dash/ , https://automeris.io/ , but I have test them and this is difficult to extract data (here actually, the data are covariance matrices with ellipses, but I would like to extend it if possible to Markov chains).
If someone could know if there are more efficient tools, mostly from this kind of 2D plot. I am also opened to commercial applications. I am on MacOS 11.3.
If I am not on the right forum, please let me know it.
UPDATE 1:
I tried to apply the method in Matlab with the script below from this previous post :
...ANSWER
Answered 2021-Jun-12 at 23:37Restating the problem - My understanding given the different comments and your updates is the following:
- someone other than you is in possession of data, which as it happens is 2D data, i.e. an Nx2 matrix;
- using the covariance matrix, they are effectively saying something about the joint distribution of these two dimensions, specifically about the variance;
- if they assume a Gaussian distribution, as is implied by your comment regarding 68%, 95% and 99.7% for 1sigma, 2sigma and 3sigma, they can draw ellipses which represent the 2D-normal distribution: these are in fact some of the contour lines associated with the 3D "bell" surface;
- you have obtained the contour lines in a graph and are trying to obtain the covariance matrix (not the original data...);
- you are concerned about the complexity of having to extract the information from each ellipsis.
Partial answer:
- It is impossible to recover the original data, I hope you are already aware of that, but in case you are not let's just note that the covariance matrix is a summary statistic of the data, much like the average, and although it says something about the data many different datasets could happen to have the same summary statistic (the same way many different sets of numbers can give you an average of 10).
- It is possible to somewhat recover the covariance matrix, i.e. the 3 numbers a, b and c in the matrix [a,b;b,c], though the error in doing so will likely be large because of how imprecise the pixel representation is. Essentially, you will be looking for the dimensions of the two axes, for the variances, as well as the angle of one of the axes, for the covariance.
- Unless I am mistaken, under the Gaussian assumption above, you only need to measure this for one of the three ellipses, and then factor by whatever number of sigmas that contour represents. Here you might want to either use the best-defined ellipse, or attempt to use the largest one, which will provide the maximum precision for your measurements (cf. pixelization).
- Also, the problem of finding the axes and angle for the ellipse need not be as complex as what it seems like in your first trials: instead of trying to find the contour of the ellipses, find the bounding rectangle.
- In order to further simplify this process, if your images are color-coded the way you show, then a filter on blue pixels might be enough in terms of image processing. Then simply take the minimum and maximum (x,y) coordinates in order to obtain the bounding rectangle.
- Once the bounding rectangle is obtained, find the equation to your ellipse (that's a question for a math group, but you could start here for example).
Happy filtering!
QUESTION
I have traffic density (number of cars) data of various segments of a road. I want to plot a contour map like in the attached figure in R.
...ANSWER
Answered 2021-Jun-12 at 13:04It seems that you're looking for a tile plot. Here is an approach with ggplot2
:
QUESTION
BRAND new to ML. Class project has us entering the code below. First I am getting warning:
...ANSWER
Answered 2021-Jun-12 at 04:26You need to set self.theta
to be an array, not a scalar (at least in this specific problem).
In your case, (intercepted-augmented) X
is a '3 by n' array, so try self.theta = [0, 0, 0]
for example. This will correct the specific error 'bool' object has no attribute 'mean'
. Still, this will just produce preds as a zero vector; you haven't fit the model yet.
To let you know how I approached the error, I first went to the exact line the error message was pointing to, and put print(preds == y)
before the line, and it printed out False
. I guess what you expected was a vector of True
and False
s. Your y
seemed okay; it was a vector (a list
to be specific). So I tried print(pred)
, which showed me a '3 by n' array, which is weird. Now going up from that line, I found out that pred
comes from predict_prob()
, especially np.dot(X, self.theta)
. Here, when X
is a '3 by n' array and self.theta
is a scalar, numpy seems to multiply the scalar to each item in the array and return the array (having the same dimension as the original array), instead of doing matrix multiplication! So you need to explicitly provide self.theta
as an array (conforming to the dimension of X
).
Hope the answer and the reasoning behind it helped.
As for the red line you mentioned in the comment, I guess it is also because you are not fitting the model. (To see the problem, put print(probs)
before plt.countour(...)
. You'll see an array with 0.5 only.)
So try putting model.fit(X, y)
before preds = model.predict(X)
. (You'll also need to put self.verbose = verbose
in the __init__()
.)
After that, I get the following:
QUESTION
I want to design and train a neural network for the automatic recognition of the edges, in some microscopic images. I am using Keras for a start, I may consider PyTorch later.
The structure of the images is rather simple, with some dark areas, and some clear areas, relatively easy to distinguish, and the task is to select the pixels of the contour between dark and clear areas. The transition between dark and clear is gradual, so my result is not a single line of edge pixels, but rather a 10 or 15 pixels wide "ribbon" at the edge.
I have manually annotated 200-something images, so for each image I have another image, of the same size, where the pixels of the contours are black, and all the other pixels are white.
I have seen many tutorials on how to design, compile and fit a model (a neural network), and then how to test it, using the manually annotated data.
However, most of the tutorials work on problems of classification, where the number of neurons in the output layer is the number of categories.
My problem is not a problem of classification, and ideally my output should be an image of the same size of the input.
So, here is my question:
What is the best way to design the output layer? Is a layer with a number of neurons equal to the number of pixels the best idea? Or this is a waste, and there is a more efficient way?
Addendum
- The images are "easy", but it is still difficult to find the contour pixels, so I believe that it is worth using the machine learning approach.
- The transition between dark and clear is a little gradual, so my result is not a single line of pixels on the edge, but rather a band, a 10 or 15 wide ribbon of edge pixels. Since I am after a ribbon of pixels, my categories should be "edge" and "not-edge". If I use the categories "dark pixels" and "clear pixels", and then numerically find the pixels between the two areas I do not get the "ribbon" result, which I need.
ANSWER
Answered 2021-Jun-10 at 10:11The short answer is "yes": it is a good idea to have as many neurons in output as you have in input, i.e. to output an image with the same resolution of the input images.
The network architecture will have an input layer with a neuron for each pixel, then typically the hidden layers will shrink to less neurons, probably with convolutional layers, and then some more layers will re-expand the number of neurons, up to the output layer, which in principle may have the same number of neurons as the input layer.
The most common architecture in this type of problem is the U-net architecture, described in the article "U-Net: Convolutional Networks for Biomedical Image Segmentation", by Ronneberger, Fischer, and Brox, published on the open arxiv: https://arxiv.org/abs/1505.04597.
[
QUESTION
I have some sketched images where the images contain text captions. I am trying to remove those caption.
I am using this code:
...ANSWER
Answered 2021-Jun-09 at 20:15The cv2
pre-processing is unecessary here, tesseract is able to find the text on its own. See the example below, commented inline:
QUESTION
I have to load previous chat messages first and i am getting response of messages like this
...ANSWER
Answered 2021-Jun-08 at 07:55I found solution for it I changed the format of messages into required format of gifted chat it will not work fine until we modify our response into the gifted chat required format Here it is what i did
QUESTION
I am trying to plot a data (x, y, z) in gnuplot of range x=(0, 50k+) , y=(0,50k+). However, the data need to be super imposed on a map which is of size (2000, 2000).
The issue I am having is, the x and y axis range is 50k+ and the data is plotting nicely, however, the image is rendered in a corner mapping the (0, 2000) range in axis. I need to render the map independent of the data axis comprising the whole plot area, over the ata range. Following is what I am trying that doesn't scale the image,
...ANSWER
Answered 2021-Jun-08 at 02:55There are auxilliary keywords that can modify binary filetype=png w rgbimage
. The ones you want are dx
and dy
(see "help binary keywords"). In your case the image is 2000x2000 pixels and each pixel represents an area
57599/2000 = 28.8, so the plot command becomes
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install contour
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page