mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-27 18:25:32 +08:00
Change color definitions from ini file to python module
This simplifies the code and allows users to use either `color_dict` or module variables, e.g., `rgb_colors.white`.
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
import os
|
||||
import ast
|
||||
import warnings
|
||||
import itertools
|
||||
import ConfigParser
|
||||
|
||||
import numpy as np
|
||||
|
||||
from skimage import img_as_float
|
||||
from skimage._shared.utils import is_str
|
||||
from .colorconv import rgb2gray, gray2rgb
|
||||
from . import rgb_colors
|
||||
|
||||
|
||||
__all__ = ['color_dict', 'label2rgb', 'DEFAULT_COLORS']
|
||||
@@ -18,14 +16,7 @@ DEFAULT_COLORS = ('red', 'blue', 'yellow', 'magenta', 'green',
|
||||
'indigo', 'darkorange', 'cyan', 'pink', 'yellowgreen')
|
||||
|
||||
|
||||
def _load_colors():
|
||||
directory, _ = os.path.split(os.path.abspath(__file__))
|
||||
config_file = os.path.join(directory, 'colors.ini')
|
||||
|
||||
parser = ConfigParser.ConfigParser()
|
||||
parser.read(config_file)
|
||||
return dict((k, ast.literal_eval(v)) for k, v in parser.items('colors'))
|
||||
color_dict = _load_colors()
|
||||
color_dict = rgb_colors.__dict__
|
||||
|
||||
|
||||
def _rgb_vector(color):
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
[colors]
|
||||
aliceblue = (0.941, 0.973, 1)
|
||||
antiquewhite = (0.98, 0.922, 0.843)
|
||||
aqua = (0, 1, 1)
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
|
||||
def configuration(parent_package='', top_path=None):
|
||||
from numpy.distutils.misc_util import Configuration
|
||||
|
||||
config = Configuration('color', parent_package, top_path)
|
||||
config.add_data_files('colors.ini')
|
||||
|
||||
return config
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from numpy.distutils.core import setup
|
||||
setup(maintainer='scikit-image Developers',
|
||||
maintainer_email='scikit-image@googlegroups.com',
|
||||
description='Image Color Routines',
|
||||
url='https://github.com/scikit-image/scikit-image',
|
||||
license='Modified BSD',
|
||||
**(configuration(top_path='').todict())
|
||||
)
|
||||
Reference in New Issue
Block a user