本文整理汇总了Python中skimage.exposure.adjust_sigmoid函数的典型用法代码示例。如果您正苦于以下问题:Python adjust_sigmoid函数的具体用法?Python adjust_sigmoid怎么用?Python adjust_sigmoid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了adjust_sigmoid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: predict_image
def predict_image(self, test_img):
"""
predicts classes of input image
:param test_img: filepath to image to predict on
:param show: displays segmentation results
:return: segmented result
"""
img = np.array( rgb2gray( imread( test_img ).astype( 'float' ) ).reshape( 5, 216, 160 )[-2] ) / 256
plist = []
# create patches from an entire slice
img_1 = adjust_sigmoid( img ).astype( float )
edges_1 = adjust_sigmoid( img, inv=True ).astype( float )
edges_2 = img_1
edges_5_n = normalize( laplace( img_1 ) )
edges_5_n = img_as_float( img_as_ubyte( edges_5_n ) )
plist.append( extract_patches_2d( edges_1, (23, 23) ) )
plist.append( extract_patches_2d( edges_2, (23, 23) ) )
plist.append( extract_patches_2d( edges_5_n, (23, 23) ) )
patches = np.array( zip( np.array( plist[0] ), np.array( plist[1] ), np.array( plist[2] ) ) )
# predict classes of each pixel based on model
full_pred = self.model.predict_classes( patches )
fp1 = full_pred.reshape( 194, 138 )
return fp1
示例2: run
def run(self, img=misc.lena(), increase=True):
img = misc.imread('/Users/Daniel/Desktop/p0.jpg')
img_blurred = self.__blur(img)
img = self.__divide(img, img_blurred)
if False:
img = exposure.adjust_sigmoid(img)
misc.imsave('/Users/Daniel/Desktop/p1.jpg', img)
示例3: preproc
def preproc(self, img, size, pixel_spacing, equalize=True, crop=True):
"""crop center and resize"""
# TODO: this is stupid, you could crop out the heart
# But should test this
if img.shape[0] < img.shape[1]:
img = img.T
# Standardize based on pixel spacing
img = transform.resize(img, (int(img.shape[0]*(1.0/np.float32(pixel_spacing[0]))), int(img.shape[1]*(1.0/np.float32(pixel_spacing[1])))))
# we crop image from center
short_egde = min(img.shape[:2])
yy = int((img.shape[0] - short_egde) / 2)
xx = int((img.shape[1] - short_egde) / 2)
if crop:
crop_img = img[yy : yy + short_egde, xx : xx + short_egde]
# resize to 64, 64
resized_img = transform.resize(crop_img, (size, size))
else:
resized_img = img
#resized_img = gaussian_filter(resized_img, sigma=1)
#resized_img = median_filter(resized_img, size=(3,3))
if equalize:
resized_img = equalize_hist(resized_img)
resized_img = adjust_sigmoid(resized_img)
resized_img *= 255.
return resized_img.astype("float32")
示例4: proc_mbi
def proc_mbi(imgarray):
# Normalize image:
img = img_as_float(imgarray,force_copy=True)
# Image equalization (Contrast stretching):
p2,p98 = np.percentile(img, (2,98))
img = exposure.rescale_intensity(img, in_range=(p2, p98), out_range=(0, 1))
# Gamma correction:
#img = exposure.adjust_gamma(img, 0.5)
# Or Sigmoid correction:
img = exposure.adjust_sigmoid(img)
print "Init Morph Proc..."
sizes = range(2,40,5)
angles = [0,18,36,54,72,90,108,126,144,162]
szimg = img.shape
all_thr = np.zeros((len(sizes),szimg[0], szimg[1])).astype('float64')
all_dmp = np.zeros((len(sizes) - 1,szimg[0], szimg[1])).astype('float64')
idx = 0
for sz in sizes:
print sz
builds_by_size = np.zeros(szimg).astype('float64')
for ang in angles:
print ang
stel = ia870.iaseline(sz, ang)
oprec = opening_by_reconstruction(img, stel)
thr = np.absolute(img-oprec)
builds_by_size += thr
all_thr[idx,:,:] = (builds_by_size / len(angles))
if idx>0:
all_dmp[idx-1,:,:] = all_thr[idx,:,:] - all_thr[idx-1,:,:]
idx += 1
mbi = np.mean(all_dmp, axis=0)
return mbi
示例5: callPeaks
def callPeaks(lane, gain=7, hamming=5, filt=0.2, order=9):
""" Identify peaks in the lane
:Args:
:param lane: The lane which to call peaks.
:type lane: tapeAnalyst.gel_processing.GelLane
:param gain: The gain value to use for increasing contrast (see
skimage.exposure.adjust_sigmoid)
:type gain: int
:param hamming: The value to use Hamming convolution (see
scipy.signal.hamming)
:type gain: int
:param filt: Remove all pixels whose intensity is below this value.
:type filt: float
:param order: The distance allowed for finding maxima (see scipy.signal.argrelmax)
:type order: int
"""
# Increase contrast to help with peak calling
ladj = exposure.adjust_sigmoid(lane.lane, cutoff=0.5, gain=gain)
# Tack the max pixel intensity for each row in then lane's gel image.
laneDist = ladj.max(axis=1)
# Smooth the distribution
laneDist = signal.convolve(laneDist, signal.hamming(hamming))
# Get the locations of the dye front and dye end. Peak calling is difficult
# here because dyes tend to plateau. To aid peak calling, add an artificial
# spike in dye regions. Also remove all peaks outside of the dyes
try:
dyeFrontPeak = int(np.ceil(np.mean([lane.dyeFrontStart, lane.dyeFrontEnd])))
laneDist[dyeFrontPeak] = laneDist[dyeFrontPeak] + 2
laneDist[dyeFrontPeak+1:] = 0
except:
logger.warn('No Dye Front - Lane {}: {}'.format(lane.index, lane.wellID))
try:
dyeEndPeak = int(np.ceil(np.mean([lane.dyeEndStart, lane.dyeEndEnd])))
laneDist[dyeEndPeak] = laneDist[dyeEndPeak] + 2
laneDist[:dyeEndPeak-1] = 0
except:
logger.warn('No Dye End - Lane {}: {}'.format(lane.index, lane.wellID))
# Filter out low levels
laneDist[laneDist < filt] = 0
# Find local maxima
peaks = signal.argrelmax(laneDist, order=order)[0]
return peaks
示例6: test_adjust_inv_sigmoid_cutoff_half
def test_adjust_inv_sigmoid_cutoff_half():
"""Verifying the output with expected results for inverse sigmoid
correction with cutoff equal to half and gain of 10"""
image = np.arange(0, 255, 4, np.uint8).reshape(8,8)
expected = np.array([[253, 253, 252, 252, 251, 251, 250, 249],
[249, 248, 247, 245, 244, 242, 240, 238],
[235, 232, 229, 225, 220, 215, 210, 204],
[197, 190, 182, 174, 165, 155, 146, 136],
[126, 116, 106, 96, 87, 78, 70, 62],
[ 55, 49, 43, 37, 33, 28, 25, 21],
[ 18, 16, 14, 12, 10, 8, 7, 6],
[ 5, 4, 4, 3, 3, 2, 2, 1]], dtype=np.uint8)
result = exposure.adjust_sigmoid(image, 0.5, 10, True)
assert_array_equal(result, expected)
示例7: test_adjust_sigmoid_cutoff_one
def test_adjust_sigmoid_cutoff_one():
"""Verifying the output with expected results for sigmoid correction
with cutoff equal to one and gain of 5"""
image = np.arange(0, 255, 4, np.uint8).reshape(8,8)
expected = np.array([[ 1, 1, 1, 2, 2, 2, 2, 2],
[ 3, 3, 3, 4, 4, 4, 5, 5],
[ 5, 6, 6, 7, 7, 8, 9, 10],
[ 10, 11, 12, 13, 14, 15, 16, 18],
[ 19, 20, 22, 24, 25, 27, 29, 32],
[ 34, 36, 39, 41, 44, 47, 50, 54],
[ 57, 61, 64, 68, 72, 76, 80, 85],
[ 89, 94, 99, 104, 108, 113, 118, 123]], dtype=np.uint8)
result = exposure.adjust_sigmoid(image, 1, 5)
assert_array_equal(result, expected)
示例8: test_adjust_sigmoid_cutoff_zero
def test_adjust_sigmoid_cutoff_zero():
"""Verifying the output with expected results for sigmoid correction
with cutoff equal to zero and gain of 10"""
image = np.arange(0, 255, 4, np.uint8).reshape(8,8)
expected = np.array([[127, 137, 147, 156, 166, 175, 183, 191],
[198, 205, 211, 216, 221, 225, 229, 232],
[235, 238, 240, 242, 244, 245, 247, 248],
[249, 250, 250, 251, 251, 252, 252, 253],
[253, 253, 253, 253, 254, 254, 254, 254],
[254, 254, 254, 254, 254, 254, 254, 254],
[254, 254, 254, 254, 254, 254, 254, 254],
[254, 254, 254, 254, 254, 254, 254, 254]], dtype=np.uint8)
result = exposure.adjust_sigmoid(image, 0, 10)
assert_array_equal(result, expected)
示例9: test_adjust_sigmoid_cutoff_half
def test_adjust_sigmoid_cutoff_half():
"""Verifying the output with expected results for sigmoid correction
with cutoff equal to half and gain of 10"""
image = np.arange(0, 255, 4, np.uint8).reshape(8,8)
expected = np.array([[ 1, 1, 2, 2, 3, 3, 4, 5],
[ 5, 6, 7, 9, 10, 12, 14, 16],
[ 19, 22, 25, 29, 34, 39, 44, 50],
[ 57, 64, 72, 80, 89, 99, 108, 118],
[128, 138, 148, 158, 167, 176, 184, 192],
[199, 205, 211, 217, 221, 226, 229, 233],
[236, 238, 240, 242, 244, 246, 247, 248],
[249, 250, 250, 251, 251, 252, 252, 253]], dtype=np.uint8)
result = exposure.adjust_sigmoid(image, 0.5, 10)
assert_array_equal(result, expected)
示例10: intensity_correction
def intensity_correction(img):
mean_val = np.mean(img)
mean_val = mean_val / 255.
#print(mean_val)
#sigmoid correction
img2 = exp.adjust_sigmoid(img, cutoff = mean_val, gain=5)
#draw(img2, "Sigmoid correction", 4, 3, 4, 4, 3, 5)
#robust linear correction
left, right = np.percentile(img2, (10, 90))
img3 = exp.rescale_intensity(img2, in_range=(left, right))
#draw(img3, "Linear correction", 4, 3, 7, 4, 3, 8)
img4 = filters.gaussian(img3, sigma=.5)
#draw(img4, "Gaussian filter", 4, 3, 10, 4, 3, 11)
return img4
示例11: image_transformation
def image_transformation(X, method_type='blur', **kwargs):
# https://www.kaggle.com/tomahim/image-manipulation-augmentation-with-skimage
q = kwargs['percentile'] if 'percentile' in kwargs else (0.2, 99.8)
angle = kwargs['angle'] if 'angle' in kwargs else 60
transformation_dict = {
'blur': normalize(ndimage.uniform_filter(X)),
'invert': normalize(util.invert(X)),
'rotate': rotate(X, angle=angle),
'rescale_intensity': _rescale_intensity(X, q=q),
'gamma_correction': exposure.adjust_gamma(X, gamma=0.4, gain=0.9),
'log_correction': exposure.adjust_log(X),
'sigmoid_correction': exposure.adjust_sigmoid(X),
'horizontal_flip': X[:, ::-1],
'vertical_flip': X[::-1, :],
'rgb2gray': skimage.color.rgb2gray(X)
}
return transformation_dict[method_type]
示例12: image_equalization
def image_equalization(image_file):
'''
in testing
'''
# Load an example image
img = io.imread(image_file)
#img = data.moon()
#img = 'new.jpg'
# Contrast stretching
p2, p98 = np.percentile(img, (2, 98))
img_rescale = exposure.rescale_intensity(img, in_range=(p2, p98))
img_rescale = exposure.adjust_sigmoid(img_rescale, 0.5, 5)
# Equalization
img_eq = exposure.equalize_hist(img)
# Adaptive Equalization
img_adapteq = exposure.equalize_adapthist(img, clip_limit=0.03)
'''
cv2.imshow('image', img)
cv2.waitKey(0)
'''
cv2.imshow('image', img_rescale)
cv2.waitKey(0)
'''
cv2.imshow('image', img_eq)
cv2.waitKey(0)
cv2.imshow('image', img_adapteq)
cv2.waitKey(0)
'''
cv2.imwrite('new_adj.jpg', img_rescale)
'''
cv2.imwrite('new_adj2.jpg', img_eq)
cv2.imwrite('new_adj3.jpg', img_adapteq)
'''
return ['new_adj.jpg', 1, 2] #'new_adj2.jpg', 'new_adj3.jpg']
示例13: adjust_sigmoid
c.z_sun
# In[ ]:
# In[ ]:
cube.imshow(data=out)
# In[ ]:
out2 = adjust_sigmoid(out)
# In[ ]:
equal = equalize_adapthist(out2)
# In[ ]:
cube.imshow(equal)
# In[ ]:
meta = pd.read_csv('/Users/klay6683/Dropbox/DDocuments/UVIS/straws/coiss_ahires.015.list.txt',
示例14: range
for k in range(0,len(image_file_list),n):
X = []
Y = []
for fname in image_file_list[k:k+n]:
label = label_dict[fname.split('.')[0]]
cur_img = imread(folder+'/'+fname , as_grey=True)
cur_img = 1 - cur_img
# randomly add samples
r_for_eq = random()
if r_for_eq<0.3:
cur_img = equalize_adapthist(cur_img,ntiles_x=5,ntiles_y=5,clip_limit=0.1)
if 0.3<r_for_eq<0.4:
cur_img = adjust_sigmoid(cur_img,cutoff=0.5, gain=10, inv=False)
if 0.5<r_for_eq<0.6:
cur_img = adjust_gamma(cur_img,gamma=0.5, gain=1)
X.append([cur_img.tolist()])
label_vec = [0]*5
label_vec[label] = 1
"""
label_vec = [0]*3
if label == 0 or label == 1:
label_vec[0] = 1
elif label == 2 or label == 3 :
label_vec[1] = 1
else:
示例15:
cov_point_density = []
var_area_density = []
cov_area_density = []
fs_area = []
pairwise = []
image = exposure.equalize_adapthist(A)
io.imshow(image)
plt.grid(False)
# <codecell>
# Process for nuclei
binary = filter.threshold_adaptive(exposure.adjust_sigmoid(A[:, :, 0], cutoff=0.4, gain = 30), 301).astype(bool)
clean = morphology.binary_closing(binary, morphology.disk(3)).astype(bool)
clean = morphology.remove_small_objects(clean, 200)
clean = morphology.remove_small_objects( (1-clean).astype(bool), 200)
io.imshow(clean)
plt.grid(False)
# <codecell>
# Find contour of inflammatory zone
local_density = filter.gaussian_filter(clean, 61)
local_density -= local_density.min()
local_density /= local_density.max()