mask

get mask from contour with OpenCV

痞子三分冷 提交于 2020-05-15 02:07:16
问题 I would like to get an image mask from the contour (it exists only 1 contour) I have computed thanks to cv.findContours. However, while my contour variable is not empty, I do not manage to retrieve an image mask using cv.drawContours, my destination image being always empty. Here is my code: img = mosaicImage[:,:,0].astype('uint8') contours, _ = cv.findContours(img.copy(), cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE) mask = np.zeros(img.shape, np.uint8) cv.drawContours(mask, contours, -1, (0,255,0)

How to resize a contour in opencv 2.4.11 python? (Goal: Object extraction)

折月煮酒 提交于 2020-05-15 01:56:28
问题 I'm super new to opencv, so pardon my ignorance... Basically: I have an object of interest in my image. I would like to extract it. My problems arise from downscaling the original image in order to facilitate processing. I have found a contour of the object on the smaller image. What I would really like to do is use the information about that contour to extract the object from the original full size image. I can really only think of two ways to do this, but I have no idea which of these

Custom circular button for SignIn with Apple

↘锁芯ラ 提交于 2020-04-16 04:53:12
问题 I'm following Apple's guidelines for implementing the "Sign in with Apple" button. In the documentation apple says that it is also possible to use only the logo to create a custom button of "Log in with Apple), also you can also change the shape of the image to have a circular button ... In order to be able to edit the image it also provides insert a mask but I don't understand that we have to create a mask for the button or the selected image. This is what apple wrote in the documentation At

Creating anti-aliased circular mask efficiently

|▌冷眼眸甩不掉的悲伤 提交于 2020-04-13 09:00:09
问题 I am trying to create anti-aliased (weighted and not boolean) circular masks for making circular kernels for use in convolution. radius = 3 # no. of pixels to be 1 on either side of the center pixel # shall be decimal as well; not the real radius kernel_size = 9 kernel_radius = (kernel_size - 1) // 2 x, y = np.ogrid[-kernel_radius:kernel_radius+1, -kernel_radius:kernel_radius+1] dist = ((x**2+y**2)**0.5) mask = (dist-radius).clip(0,1) print(mask) and the output is array([[1. , 1. , 1. , 1. ,

SwiftUI Path as contentShape, doesn't line up with Image

旧城冷巷雨未停 提交于 2020-03-25 23:13:39
问题 TL;DR : I'm using a Path to specify the hit area for an Image . But I don't know how to adjust the Path coordinates to match the layout that SwiftUI decides on... or if I even need to do so. Runtime My (test) app looks like this, Image borders ( not frames) colored for clarity: What I want is for taps in the opaque orange to be handled by that Image . Taps outside the opaque orange — even if within the bounds of the orange image — should "fall through" either to the green image or the gray

SwiftUI Path as contentShape, doesn't line up with Image

两盒软妹~` 提交于 2020-03-25 23:09:20
问题 TL;DR : I'm using a Path to specify the hit area for an Image . But I don't know how to adjust the Path coordinates to match the layout that SwiftUI decides on... or if I even need to do so. Runtime My (test) app looks like this, Image borders ( not frames) colored for clarity: What I want is for taps in the opaque orange to be handled by that Image . Taps outside the opaque orange — even if within the bounds of the orange image — should "fall through" either to the green image or the gray