<s> import numpy as np <EOL> import scipy . ndimage as ndi <EOL> from . . util import img_as_float <EOL> from . . color import rgb2lab <EOL> from . _quickshift_cy import _quickshift_cython <EOL> def quickshift ( image , ratio = <NUM_LIT:1.0> , kernel_size = <NUM_LIT:5> , max_dist = <NUM_LIT:10> , <EOL> return_tree = False , sigma = <NUM_LIT:0> , convert2lab = True , random_seed = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> image = img_as_float ( np . atleast_3d ( image ) ) <EOL> if convert2lab : <EOL> if image . shape [ <NUM_LIT:2> ] != <NUM_LIT:3> : <EOL> ValueError ( "<STR_LIT>" ) <EOL> image = rgb2lab ( image ) <EOL> if kernel_size < <NUM_LIT:1> : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> image = ndi . gaussian_filter ( image , [ sigma , sigma , <NUM_LIT:0> ] ) <EOL> image = np . ascontiguousarray ( image * ratio ) <EOL> segment_mask = _quickshift_cython ( <EOL> image , kernel_size = kernel_size , max_dist = max_dist , <EOL> return_tree = return_tree , random_seed = random_seed ) <EOL> return segment_mask </s>
