mask

Apply function to masked numpy array

梦想与她 提交于 2019-12-30 07:14:08
问题 I've got an image as numpy array and a mask for image. from scipy.misc import face img = face(gray=True) mask = img > 250 How can I apply function to all masked elements? def foo(x): return int(x*0.5) 回答1: For that specific function, few approaches could be listed. Approach #1 : You can use boolean indexing for in-place setting - img[mask] = (img[mask]*0.5).astype(int) Approach #2 : You can also use np.where for a possibly more intuitive solution - img_out = np.where(mask,(img*0.5).astype(int

Masking shapes in HTML5 canvas?

怎甘沉沦 提交于 2019-12-30 00:07:44
问题 Apologies if this has been asked elsewhere but it's pretty hard to phrase as it is so I couldn't find anything. Is there any way to implement masks in canvas? For example, using shapes only (no images) I draw a house with a window. I also have a shape representing a person. I want that person to appear at the window - but obviously only so much as the window allows should be visible of the person. The rest would be masked. I thought about emptying the part of the house occupied by the window,

Android - Creating a circular mask on video

老子叫甜甜 提交于 2019-12-29 05:20:17
问题 I'm relatively new to Android development, and I was wondering if it's possible to mask a VideoView into a shape. This is what I have so far: Expected Result My XML for video view and layout: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#0088ff" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen

How to mask credit card numbers in log files with Log4J?

泪湿孤枕 提交于 2019-12-27 22:12:38
问题 Our web app needs to be made PCI compliant, i.e. it must not store any credit card numbers. The app is a frontend to a mainframe system which handles the CC numbers internally and - as we have just found out - occasionally still spits out a full CC number on one of its response screens. By default, the whole content of these responses are logged at debug level, and also the content parsed from these can be logged in lots of different places. So I can't hunt down the source of such data leaks.

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

耗尽温柔 提交于 2019-12-27 10:22:22
问题 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.], [ 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.]]) I'm creating a disc shaped mask with radius 3 thus: y,x = np.ogrid[-3: 3+1, -3: 3+1] mask = x**2+y**2 <= 3**2 This gives: >> mask array([[False, False, False, True

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

前提是你 提交于 2019-12-27 10:20:46
问题 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.], [ 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.]]) I'm creating a disc shaped mask with radius 3 thus: y,x = np.ogrid[-3: 3+1, -3: 3+1] mask = x**2+y**2 <= 3**2 This gives: >> mask array([[False, False, False, True

03JavaScript程序设计修炼之道_2019-07-02_21-47-36_ 鼠标弹起拖拽、放大镜、mouseenter&mouseleave、

人走茶凉 提交于 2019-12-26 05:04:19
26drag.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> * { padding: 0; margin: 0; } .box { width: 100px; height: 100px; border: 20px solid gray; border-top-width: 30px; padding: 12px; background-color: blue; cursor: move; position: absolute; } </style> </head> <body> <div class="box" id="box"></div> <script> var box = document.querySelector("#box"); box.onmousedown = function(e) { var e = e || event; // 记住点击div的内部偏移量

Css mask not working on Chrome (Webkit)

拟墨画扇 提交于 2019-12-25 12:49:15
问题 I have a problem: I made a picture with some layer and wanted to mask them with the mask css property. It works fine on Firefox, whereas on Chrome it doesn't even with the -webkit- prefixe. Here is the code, note the mask is applied on #plan-1 Maybe Chrome can't make a mask from a jpeg ? :o body{ margin: 0; background-color:black; transform: translateZ(0); height: 100vh; width: 100vw; overflow: hidden; } section{ display: block; background-position: center; height: 100%; width: 100%; position

Css mask not working on Chrome (Webkit)

穿精又带淫゛_ 提交于 2019-12-25 12:48:05
问题 I have a problem: I made a picture with some layer and wanted to mask them with the mask css property. It works fine on Firefox, whereas on Chrome it doesn't even with the -webkit- prefixe. Here is the code, note the mask is applied on #plan-1 Maybe Chrome can't make a mask from a jpeg ? :o body{ margin: 0; background-color:black; transform: translateZ(0); height: 100vh; width: 100vw; overflow: hidden; } section{ display: block; background-position: center; height: 100%; width: 100%; position

Showing only part of background image using CSS3

邮差的信 提交于 2019-12-25 11:00:34
问题 Is it possible to show only a part of a backgroundimage when using CSS3? I want to use an image as a background but only show half of it, so is there something like a mask you can define for your backgroundimages? 回答1: Well only problem is that "clip-path", "mask" and "filter" (no not the IE "filter" but SVG "filter") only works for Firefox and Safari (yes no Chrome). And they do it differently. Firefox needs an svg clippath specified via an id eg: .box { clip-path: url("roundedrect.svg#cp1")