masking

CGImage Masking with UIImage pngData()

拥有回忆 提交于 2021-02-10 13:16:09
问题 I'm trying to mask an image in swift. Here's my code: (Normally, originalImg is an image that is loaded from UIImagePickerController and then cropped by UIGraphicsGetImageFromCurrentImageContext() , and makedImage is an image that is drawn by the user, created by UIGraphicsGetImageFromCurrentImageContext() ) func imageMasking(_ originalImg: UIImage, maskImage: UIImage) -> UIImage { let cgMaskImage = maskImage.cgImage! let mask = CGImage(maskWidth: cgMaskImage.width, height: cgMaskImage.height

CGImage Masking with UIImage pngData()

↘锁芯ラ 提交于 2021-02-10 13:16:05
问题 I'm trying to mask an image in swift. Here's my code: (Normally, originalImg is an image that is loaded from UIImagePickerController and then cropped by UIGraphicsGetImageFromCurrentImageContext() , and makedImage is an image that is drawn by the user, created by UIGraphicsGetImageFromCurrentImageContext() ) func imageMasking(_ originalImg: UIImage, maskImage: UIImage) -> UIImage { let cgMaskImage = maskImage.cgImage! let mask = CGImage(maskWidth: cgMaskImage.width, height: cgMaskImage.height

How to extract NetCDF data frame by region using a polygon shapefile

拈花ヽ惹草 提交于 2021-01-29 10:31:32
问题 I'am trying to extract the variable "swh_ku" from multiple NetCDF files together with their corresponding latitude and longitude values into csv files using a polygon shapefile or it's extent. I'm working with Jason-1 global altimetry swath data but I only need the data for the domain represented by the shapefile. I just need help with some lines of code that would complete the working code bellow so I can extract only the data for the region I'm interested in. I've tried several software

Crop image using mask and Python scikit-image

∥☆過路亽.° 提交于 2021-01-28 07:51:04
问题 I'm working in image proceesing and I have the following code to obtain the convex hull of a image: from skimage import io from skimage.color import rgb2gray from skimage.morphology import convex_hull_image original = io.imread('test.png') image = rgb2gray(original) chull = convex_hull_image(image) I want to crop the original image according to the convex hull in order to eliminate empty space that is in the image (original image attached), and have an image that only contains what is inside

Remove columns where every value is masked

◇◆丶佛笑我妖孽 提交于 2021-01-27 07:37:06
问题 I want to remove columns from a masked array where every value in the column is masked. So in the following example: >>> import numpy as np >>> test = np.array([[1,0,0],[0,3,0],[1,4,0]]) >>> test = np.ma.masked_equal(test,0) >>> test [[1 -- --] [-- 3 --] [1 4 --]], >>> np.somefunction(test) [[1 --] [-- 3 ] [1 4 ]] what should np.somefunction() be to get the given output? 回答1: You can use fancy indexing: test[:, ~np.all(test.mask, axis=0)] #masked_array(data = # [[1 --] # [-- 3] # [1 4]], #

Remove columns where every value is masked

倾然丶 夕夏残阳落幕 提交于 2021-01-27 07:31:16
问题 I want to remove columns from a masked array where every value in the column is masked. So in the following example: >>> import numpy as np >>> test = np.array([[1,0,0],[0,3,0],[1,4,0]]) >>> test = np.ma.masked_equal(test,0) >>> test [[1 -- --] [-- 3 --] [1 4 --]], >>> np.somefunction(test) [[1 --] [-- 3 ] [1 4 ]] what should np.somefunction() be to get the given output? 回答1: You can use fancy indexing: test[:, ~np.all(test.mask, axis=0)] #masked_array(data = # [[1 --] # [-- 3] # [1 4]], #

Dart how to add commas to a string number

天涯浪子 提交于 2021-01-21 00:35:13
问题 I'm trying to adapt this: Insert commas into number string to work in dart, but no luck. either one of these don't work: print("1000200".replaceAllMapped(new RegExp(r'/(\d)(?=(\d{3})+$)'), (match m) => "${m},")); print("1000300".replaceAll(new RegExp(r'/\d{1,3}(?=(\d{3})+(?!\d))/g'), (match m) => "$m,")); Is there a simpler/working way to add commas to a string number? 回答1: You just forgot get first digits into group. Use this short one: '12345kWh'.replaceAllMapped(new RegExp(r'(\d{1,3})(?=(

Better way to mask a Fortran array?

别来无恙 提交于 2020-12-29 14:14:05
问题 I am wanting to mask a Fortran array. Here's the way I am currently doing it... where (my_array <=15.0) mask_array = 1 elsewhere mask_array = 0 end where So then I get my masked array with: masked = my_array * mask_array Is there a more concise way to do this? 回答1: Use the MERGE intrinsic function: masked = my_array * merge(1,0,my_array<=15.0) 回答2: Or, sticking with where , masked = 0 where (my_array <=15.0) masked = my_array I expect that there are differences, in speed and memory