mask

Create mask by first positions only

南楼画角 提交于 2019-12-07 06:04:34
问题 I have array: a = np.array([[ 0, 1, 2, 0, 0, 0], [ 0, 4, 1, 35, 0, 10], [ 0, 0, 5, 4, 0, 4], [ 1, 2, 5, 4, 0, 4]]) I need select only from first consecutive 0 in each row: [[ True False False False False False] [ True False False False False False] [ True True False False False False] [ False False False False False False]] I try: a[np.arange(len(a)), a.argmax(1): np.arange(len(a)), [0,0,0]] = True But this is wrong. 回答1: You can use np.cumsum . Assumption: you are looking for zeros only at

Using an UIView as a Mask in another UIView on Swift

百般思念 提交于 2019-12-07 01:35:17
问题 I am developing an App on xCode with Swift. My screen has an Image of an animal (outlet "backImage"), over this image I have a view (outlet "coverView"), color black, which covers all the screen. So so far you can't see the animal image, because the "coverView" is in front of it. Then I have another view (outlet "maskView") which is smaller and it's over the big view "coverView". What I want is to use this "maskView" as mask and therefor see the "backImage" through it, like a window. Is there

How to get a CGImageRef from Context-Drawn Images?

那年仲夏 提交于 2019-12-06 21:41:01
问题 Ok using coregraphics, I'm building up an image which will later be used in a CGContextClipToMask operation. It looks something like the following: UIImage *eyes = [UIImage imageNamed:@"eyes"]; UIImage *mouth = [UIImage imageNamed:@"mouth"]; UIGraphicsBeginImageContext(CGSizeMake(150, 150)); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetRGBFillColor(context, 0, 0, 0, 1); CGContextFillRect(context, bounds); [eyes drawInRect:bounds blendMode:kCGBlendModeMultiply alpha:1];

kineticjs - mask/contain images so no overlap

孤人 提交于 2019-12-06 15:25:43
i have 2 images on my stage underneath an overlay image of 2 frames. The user can drag each image as if they were positioninng each image inside a photo frame. The problem i have is the yoda image in this example can overlap and appear inside the darth vader frame on the left (and vice-versa), as shown here: jsfiddle here: http://jsfiddle.net/vTLkn/ Is there a way of placing the images inside some form of container or rectangle to stop this so they cannot appear inside another 'frame'? The final page could end up having up to 5 or 6 frames and images with each image able to be scaled up or

advanced usage of matlab roipoly command

别等时光非礼了梦想. 提交于 2019-12-06 13:54:34
问题 I am new to matlab and am working on Image processing. I am using the roipoly function to create a mask. As I understand I can use it like this : I = imread('eight.tif'); c = [222 272 300 270 221 194]; r = [21 21 75 121 121 75]; BW = roipoly(I,c,r); figure, imshow(I) figure, imshow(BW) The image is shown below : One observation I had was that the interpolation between the adjacent points as specified by the c & r matrix is done by 'Linear Interpolation', in other sense always a straight line

Python Open CV2 Color Detection Mask to Pixel Coordinates

柔情痞子 提交于 2019-12-06 13:33:38
I am currently working in Python to do color detection on a single image. After loading my image and establishing my RGB (or BGR in CV2), I use the following 2 lines to produce a mask and a output image. mask = cv2.inRange(image, lower, upper) output = cv2.bitwise_and(image, image, mask = mask) Then the code displays the following image. But now, I would like to take the processed image and extract pixel coordinate points for the green line. Thanks. Any help would be appreciated. Soltius So, how about findNonZeros() on a binarised version of your image ? Starting with the image with the green

Boolean array with no all True values in one row

半世苍凉 提交于 2019-12-06 13:13:35
I have numpy array : np.random.seed(100) mask = np.random.choice([True, False], size=(10,3)) print (mask) [[ True True False] [False False False] [ True True True] <- problem - all values True [ True True False] [ True True True] <- problem - all values True [ True False True] [ True False True] [False True True] [ True False False] [False True True]] Need in each row no all values True - so here can be only 0 , 1 or 2 True because 3 'columns' . Ugly solution is: mask[:, -1] = False print (mask) [[ True True False] [False False False] [ True True False] [ True True False] [ True True False] [

OpenGL - don't write depth if alpha

两盒软妹~` 提交于 2019-12-06 09:57:03
问题 What I'm want to do in OpenGL using C++ and GLSL: When texture has alpha (texture.a! = 1.0;) then this pixel is not written to the depth buffer. (for color buffer it is written) Write depth occurs only when a pixel texture.a == 1.0; Discarding in shader is not a solution - then this pixel is not written to color buffer. Any ideas? @UPDATE: Example: I've got some UI images rendered by OpenGL. Some of them have alpha in corners. In scene rendering I have "depth prepass" to save some pixels by

gdal ReadAsarray for vrt extremely slow

巧了我就是萌 提交于 2019-12-06 08:49:02
问题 I am trying to simply subtract two rasters and save the result in another raster. One of the input images is a tif-file, the other is a vrt-file. (Output is tif) The files are very big, so I open them, divide them into tiles and run through each of them and then subtracting. The problem is that it is extremely slow! import gdal import numpy as np rA = gdal.Open(raFileName) rB = gdal.Open(rbFileName) nodataA = rA.GetRasterBand(1).GetNoDataValue() nodataB = rB.GetRasterBand(1).GetNoDataValue()

Mask layout with rounded corner xml shape

笑着哭i 提交于 2019-12-06 03:20:28
I have this LinearLayout: <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <ImageView android:layout_width="100dp" android:layout_height="70dp" android:src="@drawable/ic_launcher" android:scaleType="centerCrop"/> <TextView android:layout_width="100dp" android:layout_height="30dp" android:background="#FFD800" android:textColor="@android:color/black" android:gravity="center" android:text="Text View"/> </LinearLayout> And I want to mask it with rounded corner, like this: I tried to put it in a FrameLayout with another layout