matlab,image-processing,interpolation,contour,points

One intuitive approach (IMO) is to create an independent variable for both x and y. Base it on arc length, and interpolate on it. % close the contour, temporarily xc = [x(:); x(1)]; yc = [y(:); y(1)]; % current spacing may not be equally spaced dx = diff(xc); dy =...

Indexes in java starts from zero for (int idx = 0; idx < contours.size(); idx++) { Mat contour = contours.get(idx); double contourarea = Imgproc.contourArea(contour); if (contourarea > maxArea) { maxArea = contourarea; maxAreaIdx = idx; } } ...

python,opencv,image-processing,contour

If you want to work with findContours and other image processing analysis functions in OpenCV with your binary image, you simply need to take binary and convert it to uint8. uint32 will only work under certain modes, and to avoid any unnecessary headaches in remember which mode allows you to...

python,matplotlib,scipy,curve-fitting,contour

I think you want griddata(). You can look at the following website, which does exactly what you are looking for: http://wiki.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data

As stated in the comments you need to have complete data before you can calculate contours. Therefore you have to interpolate or replace your missing values in some way that makes sense in your case. I've provided a couple of options below, but you'd need to come up with rationale...

In Octave you can use bwboundaries (but I will welcome patches that implement bwtraceboundaries) octave:1> pkg load image; octave:2> bw = logical (imread ("http://i.stack.imgur.com/BoQPe.jpg")); octave:3> boundaries = bwboundaries (bw); octave:4> boundaries = cell2mat (boundaries); octave:5> imshow (bw); octave:6> hold on octave:7> plot (boundaries(:,2), boundaries(:,1), '.g'); There are a couple of...

The relevant line is unset clabel I know, that is very unintuitive. Don't know the reason behind it. Here is the complete script with the respective changes, for reference: set xyplane 0; set pm3d set contour unset clabel set cntrparam levels 6 unset surface; unset key; set pm3d map splot...

opencv,image-processing,contour

Depending what you want to do, you could also use the RotatedRect. //you got your contour RotatedRect minRect = minAreaRect(contour); minRect.angle //angle from 0-90 Check out this thread, to see how you can compute the correct angle from that. This is probably only viable if you want to use a...

This is completely answered in the ?filled.contour help page. In the Notes section it states The output produced by filled.contour is actually a combination of two plots; one is the filled contour and one is the legend. Two separate coordinate systems are set up for these two plots, but they...

Very simple. Place an offset within the contourf command. In other words: xMove = 10; yMove = 10; contourf(x_coor + xMove, y_coor + yMove, radius,'edgecolor','none'); xMove and yMove are whichever offsets in the x and y direction you want. Given your example co-ordinates, you thus get: Good luck!...

Here is the Procedure to detect the Sign from the Image: Convert the Image to HSV format. Extract the Red component from the image HSV - H Range(0-10) && (170-180). Dilate , Erode the Binary Red Mask to find the Border. Find contour With RETR_EXTERNAL flag to extract only outer...

Check out this example. You can set up your own colormap colors like this: cmap = mpl.colors.ListedColormap(['r', 'g', 'b', 'c']) You can also select from the existing colormap options ...

opencv,image-processing,contour

Sebastian, thank you for your points. I realized my approach was flawed, and then took an approach based on implicit surfaces. Video here: https://www.youtube.com/watch?v=RKrylKFUceY Code here: https://github.com/dustinfreeman/smootour/...

python,matplotlib,plot,pandas,contour

Here is an example for you to start with: import pylab as pl import numpy as np import pandas as pd # prepare some random data N = 100 np.random.seed(0) weekday = np.random.randint(0, 7, N) week = np.random.randint(0, 40, N) activity = np.random.randint(0, 100, N) df = pd.DataFrame({"weekday":weekday, "week":week, "activity":activity})...

You can try doing a cv2.dilate(img, kernel) to thicken the lines before you try to do houghCircles method. Also a general approach to handling noise is to do a cv2.erode(img, kernel) to thin out the whites, which gets rid of small pixels in the image. Further reading: http://docs.opencv.org/trunk/doc/py_tutorials/py_imgproc/py_morphological_ops/py_morphological_ops.html Kernel is...

