mask

OpenCV Binary Image Mask for Image Analysis in C++

谁都会走 提交于 2019-12-04 09:49:50
问题 I'm trying to analyse some images which have a lot of noise around the outside of the image, but a clear circular centre with a shape inside. The centre is the part I'm interested in, but the outside noise is affecting my binary thresholding of the image. To ignore the noise, I'm trying to set up a circular mask of known centre position and radius whereby all pixels outside this circle are changed to black. I figure that everything inside the circle will now be easy to analyse with binary

Mask specific columns of a numpy array

徘徊边缘 提交于 2019-12-04 08:43:45
I have a 2D numpy array A of (60,1000) dimensions. Say, I have a variable idx=array([3,72,403, 512, 698]) . Now, I want to mask all the elements in the columns specified in idx . The values in these columns might appear in other columns but they shouldn't be masked. Any help would be appriciated. In [22]: A = np.random.rand(5, 10) In [23]: idx = np.array([1, 3, 5]) In [24]: m = np.zeros_like(A) In [25]: m[:,idx] = 1 In [26]: Am = np.ma.masked_array(A, m) In [27]: Am Out[27]: masked_array(data = [[0.680447483547 -- 0.290757600047 -- 0.0718559525615 -- 0.334352145502 0.0861242618662 0

Pandas best way to subset a dataframe inplace, using a mask

一笑奈何 提交于 2019-12-04 06:53:04
I have a pandas dataset that I want to downsize (remove all values under x). The mask is df[my_column] > 50 I would typically just use df = df[mask] , but want to avoid making a copy every time, particularly because it gets error prone when used in functions (as it only gets altered in the function scope). What is the best way to subset a dataset inplace? I was thinking of something along the lines of df.drop(df.loc[mask].index, inplace = True) Is there a better way to do this, or any situation where this won't work at all? You are missing the inplace parameter : df.drop(df[df.my_column < 50]

Stack View ScaleAspectFit Mask Resize in Swift

走远了吗. 提交于 2019-12-04 06:35:37
问题 I am masking an image within a stack view and for some odd reason, my mask is not aligning/resizing correctly with the image. Here is a demonstration of what's occurring as I'm dynamically adding instances of this image in a stack view while each subview is resized within its boundaries and spacing. As you can see, the mask retains the original size of the image and not the resized version. I've tried many different width & height variations including the bounds.width, layer.frame.width,

Reverse a CALayer mask

人盡茶涼 提交于 2019-12-04 06:07:19
I am trying to use a CALayer with an image as contents for masking a UIView. For the mask I have complex png image. If I apply the image as a view.layer.mask I get the opposite behaviour of what I want. Is there a way to reverse the CAlayer? Here is my code: layerMask = CALayer() guard let layerMask = layerMask else { return } layerMask.contents = #imageLiteral(resourceName: "mask").cgImage view.layer.mask = layerMask // What I would like to to is view.layer.mask = layerMask.inverse. // <--- I have seen several posts on reverse CAShapeLayers and Mutable paths, but nothing where I can reverse a

Qt: Extract intensity values clipped by a region of interest polygon

大城市里の小女人 提交于 2019-12-04 05:22:21
问题 Based on a grayscale image and an ordered closed polygon (may be concave), I want to get all grayscale values that lie inside a region of interest polygon (as likewise described in SciPy Create 2D Polygon Mask). What is the most performant realisation of that in Qt 4.8? Endpoint should be some kind of QList<double> . Thanks for your advices. In addition, is it possible to compute a floating point mask (e.g. 0 for outside the polygon, 0.3 for 30% of the pixel area is within the polygon, 1 for

Mask a view in Objective-C

▼魔方 西西 提交于 2019-12-04 05:12:41
In ActionScript 3 we can apply a mask of to a visual object like this: SomeVisualObject.mask = maskShapeObject; How can I achieve similar result in Objective-C ? Assume I have two UIImageView objects, I want something like this: imageView1.mask = imageView2; How can I use one UIImageView to mask, or clip the shape of, another? CALayer *maskLayer = [CALayer layer]; UIImage *maskImage = [UIImage imageNamed:@"maskImage.png"]; maskLayer.contents = (id)maskImage.CGImage; maskLayer.bounds = (CGRect){CGPointZero, maskImage.size}; UIImageView *imageViewToMask = [[UIImageView alloc] initWithFrame

Masking a UIView

核能气质少年 提交于 2019-12-04 01:28:18
问题 I use the following code all the time in my view controller: UIView *view = [[CustomView alloc] init]; UIView *mask = [[CustomMask alloc] init]; [view layer].mask =[mask layer]; and it masks the view as I want. However, when it is not in a view controller I get the error: 'Request for member 'mask' in something not a structure or a union' E.g. I want to apply the mask in the CustomView class itself. So I would have: UIView *mask = [[CustomMask alloc] init]; [self layer].mask =[mask layer];

Animate circular mask of UIImageView in iOS

六月ゝ 毕业季﹏ 提交于 2019-12-04 00:15:50
I am wondering how to animate the scale of a mask on a uiimageview. Example images attached. The gray boxes are the image background of my uiviewcontroller and is not part of the issue. I assume creation of a uiview subclass that I pass an image, a radius and a center point. And then (?) create a mask, and then animate it back and forth? Can anyone point me in the right direction? The circle can be placed anywhere, at any size, but the image to be revealed is always full screen. Eventually I will add a method to shrink the circle back down. But one step at a time. Thank you for the direction,

Converting subnet mask “/” notation to Cisco 0.0.0.0 standard

ぐ巨炮叔叔 提交于 2019-12-03 22:53:26
问题 I've searched SO for help but could'nt find a answer to my question. Situation: I need to convert a "/NN" subnet mask notation (think IPTABLES) to a 0.0.0.0 cisco notation. NN are the number of "1" in the submask, from the lowest octet to the higher. Each octet are 8 bit integers. Possible solution: Make a array of 32 "0" and filling the last NN digits with "1", then group in 4 octets and converting to int... a /23 mask should be like 0.0.1.255. My question is how to do it in .NET... i never