contour

Find contour of 2D object in image in matlab

不想你离开。 提交于 2019-12-01 11:54:13
问题 I have this problem: I have this 2D binary image and I want to extract the contour of the object in this image. This is the image: I want to have the same matrix image but with ones only in the contour of the object and zeros elsewhere. Is there a solution? If so, is there any implementation to do the same thing also for a 3D object? Thank you very much 回答1: If you have the Image Processing Toolbox you can use bwperim BW = imread('http://i.stack.imgur.com/05T06.png'); BW = BW(:,:,1) == 255;

OpenCV - Finding contour end points?

限于喜欢 提交于 2019-12-01 11:42:45
I'm looking for a way to get the end points of a thin contour extracted from a Canny edge detection. I was wondering is this is possible with some built-in way. I would plan on walking through the contour to find the two points with the largest distance from each other (moving only along the contour), but it would be much easier if a way already exists. I see that cvarcLength exists to get the perimeter of a contour, so it's possible there would be a built-in way to achieve this. Is it are the points within a contour ordered in such a way that some information can be known about the end points

Find contour/edge in pcolor in Matlab

杀马特。学长 韩版系。学妹 提交于 2019-12-01 10:41:07
I'm trying to make a contour that follows the edges of the 'pixels' in a pcolor plot in Matlab. This is probably best explained in pictures. Here is a plot of my data. There is a distinct boundary between the yellow data (data==1) and the blue data (data==0): Note that this is a pcolor plot so each 'square' is essentially a pixel. I want to return a contour that follows the faces of the yellow data pixels , not just the edge of the yellow data. So the output contour (green line) passes through the mid-points of the face (red dots) of the pixels. Note that I don't want the contour to follow the

Animating a contour plot in matplotlib using FuncAnimation

a 夏天 提交于 2019-12-01 09:13:20
I am trying to create an animation in matplotlib that updates three artists, including imshow, contour and text. Using FuncAnimation I am able to update the text and the image components, but have not been able to update the contour. Specifically, I tried this as my callback: def updatefig(*args): text_component.set_text(newText()) image_component.set_array(newArrayData()) contour_component.set_array(newArrayData()) return [text_component,image_component,contour_component] This code doesn't raise an exception but neither does it update the contour lines. I wonder if this is just a matter my

Program hangs when using “matplotlib.mlab.griddata”

╄→尐↘猪︶ㄣ 提交于 2019-12-01 08:52:12
I have written a script (Python 2.6) to grid data in x,y,z (.csv format), and display a contour plot of the data. The script works for some datasets but not others - even though both datasets were created using the same script. The datasets to be plotted are created by sub-sampling from a master dataset. Here is an example of every_4.csv (master dataset sub-sampled for every 4 rows). Easting Northing TMI_nT 526243.0 5254128.9 62278.8 526259.4 5254128.9 62352.3 526275.9 5254128.9 62303.3 526292.3 5254128.9 62361.9 526308.8 5254128.9 62667.8 526325.2 5254128.9 62668.6 526341.7 5254128.9 61700.1

Find contour/edge in pcolor in Matlab

核能气质少年 提交于 2019-12-01 08:33:30
问题 I'm trying to make a contour that follows the edges of the 'pixels' in a pcolor plot in Matlab. This is probably best explained in pictures. Here is a plot of my data. There is a distinct boundary between the yellow data (data==1) and the blue data (data==0): Note that this is a pcolor plot so each 'square' is essentially a pixel. I want to return a contour that follows the faces of the yellow data pixels , not just the edge of the yellow data. So the output contour (green line) passes

Animating a contour plot in matplotlib using FuncAnimation

旧时模样 提交于 2019-12-01 05:59:22
问题 I am trying to create an animation in matplotlib that updates three artists, including imshow, contour and text. Using FuncAnimation I am able to update the text and the image components, but have not been able to update the contour. Specifically, I tried this as my callback: def updatefig(*args): text_component.set_text(newText()) image_component.set_array(newArrayData()) contour_component.set_array(newArrayData()) return [text_component,image_component,contour_component] This code doesn't

How to overlay a pcolor plot with a contour plot that uses a different colormap?

狂风中的少年 提交于 2019-12-01 04:29:32
Minimum example that does not achieve it: [X,Y,Z] = peaks; figure; pcolor(X,Y,Z); shading flat; hold all; axes; contour(X,Y,Z); colormap gray; % this should only apply to the contour plot axes... axis off; % ... but it doesn't This shows both the contour plot and the pseudo colour plot in the grayscale colourmap. However, what I want to achieve is only turning the contours gray. This is just a minimalistic example, in reality the contour plot is of different data that has a different range, so two independent caxis settings are required as well. You can fix the problem by catenating two

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

血红的双手。 提交于 2019-12-01 01:46:27
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=length(heading),nrow=length(speed),byrow=FALSE) mag=mheading+mspeed x=sin(mheading*pi/180)*mspeed y=cos

Construct ternary grid, evaluate a function on the grid and contour plot in Matlab

你说的曾经没有我的故事 提交于 2019-12-01 01:36:42
I need to evaluate a function (say) Fxy = 2*x.^2 +3 *y.^2; on a ternary grid x-range (0 - 1), y-range (0-1) and 1-x-y (0 - 1). I am unable to construct the ternary grid on which I need to evaluate the above function. Also, once evaluated I need to plot the function in a ternary contour plot. Ideally, I need the axes to go counter clockwise in the sense (x -> y--> (1-x-y)). I have tried the function function tg = triangle_grid ( n, t ) ng = ( ( n + 1 ) * ( n + 2 ) ) / 2; tg = zeros ( 2, ng ); p = 0; for i = 0 : n for j = 0 : n - i k = n - i - j; p = p + 1; tg(1:2,p) = ( i * t(1:2,1) + j * t(1:2