Change your fourth line into this, in accordance with the definition of L1 norm: z = abs(xm)+abs(ym); You could do it more efficiently using with bsxfun to avoid generating the matrices xm, ym: x = linspace(-1,1,10); y = linspace(-1,1,10); z = bsxfun(@plus, abs(x), abs(y).'); surfc(x,y,z) Either of the two approaches...

python,sorting,opencv,image-processing,contour

Implements de sort function of list in python like here. In the implemented function you calculate the center and verify if the X position is gretter or smaller them the other. If gretter return 1, smaller -1 and equals 0. def greater(a, b): momA = cv2.moments(a) (xa,ya) = int(momA['m10']/momA['m00']), int(momA['m01']/momA['m00'])...

python,matplotlib,contour,colormap,contourf

This answer is taken almost entirely from the contour demo example: import numpy as np import matplotlib.cm as cm import matplotlib.mlab as mlab # for setting up the data import matplotlib.pyplot as plt # set up example data: delta = 0.025 x = np.arange(-3.0, 3.0, delta) y = np.arange(-2.0, 2.0,...

Since my suggestion is a bit too long for a comment: Have you tried plotting both original files together? You can disable contouring of the first file using nocontour, and disable the surface for the second plot with nosurface: set contour base set cntrparam level discrete 0.3,0.067 set pm3d map...

I guess there is another way, simply with text. Here is a sample: % Create a sample curve x = 1:337; y = sqrt(x); plot(x,y); % Define position to display the text i = round(numel(x)/2); % Get the local slope d = (y(i+1)-y(i))/(x(i+1)-x(i)); X = diff(get(gca, 'xlim')); Y = diff(get(gca,...

python,matplotlib,pandas,group-by,contour

Thanks a lot! My fault was, that I did not realize, that I have to apply some function to the groupby dataframe, like .size(), to work with it... hdf = aggdf.groupby(['a','b']).size() hdf gives me a b 1 -2.0 1 -1.9 1 -1.8 1 -1.7 2 -1.6 5 -1.5 10 -1.4...

for coll in covariance1.collections: coll.remove() then update....

python,algorithm,opencv,computer-vision,contour

According to OpenCV documentation findContours uses "Suzuki, S. and Abe, K., Topological Structural Analysis of Digitized Binary Images by Border Following" The function retrieves contours from the binary image using the algorithm [Suzuki85]. I didn't find description of boundingRect algorithm but found this file in opencv repo 7.a. Straight Bounding...

Your functions vec_dot and f do not vectorize well. The contour3d function passes in a vector of x, y, and z values and only calls the f function once. So rather than calling something like for(y in 1:10) {print( f(y/10,0,0) )} R typically passes in all the values it wants...

c++,opencv,image-processing,vector,contour

- A little bit more explanation of my above comment. calcOpticalFlowPyrLK() can directly use vector<Point> or vector<Point2f> for parameter prevPts. prevPts – vector of 2D points for which the flow needs to be found; point coordinates must be single-precision floating-point numbers. That said, you only need to use contours[0], contours[1]...

I have figured out the solution. The code is shown as blow. im1=double(peaks(300)); im2=double(peaks(300)'); im1_rgb=summer(im1); im2_rgb=cool(im2); [x,y] = meshgrid(1:size(im1,2),1:size(im1,1)); data=im1_rgb/2+im2_rgb/2; subplot(1,3,1) tcolor(x,y,data) hold on [c,h1]=contour(x,y,im1); set(h1,'LineColor','b') [c,h2]=contour(x,y,im2); set(h2,'LineColor','k') hold off subplot(1,3,2) tcolor(x,y,im1_rgb) hold on [c,h1]=contour(x,y,im1); set(h1,'LineColor','b') hold off subplot(1,3,3) tcolor(x,y,im2_rgb) hold on [c,h2]=contour(x,y,im2);...

z <- as.matrix(read.csv(text=',1,2,3,4,5,6,7,8,9,10,11\n1,0,0,0,0,0,0,0,0,0,0,0\n2,0,0,0,0.4,0.6,0.6,0.6,0.4,0,0,0\n3,0,0,0.5,0.7,0.8,0.8,0.8,0.7,0.5,0,0\n4,0,0.4,0.7,0.8,0.9,0.9,0.9,0.8,0.7,0.4,0\n5,0,0.6,0.8,0.9,1.0,1.0,1.0,0.9,0.8,0.6,0\n6,0,0.6,0.8,0.9,1.0,1.0,1.0,0.9,0.8,0.6,0\n7,0,0.6,0.8,0.9,1.0,1.0,1.0,0.9,0.8,0.6,0\n8,0,0.4,0.7,0.8,0.9,0.9,0.9,0.8,0.7,0.4,0\n9,0,0,0.5,0.7,0.8,0.8,0.8,0.7,0.5,0,0\n10,0,0,0,0.4,0.6,0.6,0.6,0.4,0,0,0\n11,0,0,0,0,0,0,0,0,0,0,0\n',row.names=1)); z; ## X1 X2 X3 X4...

python,opencv,image-processing,line,contour

I got something working. It's a bit ad-hoc, but this is basically the algorithm I wrote. I had to reconstruct the contour of your image, so what I did was I read in the image manually, extracted the outer most contour of the object, then proceeded from there. What's good...

I'd create the grid myself. [xi, yi] = meshgrid( min(x):1: max(x), min(y):1: max(y)); zi = griddata(x,y,z, xi,yi); contour(xi,yi,zi,[2,2]) The following commands will give you an idea of what is happening: figure() surf(xi,yi,zi); shading interp; hold on; plot3(x,y,z,'kx') ...

No, I don't think there's a way to make it work, using Findcontours. The reason is that the OpenCV method, is a contour finding method and not a blob finding method. The area is calculated from the perimeter and not just a sum of pixels. The perimeter is a sum...

As @tonytonov has suggested this thread, the transparent areas can be deleted by closing the polygons. # check x and y grid minValue<-sapply(volcano3d,min) maxValue<-sapply(volcano3d,max) arbitaryValue=min(volcano3d$z-10) test1<-data.frame(x=minValue[1]-1,y=minValue[2]:maxValue[2],z=arbitaryValue) test2<-data.frame(x=minValue[1]:maxValue[1],y=minValue[2]-1,z=arbitaryValue) test3<-data.frame(x=maxValue[1]+1,y=minValue[2]:maxValue[2],z=arbitaryValue)...

Take a look at this example from the matplotlib gallery for contour plot functionality. By modifying the levels in your script, as well as changing some of the references, leads to : plt.figure() CS = plt.contour(X, Y,log_mu,levels = [-7,-8], colors=('k',),linestyles=('-',),linewidths=(2,)) CSF = plt.contourf(X, Y,log_mu) plt.clabel(CS, fmt = '%2.1d', colors =...

python,matplotlib,plot,contour

This is actually due to savefig's defaults. The figure can have a transparent background (e.g. try fig.patch.set(facecolor='none'); fig.canvas.print_png), but it's being overridden when you call plt.savefig. If you want a transparent background, you'll need to specify transparent=True in your call to savefig. Otherwise, it will override the figure's current background...

You can make all the contour lines black by specifying a linespec in the contour command to force all your lines to one kind. That is, try changing your contour command to clabel(contour(anomaly.', 'k')). Like this: [x y] = meshgrid((1:87)/87); testResults = sin(x).*sin(y); anomaly = testResults; figure imagesc(testResults.') colormap(gray) colorbar...

Pass the labcex argument to contour with a desired scaling factor. As ?contour states, labcex is cex for contour labelling. contour(x, y, z, labcex=5) ...

javascript,d3.js,data-visualization,contour,scatter-plot

This question is very similar to another question that was already asked and answered at Create contour map In that post, it was recommended to use d3.js and conrec.js....

Do you trying to find corners of rectangle in perspective? You may want to try several solutions: Use HoughLines for line detection and find their intersection. Use Generalized Hough Transform Use Harris corner detector. But you need to filter extra corners. For similar task I used following procedure (it works...

python,numpy,matplotlib,contour

Imagine how you might possibly interpolate such a dataset: there's no way you could continuously move from just below 360° to 0°, unless you'd unwrap those values (see np.unwrap) such that values close to 0° would be reinterpreted as those same values +360°. But then you increase all contours again...

matlab,wolfram-mathematica,matlab-figure,contour

The thing to keep in mind is that Mathematica is formula-oriented and is programmed in terms of mathematical variables, while Matlab is numerically oriented and programmed in terms of matrices and arrays. To evaluate a function of two variables on a grid, it is necessary to first generate that grid...

matlab,plot,matlab-figure,contour

You can use imagesc with the 'jet' colormap. Here's an example: x = conv2( randn(600), fspecial('gaussian',200,20), 'valid'); %// example 2D smooth data imagesc(x) colormap(jet) colorbar grid ...

The contours and colours do not align because filled.contour produces two plots (legend and contour). After plotting, these coordinate systems are lost. (?filled.contour). This can be solved by adding the relevant commands to the plot.axes argument. Semi-circles can be drawn with draw.arc from the plotrix package, spokes with segments. The...