remap

Color similarity/distance in RGBA color space

岁酱吖の 提交于 2019-11-28 17:08:54
问题 How to compute similarity between two colors in RGBA color space? (where the background color is unknown of course) I need to remap an RGBA image to a palette of RGBA colors by finding the best palette entry for each pixel in the image*. In the RGB color space the most similar color can be assumed to be the one with the smallest euclidean distance. However, this approach doesn't work in RGBA, e.g., Euclidean distance from rgba(0,0,0,0) to rgba(0,0,0,50%) is smaller than to rgba(100%,100%,100%

Remap or Map function in Javascript

落爺英雄遲暮 提交于 2019-11-28 05:58:37
Of late, most of my programming experience has been in Processing , and more recently I have been wanting to branch out a little deeper in to some JavaScript, since they are slightly related. I was just wondering, as my recent searching has turned up nothing, if JavaScript had a similar function to Processing's "map" function, in which a value and it's range is taken and remapped to a new range? More info here: http://processing.org/reference/map_.html PS: Yes, I also know that www.processingjs.org exists, but I was just wondering if JS had such a function natively. The function below produces

How do I use OpenCV's remap function?

依然范特西╮ 提交于 2019-11-27 20:52:00
Here's the simplest possible test case for remap(): import cv2 import numpy as np inimg = np.arange(2*2).reshape(2,2).astype(np.float32) inmap = np.array([[0,0],[0,1],[1,0],[1,1]]).astype(np.float32) outmap = np.array([[10,10],[10,20],[20,10],[20,20]]).astype(np.float32) outimg = cv2.remap(inimg,inmap,outmap,cv2.INTER_LINEAR) print "inimg:",inimg print "inmap:",inmap print "outmap:",outmap print "outimg:", outimg and here's the output: inimg: [[ 0. 1.] [ 2. 3.]] inmap: [[ 0. 0.] [ 0. 1.] [ 1. 0.] [ 1. 1.]] outmap: [[ 10. 10.] [ 10. 20.] [ 20. 10.] [ 20. 20.]] outimg: [[ 0. 0.] [ 0. 0.] [ 0. 0.

Remap or Map function in Javascript

北城以北 提交于 2019-11-27 01:08:14
问题 Of late, most of my programming experience has been in Processing, and more recently I have been wanting to branch out a little deeper in to some JavaScript, since they are slightly related. I was just wondering, as my recent searching has turned up nothing, if JavaScript had a similar function to Processing's "map" function, in which a value and it's range is taken and remapped to a new range? More info here: http://processing.org/reference/map_.html PS: Yes, I also know that www

vim change :x function to delete buffer instead of save & quit

别来无恙 提交于 2019-11-26 05:29:04
I want to set :x in vim gui-mode to delete buffer because I always kill the whole gvim, which is kind of annoying. I know i can specifically set gui problems with if has("gui running") but don't know how to remap :x thanks in advance ps.: maybe the tag/term remap is wrong but I don't know the correct term, that's why google didn't provide any help at all. I find the safest alternative is to use an expression abbreviation: cnoreabbrev <expr> x getcmdtype() == ":" && getcmdline() == 'x' ? 'bd' : 'x' This will ensure the abbreviation will only be expanded to bd when :x is used otherwise just

vim change :x function to delete buffer instead of save & quit

眉间皱痕 提交于 2019-11-26 01:54:45
问题 I want to set :x in vim gui-mode to delete buffer because I always kill the whole gvim, which is kind of annoying. I know i can specifically set gui problems with if has(\"gui running\") but don\'t know how to remap :x thanks in advance ps.: maybe the tag/term remap is wrong but I don\'t know the correct term, that\'s why google didn\'t provide any help at all. 回答1: I find the safest alternative is to use an expression abbreviation: cnoreabbrev <expr> x getcmdtype() == ":" && getcmdline() ==

Remap values in pandas column with a dict

故事扮演 提交于 2019-11-25 21:48:42
问题 I have a dictionary which looks like this: di = {1: \"A\", 2: \"B\"} I would like to apply it to the \"col1\" column of a dataframe similar to: col1 col2 0 w a 1 1 2 2 2 NaN to get: col1 col2 0 w a 1 A 2 2 B NaN How can I best do this? For some reason googling terms relating to this only shows me links about how to make columns from dicts and vice-versa :-/ 回答1: You can use .replace. For example: >>> df = pd.DataFrame({'col2': {0: 'a', 1: 2, 2: np.nan}, 'col1': {0: 'w', 1: 1, 2: 2}}) >>> di =