contour

Plot a contour of multivariate normal PDF of a given MVN in MATLAB?

家住魔仙堡 提交于 2019-12-10 02:22:28
问题 I have a bivariate gaussian I defined as follow: I=[1 0;0 1]; mu=[0,0]; sigma=0.5*I; beta = mvnrnd(mu,sigma,100); %100x2 matrix where each column vector is a variable. now I want to plot a contour of the pdf of the above matrix. What I did: Z = mvnpdf(beta,mu,sigma); %100x1 pdf matrix Now I want to plot a contour of the bivariate gaussian beta. I know I should use the command contour but this one require Z to be a square matrix. how do I solve this? I am very confused and not sure how to plot

Move area of an image to the center using OpenCV

本秂侑毒 提交于 2019-12-10 00:38:22
问题 I'm trying to move a region of an image to the center, I succeeded in getting its contour and I know how to place this in the center. But what I want is to move the pixels that are inside the contour (yellow with black) at the center and not just the contour (which is pink by CV_FILLED ). Image: Code: //Then segment the image. save in Mat crop // ---- Center image ----- // pos : contour interest RotatedRect rr = fitEllipse(contours[pos]); vector<Point>&contour = contours[pos]; //http:/

How to plot contour lines on a surface plot? (4D)

对着背影说爱祢 提交于 2019-12-09 20:44:57
问题 I would like to make a 4d plot, where you have X, Y, Z (as a surface) and C (displayed as contours on that surface). What I have right now: What I would like to have: I suspect the answer will be some trick with facecolors or countourf3d but I can't seem to figure it out. Any help much appreciated. My code: import scipy.ndimage import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm def surfcont4d(X,Y,Z,V): # create the figure, add

Contour plot data (lat,lon,value) within boundaries and export GeoJSON

你离开我真会死。 提交于 2019-12-09 07:18:32
问题 I'm trying to interpolate data within boundaries and plot contour lines (polygons) based on Latitude, longitude, value data from csv files. Results I want print as geojson. I'm stuck on the basic contour plot from csv. I really appreciate help here. This is what I got in this moment but can't make it work. import numpy as np import matplotlib.pyplot as plt data = np.genfromtxt('temp.csv', delimiter=',') x = data[:1] y = data[:2] [x,y] = meshgrid(x,y); z = data[:3]; plt.contour(x,y,z) plt.show

Aligning contour line with contour filled plot irregular grid polar plot (semi circle)

折月煮酒 提交于 2019-12-09 02:17:05
问题 I see several people have answered the question for plotting with an irregular grid. I'm having trouble getting the contour lines to line up with the filled contours. Also, need to display the data point locations on the plot, and the radial spokes at 30 deg increments, and semi circles at 10, 20 30. Ref: Plotting contours on an irregular grid heading=seq(0,180,30) speed=c(5,10,15,20,30) mheading=matrix(heading,ncol=length(heading),nrow=length(speed),byrow=TRUE) mspeed=matrix(speed,ncol

Problems during Skeletonization image for extracting contours

纵然是瞬间 提交于 2019-12-09 01:16:26
问题 I found this code to get a skeletonized image. I have a circle image (https://docs.google.com/file/d/0ByS6Z5WRz-h2RXdzVGtXUTlPSGc/edit?usp=sharing). img = cv2.imread(nomeimg,0) size = np.size(img) skel = np.zeros(img.shape,np.uint8) ret,img = cv2.threshold(img,127,255,0) element = cv2.getStructuringElement(cv2.MORPH_CROSS,(3,3)) done = False while( not done): eroded = cv2.erode(img,element) temp = cv2.dilate(eroded,element) temp = cv2.subtract(img,temp) skel = cv2.bitwise_or(skel,temp) img =

OpenCV(C): calculating moments FROM contour

橙三吉。 提交于 2019-12-08 10:03:40
问题 Here's the code I have: #include "highgui.h" #include "cv.h" #include <stdio.h> // this code finds contours int main (int argc, char* argv[]) { cvNamedWindow( argv[0], 1 ); IplImage* img_8uc1 = cvLoadImage( argv[1], CV_LOAD_IMAGE_GRAYSCALE ); IplImage* img_edge = cvCreateImage( cvGetSize(img_8uc1), 8, 1); IplImage* img_8uc3 = cvCreateImage( cvGetSize(img_8uc1), 8, 3); cvThreshold( img_8uc1, img_edge, 128, 255, CV_THRESH_BINARY ); CvMemStorage* storage = cvCreateMemStorage(); CvSeq* first

Adding points to filled.contour function in R

て烟熏妆下的殇ゞ 提交于 2019-12-08 07:48:42
问题 I am trying to add points to filled.countour function in R. But I am not getting any success. I followed this old post. My plot just shows a dot in green. I am looking for a sequence of points which changes color as specified by a color band ( PointColors in this case) . Cannot figure out why... Here is my code: dat1 <-structure(c(5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5,

OpenCv android : Copy part of an image to new Mat

♀尐吖头ヾ 提交于 2019-12-08 07:33:54
问题 I am new to OpenCV and trying to learn by implementing. I need to draw the contours I have detected in new Mat so I can work with them. This is my Original image: After doing some work I achieved this by finding and drawing contours: Here's my code m = Utils.loadResource(MainActivity.this, R.drawable.sheet1, Highgui.CV_LOAD_IMAGE_COLOR); Bitmap bm = Bitmap.createBitmap(m.cols(), m.rows(),Bitmap.Config.ARGB_8888); Imgproc.cvtColor(m, m, Imgproc.COLOR_BGR2GRAY); Imgproc.medianBlur(m, m, 3);

Make a contour plot by using three 1D arrays in python

这一生的挚爱 提交于 2019-12-08 07:31:00
问题 As the title indicates I would like to make a contour plot by using three 1D arrays. Let's say that x = np.array([1,2,3]) and y = np.array([1,2,3]) and z = np.array([20,21,45]) To do a contourplot in matplotlib i meshed the x and y coordinate as X,Y = meshgrid(x,y) but then the z array must also be a 2D array. How do I then turn z into a 2d array so it can be used? 回答1: Your z is wrong. It needs to give the values at every point of the mesh. If z is a function of x and y , calculate z at what