python - Generating your own colormap in SciPy -


i'm using python , scipy perform basic image manipulation. i've made image greyscale , subtracted gaussian blur of form of edge detection. i'd make pretty when running .imshow() command. if use 1 of default colormaps, instance,

matplotlib.pyplot.imshow(lena, cmap='binary') 

where lena matrix representing image in question, image appears washed out grey background. looks quite lot this.

i image appear sharper, 2 real colors, white , black, , little (or no) grey in between.

since none of other default colormaps in scipy can this, figured should make own. i'm afraid don't grasp documentation provided scipy.

so let's have colormap tutorial:

cdict = {'red': ((0.0, 0.0, 0.0),                  (0.5, 1.0, 0.7),                  (1.0, 1.0, 1.0)),          'green': ((0.0, 0.0, 0.0),                    (0.5, 1.0, 0.0),                    (1.0, 1.0, 1.0)),          'blue': ((0.0, 0.0, 0.0),                   (0.5, 1.0, 0.0),                   (1.0, 0.5, 1.0))}  my_cmap = matplotlib.colors.linearsegmentedcolormap('my_colormap', cdict, 256) matplotlib.pyplot.imshow(lena, cmap=my_cmap) 

how should if want colormap exclusively white range 0 .5, , exclusively black range .5 1? help!

i expect this:

cdict = {'red': ((0.0, 0.0, 0.0),                  (0.5, 0.0, 0.0),                  (0.5, 1.0, 1.0),                  (1.0, 1.0, 1.0)),          'green': ((0.0, 0.0, 0.0),                  (0.5, 0.0, 0.0),                  (0.5, 1.0, 1.0),                  (1.0, 1.0, 1.0)),          'blue': ((0.0, 0.0, 0.0),                  (0.5, 0.0, 0.0),                  (0.5, 1.0, 1.0),                  (1.0, 1.0, 1.0))} 

see also: http://matplotlib.org/examples/pylab_examples/custom_cmap.html
please excuse me if i'm wrong. never created jumps 1 want.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -