Python skimage.exposure.equalize_hist() Examples
The following are 8
code examples of skimage.exposure.equalize_hist().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
skimage.exposure
, or try the search function
.
Example #1
Source File: helper_dataset.py From reseg with GNU General Public License v3.0 | 6 votes |
def rgb2illumination_invariant(img, alpha, hist_eq=False): """ this is an implementation of the illuminant-invariant color space published by Maddern2014 http://www.robots.ox.ac.uk/~mobile/Papers/2014ICRA_maddern.pdf :param img: :param alpha: camera paramete :return: """ ii_img = 0.5 + np.log(img[:, :, 1] + 1e-8) - \ alpha * np.log(img[:, :, 2] + 1e-8) - \ (1 - alpha) * np.log(img[:, :, 0] + 1e-8) # ii_img = exposure.rescale_intensity(ii_img, out_range=(0, 1)) if hist_eq: ii_img = exposure.equalize_hist(ii_img) print np.max(ii_img) print np.min(ii_img) return ii_img
Example #2
Source File: utils.py From cube-in-a-box with MIT License | 6 votes |
def three_band_image(ds, bands, time=0, figsize=[10, 10], projection='projected'): ''' three_band_image takes three spectral bands and plots them on the RGB bands of an image. Inputs: ds - Dataset containing the bands to be plotted bands - list of three bands to be plotted Optional: time - Index value of the time dimension of ds to be plotted figsize - dimensions for the output figure projection - options are 'projected' or 'geographic'. To determine if the image is in degrees or northings ''' t, y, x = ds[bands[0]].shape rawimg = np.zeros((y, x, 3), dtype=np.float32) for i, colour in enumerate(bands): rawimg[:, :, i] = ds[colour][time].values rawimg[rawimg == -9999] = np.nan img_toshow = exposure.equalize_hist(rawimg, mask=np.isfinite(rawimg)) return img_toshow
Example #3
Source File: demo.py From lung-segmentation-2d with MIT License | 6 votes |
def loadDataGeneral(df, path, im_shape): X, y = [], [] for i, item in df.iterrows(): img = img_as_float(io.imread(path + item[0])) mask = io.imread(path + item[1]) img = transform.resize(img, im_shape) img = exposure.equalize_hist(img) img = np.expand_dims(img, -1) mask = transform.resize(mask, im_shape) mask = np.expand_dims(mask, -1) X.append(img) y.append(mask) X = np.array(X) y = np.array(y) X -= X.mean() X /= X.std() print '### Dataset loaded' print '\t{}'.format(path) print '\t{}\t{}'.format(X.shape, y.shape) print '\tX:{:.1f}-{:.1f}\ty:{:.1f}-{:.1f}\n'.format(X.min(), X.max(), y.min(), y.max()) print '\tX.mean = {}, X.std = {}'.format(X.mean(), X.std()) return X, y
Example #4
Source File: load_data.py From lung-segmentation-2d with MIT License | 6 votes |
def loadDataGeneral(df, path, im_shape): """Function for loading arbitrary data in standard formats""" X, y = [], [] for i, item in df.iterrows(): img = img_as_float(io.imread(path + item[0])) mask = io.imread(path + item[1]) img = transform.resize(img, im_shape) img = exposure.equalize_hist(img) img = np.expand_dims(img, -1) mask = transform.resize(mask, im_shape) mask = np.expand_dims(mask, -1) X.append(img) y.append(mask) X = np.array(X) y = np.array(y) X -= X.mean() X /= X.std() print '### Dataset loaded' print '\t{}'.format(path) print '\t{}\t{}'.format(X.shape, y.shape) print '\tX:{:.1f}-{:.1f}\ty:{:.1f}-{:.1f}\n'.format(X.min(), X.max(), y.min(), y.max()) print '\tX.mean = {}, X.std = {}'.format(X.mean(), X.std()) return X, y
Example #5
Source File: LST.py From python-urbanPlanning with MIT License | 5 votes |
def LSTConvolue(self): kernel_rate= np.array([[1/8, 1/8 , 1/8], [1/8, -1, 1/8], [1/8, 1/8, 1/8]]) #卷积核 kernel_id= np.array([[-1, -1 ,-1], [-1 ,8, -1], [-1, -1, -1]]) #卷积核 kernel=kernel_rate t0=time.time() # print(self.LST) array_convolve2d=convolve2d(self.LST,kernel,mode='same')*-1 # print(array_convolve2d.max(),array_convolve2d.min()) # array_convolve2d=exposure.equalize_hist(array_convolve2d) p2, p98 = np.percentile(array_convolve2d, (2,96)) array_convolve2dRescale = exposure.rescale_intensity(array_convolve2d, in_range=(p2, p98)) # print() array_convolve2dZero=np.copy(array_convolve2d) array_convolve2dZero[array_convolve2dZero>0]=1 array_convolve2dZero[array_convolve2dZero<0]=-1 array_convolve2dZero[array_convolve2dZero==0]=0 t1=time.time() t_convolve2d=t1-t0 print("lasting time:",t_convolve2d) self.imgShow(imges=(self.LST,array_convolve2dRescale,array_convolve2dZero),titleName=("array","array_convolve2d_rescale","0",),xyticksRange=(1,1)) return array_convolve2d,array_convolve2dZero ##显示图像
Example #6
Source File: load_data.py From lung-segmentation-2d with MIT License | 5 votes |
def loadDataMontgomery(df, path, im_shape): """Function for loading Montgomery dataset""" X, y = [], [] for i, item in df.iterrows(): img = img_as_float(io.imread(path + item[0])) gt = io.imread(path + item[1]) l, r = np.where(img.sum(0) > 1)[0][[0, -1]] t, b = np.where(img.sum(1) > 1)[0][[0, -1]] img = img[t:b, l:r] mask = gt[t:b, l:r] img = transform.resize(img, im_shape) img = exposure.equalize_hist(img) img = np.expand_dims(img, -1) mask = transform.resize(mask, im_shape) mask = np.expand_dims(mask, -1) X.append(img) y.append(mask) X = np.array(X) y = np.array(y) X -= X.mean() X /= X.std() print '### Data loaded' print '\t{}'.format(path) print '\t{}\t{}'.format(X.shape, y.shape) print '\tX:{:.1f}-{:.1f}\ty:{:.1f}-{:.1f}\n'.format(X.min(), X.max(), y.min(), y.max()) print '\tX.mean = {}, X.std = {}'.format(X.mean(), X.std()) return X, y
Example #7
Source File: preprocess_JSRT.py From lung-segmentation-2d with MIT License | 5 votes |
def make_lungs(): path = '/path/to/JSRT/All247images/' for i, filename in enumerate(os.listdir(path)): img = 1.0 - np.fromfile(path + filename, dtype='>u2').reshape((2048, 2048)) * 1. / 4096 img = exposure.equalize_hist(img) io.imsave('/path/to/JSRT/new/' + filename[:-4] + '.png', img) print 'Lung', i, filename
Example #8
Source File: AugmentationPipeline.py From 3d-dl with MIT License | 4 votes |
def adaptive_equalize(img): # Adaptive Equalization img = img_as_float(img) img_adapteq = exposure.equalize_hist(img) return img_adapteq