contour

create a mask and delete inside contour in opencv python

微笑、不失礼 提交于 2020-01-06 05:28:04
问题 this is the result that I have from my code : enter image description here I've made this mask on my face using contour , as I show bellow in the code . the final result of the project is to delete the face and show the background that I am not defined it yet . my question is : is there any way to make a mask with this counter so i could use something like this cv2.imshow('My Image',cmb(foreground,background,mask)) to just show the foreground under the mask on the background ? ( the problem

Error when using cv2.findContours

放肆的年华 提交于 2020-01-03 17:48:33
问题 I tried to find contours for image, but it gives an error. My code is: import cv2 import numpy as np img = cv2.imread('star.jpg',0) ret,thresh = cv2.threshold(img,127,255,0) contours,hierarchy = cv2.findContours(thresh, 1, 2) error is: Traceback (most recent call last): File "C:\Python27\OpenCVContore.py", line 5, in <module> contours,hierarchy,thresh = cv2.findContours(thresh, 1, 2) error: ........\opencv\modules\core\src\matrix.cpp:236: error: (-215) step[dims-1] == (size_t)CV_ELEM_SIZE

Create contour with PHP

旧巷老猫 提交于 2020-01-03 07:09:10
问题 I am working on a project that requires creating an outer contour from a bitmap image. eg. please check the images below. Is there any php library that I can use to achieve this task? I have found open source library http://docs.opencv.org/trunk/d4/d73/tutorial_py_contours_begin.html but this is not on php bitmap image only bitmap with contour Thanks for any clues. 回答1: You can do it with imagemagick. Although there's a PHP API for ImageMagick, I think it's much easier and safer to just spawn

R: Contour plots for marginal distributions with discrete variables

感情迁移 提交于 2020-01-03 05:26:10
问题 I am given a dataset with various numeric variables. I'll try to plot for each combination of two variables a contour/heat map plot, which shows the distribution/density of datapoints with respect to the corresponding pair. For example, ggplot(data, aes(x=var1, y=var2) ) + stat_density_2d(aes(fill = ..density..), geom = "tile", contour = FALSE )+ scale_fill_gradient2(low="darkblue",high="darkred",mid="white",midpoint=0.005) This results in the following picture The issue is now: My data,

Matplotlib: Multiple legends for contour plot for multiple contour variables

只愿长相守 提交于 2020-01-03 02:47:06
问题 I need to make multiple contours plots of several variables on the same page. I can do this with MATLAB (see below for MATLAB code). I cannot get matplotlib to show multiple legends. Any help would be much appreciated. Python code: import numpy as np from matplotlib import cm as cm from matplotlib import pyplot as plt delta = 0.25 x = np.arange(-3.0, 3.0, delta) y = np.arange(-2.0, 2.0, delta) X, Y = np.meshgrid(x, y) Z1 = X*np.exp(-X**2-Y**2) Z2 = Y*np.exp(-X**2-Y**2) plt.figure() CS = plt

Contour width measurement along its entire lendth

与世无争的帅哥 提交于 2020-01-02 07:46:13
问题 I am working on a project to measure width of contour. I have detected the contour from the image (see image 1). The next step is to measure the width of the coutour along its length (like shown in image 2). Please suggest me any ideas. I truly appreciate your help! Thank you! masked contour image required width measurement from contour, green lines indicate width I have a function that calculates contours and then next step is to measure the width from selected contours along their length.

Plotly.js: How to avoid overlapping contour lines?

余生颓废 提交于 2020-01-01 07:23:05
问题 Below is an example for creating a contour plot with plotly.js. Some of the contour lines overlap . How can I alter the plotly settings to avoid that (e.g. increase resolution , switch contouring algorithm )? If I plot the same data using conrec.js the contours do not overlap. A. Conrec.js (this works, no overlap) Source code for the example: https://github.com/jasondavies/conrec.js/tree/master/example B. Plotly.js (does not work: overlapping contours) Source code for the example: https:/

matplotlib: assign color to a radius

半城伤御伤魂 提交于 2019-12-31 00:09:41
问题 I have a 3D plot of a disk. Now I would like to plot the surface in color depending on values which are stored in an array. E.g. the radius of the disk is 300mm. The array could like: arr = np.array([[ 114.28, 14], [ 128.57, 16], [ 142.85,19], [ 157.13,20], [ 171.41,21], [ 185.69,22], [ 199.97,24], [ 214.25,27], [ 228.53,29], [ 242.81,30], [ 257.09,31], [ 271.37,34], [ 288.65,35], [ 299.93,36], [ 300,38]]) It means for radius = 114.28 I have the value 14. I would like to plot a circle at

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

喜欢而已 提交于 2019-12-30 07:43:25
问题 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 );

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

为君一笑 提交于 2019-12-30 07:41:33
问题 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 );