Questions tagged [mask]

An image mask is a bitmap that specifies an area to paint, but not the color. In effect, an image mask acts as a stencil to specify where to place color on the page. Quartz uses the current fill color to paint an image mask.

A mask is a format expression mainly used in formatting user input in forms.

Common examples of this are date input fields that accepts only numbers and format the typed input with the needed characters:

User enters      Field contents
1                1
12               12
123              12/3
1231             12/31
...              ...
12312012         12/31/2012
2841 questions
188
votes
3 answers

Update row values where certain condition is met in pandas

Say I have the following dataframe: What is the most efficient way to update the values of the columns feat and another_feat where the stream is number 2? Is this it? for index, row in df.iterrows(): if df1.loc[index,'stream'] == 2: # do…
Stanko
  • 4,275
  • 3
  • 23
  • 51
109
votes
8 answers

How can I mask a UIImageView?

I am trying to mask an image with something like this: Would you please help me? I am using this code: - (void) viewDidLoad { UIImage *OrigImage = [UIImage imageNamed:@"dogs.png"]; UIImage *mask = [UIImage imageNamed:@"mask.png"]; …
iOS.Lover
  • 5,923
  • 21
  • 90
  • 162
78
votes
9 answers

Implement an input with a mask

I would like to implement a mask for a text input field which accepts a date. The masked value should display directly inside of the input. Something like this: I wrote the mask as a value in that example, but…
Stanislas Piotrowski
  • 2,595
  • 10
  • 40
  • 59
68
votes
5 answers

OpenCV - Apply mask to a color image

How can I apply mask to a color image in latest python binding (cv2)? In previous python binding the simplest way was to use cv.Copy e.g. cv.Copy(dst, src, mask) But this function is not available in cv2 binding. Is there any workaround without…
pzo
  • 2,087
  • 3
  • 24
  • 42
62
votes
11 answers

How to mask an EditText to show the dd/mm/yyyy date format

How can I format an EditText to follow the "dd/mm/yyyy" format the same way that we can format using a TextWatcher to mask the user input to look like "0.05€". I'm not talking about limiting the characters, or validating a date, just masking to the…
Juan Cortés
  • 20,634
  • 8
  • 68
  • 91
56
votes
7 answers

Simply mask a UIView with a rectangle

I want to know how to simply mask the visible area of a UIView of any kind. All the answers/tutorials I've read so far describe masking with an image, gradient or creating round corners which is way more advanced than what I am after. Example: I…
Accatyyc
  • 5,798
  • 4
  • 36
  • 51
56
votes
6 answers

How to define TextBox input restrictions?

How can I restrict TextBox to accept only capital letters, or for example digits, or forbid to put any special character? Sure it's a piece of cake to catch TextInput event and handle the text here, but is it the proper way to do this?
iLemming
  • 34,477
  • 60
  • 195
  • 309
55
votes
3 answers

Select elements of numpy array via boolean mask array

I have a boolean mask array a of length n: a = np.array([True, True, True, False, False]) I have a 2d array with n columns: b = np.array([[1,2,3,4,5], [1,2,3,4,5]]) I want a new array which contains only the "True"-values, for example c =…
JohnDoe
  • 627
  • 2
  • 6
  • 6
45
votes
11 answers

Converting CIDR address to subnet mask and network address

Given a CIDR address, e.g. 192.168.10.0/24 How to determine mask length? (24) How to determine mask address? (255.255.255.0) How to determine network address? (192.168.10.0)
Dmitry
  • 651
  • 1
  • 8
  • 12
42
votes
9 answers

Mask US phone number string with JavaScript

I need regular express for US Phone Number format.I want to replace the phone number string into below US phone number string format in JavaScript. var number = "4031234789"; And I want to mask it in below format:- number = number.mask('(000)…
Pawan
  • 2,150
  • 11
  • 45
  • 73
40
votes
7 answers

How to properly mask a numpy 2D array?

Say I have a two dimensional array of coordinates that looks something like x = array([[1,2],[2,3],[3,4]]) Previously in my work so far, I generated a mask that ends up looking something like mask = [False,False,True] When I try to use this mask on…
pretzlstyle
  • 2,774
  • 5
  • 23
  • 40
39
votes
7 answers

How to apply a disc shaped mask to a NumPy array?

I have an array like this: >>> np.ones((8,8)) array([[ 1., 1., 1., 1., 1., 1., 1., 1.], [ 1., 1., 1., 1., 1., 1., 1., 1.], [ 1., 1., 1., 1., 1., 1., 1., 1.], [ 1., 1., 1., 1., 1., 1., 1., 1.], …
user816555
  • 445
  • 1
  • 4
  • 7
39
votes
4 answers

How can you turn an index array into a mask array in Numpy?

Is it possible to convert an array of indices to an array of ones and zeros, given the range? i.e. [2,3] -> [0, 0, 1, 1, 0], in range of 5 I'm trying to automate something like this: >>> index_array = np.arange(200,300) array([200, 201, ... ,…
Efreeto
  • 2,132
  • 1
  • 24
  • 25
34
votes
4 answers

Is it possible to have multiple masks with clip-path?

Hi, I wonder whether it's possible to use more than one mask on the same element, just like this: clip-path:polygon(8% 0%, 8% 7%, 14% 12%), polygon(96.4%, 92% 96.4%, 97% 92.3%), polygon(97% 15%, 99% 13%, 99% 0%); With this I would be able to show…
Cain Nuke
  • 2,843
  • 5
  • 42
  • 65
32
votes
2 answers

Android - Is it possible to declare an alpha mask directly within layer-list XML definition?

A newbie question I have this layers.xml that I use as a source for an ImageView. And two images, mask.png and image.jpg layers.xml:
Shlomi Schwartz
  • 8,693
  • 29
  • 109
  • 186
1
2 3
99 100