本文整理汇总了Python中scipy.misc.imresize函数的典型用法代码示例。如果您正苦于以下问题:Python imresize函数的具体用法?Python imresize怎么用?Python imresize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imresize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: interpolateXYim
def interpolateXYim(self):
newWidth = self.image.shape[1]
if newWidth > 1500:
newWidth = 1500
newHeight = int(self.image.shape[0]*newWidth/float(self.image.shape[1]))
print newWidth, newHeight, 'newWidth, newHeight'
print self.image.size, 'size'
#if self.image.size == 2:
# self.image = misc.imresize(self.image, (newHeight, newWidth), mode = 'F')
# elif self.image.size == 3:
# print self.image.shape[2], 'shape2'
# self.image = misc.imresize(self.image, (newHeight, newWidth, self.image.shape[2]), mode = 'F')
# else:
self.image = misc.imresize(self.image, (newHeight, newWidth))
else:
newHeight = self.image.shape[0]
imX = self.Xmat
imY = self.Ymat
imX[imX == 0.] = np.nan
imY[imY == 0.] = np.nan
imX = misc.imresize(imX,(newHeight, newWidth), interp = 'bicubic', mode = 'F')
imY = misc.imresize(imY,(newHeight, newWidth), interp = 'bicubic', mode = 'F')
self.Xmat = imX
self.Ymat = imY
开发者ID:ArArgyridis,项目名称:pic2map,代码行数:34,代码来源:ortho.py
示例2: preprocess_screen
def preprocess_screen(self, observation):
screen_width = config.ale_screen_size[0]
screen_height = config.ale_screen_size[1]
new_width = config.ale_scaled_screen_size[0]
new_height = config.ale_scaled_screen_size[1]
if len(observation.intArray) == 100928:
observation = np.asarray(observation.intArray[128:], dtype=np.uint8).reshape((screen_width, screen_height, 3))
observation = spm.imresize(observation, (new_height, new_width))
# Clip the pixel value to be between 0 and 1
if config.ale_screen_channels == 1:
# Convert RGB to Luminance
observation = np.dot(observation[:,:,:], [0.299, 0.587, 0.114])
observation = observation.reshape((new_height, new_width, 1))
observation = observation.transpose(2, 0, 1) / 255.0
observation /= (np.max(observation) + 1e-5)
else:
# Greyscale
if config.ale_screen_channels == 3:
raise Exception("You forgot to add --send_rgb option when you run ALE.")
observation = np.asarray(observation.intArray[128:]).reshape((screen_width, screen_height))
observation = spm.imresize(observation, (new_height, new_width))
# Clip the pixel value to be between 0 and 1
observation = observation.reshape((1, new_height, new_width)) / 255.0
observation /= (np.max(observation) + 1e-5)
observed_screen = observation
if self.last_observed_screen is not None:
observed_screen = np.maximum(observation, self.last_observed_screen)
self.last_observed_screen = observation
return observed_screen
开发者ID:musyoku,项目名称:deep-q-network,代码行数:31,代码来源:agent.py
示例3: test_bicubic
def test_bicubic():
origin = io.imread('baby_GT[gray].bmp')
im_jor = io.imread('baby_JOR[gray].bmp')
im_my = io.imread("baby_MY[gray].bmp")
image = io.imread('baby_GT.bmp')
shape = origin.shape
if len(shape) == 3:
test_img = image[:shape[0]-shape[0] % 3, :shape[1]-shape[1] % 3, :]
else:
test_img = image[:shape[0]-shape[0] % 3, :shape[1]-shape[1] % 3]
lim = imresize(test_img, 1/3.0, 'bicubic')
mim = imresize(lim, 2.0, 'bicubic')
rim = imresize(lim, 3.0, 'bicubic')
lim = np.asarray(tc.rgb2ycbcr(lim)[:, :, 0], dtype=float)
image = np.asarray(tc.rgb2ycbcr(test_img)[:, :, 0], dtype=float)
mim = np.asarray(tc.rgb2ycbcr(mim)[:, :, 0], dtype=float)
rim = np.asarray(tc.rgb2ycbcr(rim)[:, :, 0], dtype=float)
print psnr(image*1.0, rim*1.0)
print psnr(image*1.0, im_my[0:504,0:504]*1.0)
plt.subplot(221)
plt.imshow(image, interpolation="None", cmap=cm.gray)
plt.subplot(222)
plt.imshow(np.abs(rim), cmap=cm.gray)
plt.subplot(223)
plt.imshow(np.abs(im_my), interpolation="None", cmap=cm.gray)
plt.subplot(224)
plt.imshow(np.abs(im_jor), interpolation="None", cmap=cm.gray)
plt.show()
开发者ID:liangz0707,项目名称:mySuperResolution,代码行数:35,代码来源:analsys.py
示例4: downsample
def downsample(x,p_down):
size = len(imresize(x[0].reshape(28,28),p_down,mode='F').ravel())
s_tr = np.zeros((x.shape[0], size))
for i in xrange(x.shape[0]):
img = x[i].reshape(28,28)
s_tr[i] = imresize(img,p_down,mode='F').ravel()
return s_tr
开发者ID:DaiDengxin,项目名称:distillation_privileged_information,代码行数:7,代码来源:mnist.py
示例5: load_data
def load_data(trainingData, trainingLabel,
testingData, testingLabel,
resize = False, size = 100, dataset = "IKEA_PAIR"):
trainingData = os.environ[dataset] + trainingData
trainingLabel = os.environ[dataset] + trainingLabel
testingData = os.environ[dataset] + testingData
testingLabel = os.environ[dataset] + testingLabel
X_train = np.array(np.load(trainingData),
dtype = np.float32)
Y_train = np.array(np.load(trainingLabel),
dtype = np.uint8)
X_test = np.array(np.load(testingData),
dtype = np.float32)
Y_test = np.array(np.load(testingLabel),
dtype = np.uint8)
print("resizing....")
if resize:
X_train = np.array([misc.imresize(X_train[i],
size = (size, size, 3)) /255.0
for i in range(X_train.shape[0])], dtype=np.float32)
X_test = np.array([misc.imresize(X_test[i],
size = (size, size, 3)) /255.0
for i in range(X_test.shape[0])], dtype=np.float32)
np.save(trainingData + "_100.npy", X_train)
np.save(testingData + "_100.npy", X_test)
X_train = np.rollaxis(X_train, 3, 1)
X_test = np.rollaxis(X_test, 3, 1)
print("downresizing....")
return X_train, Y_train, X_test, Y_test
开发者ID:jiajunshen,项目名称:MultipleDetection,代码行数:35,代码来源:dataPreparation.py
示例6: main
def main():
scale = 100 #lower this value to make the correlation go faster
image = imread2("./waldo.png")
image = imresize(image, scale)
template = imread2("./template.png")
template = imresize(template, scale)
# make grayscale
image_gray = grayscale(image)
template = grayscale(template)
template_w, template_h = template.shape
gradients_image = gradients(image_gray)
gradients_image /= np.linalg.norm(gradients_image.flatten())
gradients_template = gradients(template)
gradients_template /= np.sum(gradients_template)
# use cross correlation
convolved_gradients = correlate2d(gradients_image, gradients_template, mode="same")
position = np.argmax(convolved_gradients)
position_x, position_y = np.unravel_index(position, gradients_image.shape)
#put a big red dot in the middle of where we found our maxima
dot_rad = 8
image[position_x-dot_rad:position_x+dot_rad,position_y-dot_rad:position_y+dot_rad,0] = 255
image[position_x-dot_rad:position_x+dot_rad,position_y-dot_rad:position_y+dot_rad,1:2] = 0
imsave("./image_matched.png", image )
开发者ID:blackle,项目名称:Year_4,代码行数:28,代码来源:magnitude_match.py
示例7: generate_biomes
def generate_biomes(data_path):
if os.path.isfile(data_path + "biomes.pkl"):
return
moisture = pickle.load(open(data_path+"moisture.pkl", 'rb'))
moisture = imresize(moisture, (IMAGE_HEIGHT, IMAGE_WIDTH))
plt.imshow(moisture)
plt.show()
moisture = np.digitize(moisture, [0, 100, 170, 230, 255])-1
moisture[moisture > 4] = 4
plt.imshow(moisture)
plt.show()
temp = pickle.load(open(data_path+"temperature.pkl", 'rb'))
temp = imresize(temp, (IMAGE_HEIGHT, IMAGE_WIDTH))
plt.imshow(temp)
plt.show()
temp = np.digitize(temp, [0, 90, 130, 255])-1
temp[temp > 2] = 2
plt.imshow(temp)
plt.show()
biomes = [
[BARE, TUNDRA, TAIGA, SNOW, OCEAN],
[GRASSLAND, WOODLAND, TEMPERATE_FOREST, TEMPERATE_RAINFOREST, OCEAN],
[DESERT, SAVANNAH, TROPICAL_SEASONAL_FOREST, TROPICAL_RAINFOREST, OCEAN]
]
img = np.zeros((IMAGE_HEIGHT, IMAGE_WIDTH))
for i in range(IMAGE_HEIGHT):
for j in range(IMAGE_WIDTH):
img[i,j] = biomes[temp[i,j]][moisture[i,j]]
elevation = pickle.load(open(data_path+"elevation.pkl", 'rb'))
img[elevation == 0] = OCEAN
plt.imshow(img)
plt.show()
pickle.dump(img, open(data_path+"biomes.pkl", 'wb'))
开发者ID:gumptiousCreator,项目名称:dmtools,代码行数:35,代码来源:worldgen.py
示例8: cropImage
def cropImage(im):
im2 = np.dstack(im).astype(np.uint8)
# return centered 128x128 from original 250x250 (40% of area)
newim = im2[61:189, 61:189]
sized1 = imresize(newim[:,:,0:3], (feature_width, feature_height), interp="bicubic", mode="RGB")
sized2 = imresize(newim[:,:,3:6], (feature_width, feature_height), interp="bicubic", mode="RGB")
return np.asarray([sized1[:,:,0], sized1[:,:,1], sized1[:,:,2], sized2[:,:,0], sized2[:,:,1], sized2[:,:,2]])
开发者ID:alyato,项目名称:lfw_fuel,代码行数:7,代码来源:run-lfw.py
示例9: makeTestPair
def makeTestPair(paths, homography, collection, location=".", size=(250,250), scale = 1.0) :
""" Given a pair of paths to two images and a homography between them,
this function creates two crops and calculates a new homography.
input: paths [strings] (paths to images)
homography [numpy.ndarray] (3 by 3 array homography)
collection [string] (The name of the testset)
location [string] (The location (path) of the testset
size [(int, int)] (The size of an image crop in pixels)
scale [double] (The scale by which we resize the crops after they've been cropped)
out: nothing
"""
# Get width and height
width, height = size
# Load images in black/white
images = map(loadImage, paths)
# Crop part of first image and part of second image:
(top_o, left_o) = (random.randint(0, images[0].shape[0]-height), random.randint(0, images[0].shape[1]-width))
(top_n, left_n) = (random.randint(0, images[1].shape[0]-height), random.randint(0, images[1].shape[1]-width))
# Get two file names
c_path = getRandPath("%s/%s/" % (location, collection))
if not exists(dirname(c_path)) : makedirs(dirname(c_path))
# Make sure we save as gray
pylab.gray()
im1 = images[0][top_o: top_o + height, left_o: left_o + width]
im2 = images[1][top_n: top_n + height, left_n: left_n + width]
im1_scaled = imresize(im1, size=float(scale), interp='bicubic')
im2_scaled = imresize(im2, size=float(scale), interp='bicubic')
pylab.imsave(c_path + "_1.jpg", im1_scaled)
pylab.imsave(c_path + "_2.jpg", im2_scaled)
# Homography for transpose
T1 = numpy.identity(3)
T1[0,2] = left_o
T1[1,2] = top_o
# Homography for transpose back
T2 = numpy.identity(3)
T2[0,2] = -1*left_n
T2[1,2] = -1*top_n
# Homography for scale
Ts = numpy.identity(3)
Ts[0,0] = scale
Ts[1,1] = scale
# Homography for scale back
Tsinv = numpy.identity(3)
Tsinv[0,0] = 1.0/scale
Tsinv[1,1] = 1.0/scale
# Combine homographyies and save
hom = Ts.dot(T2).dot(homography).dot(T1).dot(Tsinv)
hom = hom / hom[2,2]
numpy.savetxt(c_path, hom)
开发者ID:arnfred,项目名称:Mirror-Match,代码行数:60,代码来源:murals.py
示例10: create_mask
def create_mask(self, image, im, blob_list, destination_folder):
mask_file = np.zeros(shape = (image.shape[0],image.shape[1]))
if blob_list is not None:
for bl in blob_list:
x1 = int(bl[0] - bl[2])
y1 = int(bl[1] - bl[2])
x2 = int(bl[0] + bl[2])
y2 = int(bl[1] + bl[2])
x1 = np.max([x1, 0])
y1 = np.max([y1, 0])
x2 = np.min([x2, int(mask_file.shape[0])])
y2 = np.min([y2, int(mask_file.shape[1])])
image1 = image[x1:x2, y1:y2, :]
im1_sh = image1.shape
image1 /= 255
image1_resized = imresize(image1, (128, 128))
image1_transposed = np.asarray (image1_resized.transpose(2,0,1), dtype = 'float32')
final_data = np.ndarray(shape = (1,3,128,128))
final_data[0,:,:,:] = image1_transposed
y_pred = self.model.predict(final_data, verbose = 0)
y_pred = np.where(y_pred > 0.5, 1, 0)
y_pred = np.reshape(y_pred, (64,64))
y_pred = imresize(y_pred, im1_sh)
mask_file[x1:x2, y1:y2] += y_pred
mask_file = np.where(mask_file > 0, 255, 0)
final_path = destination_folder + '/' + im[:-4] + '-mask.jpg'
cv2.imwrite(final_path, mask_file)
开发者ID:ernest-s,项目名称:Data-Hacks,代码行数:27,代码来源:stup.py
示例11: get_image_lena
def get_image_lena(query):
"""
get the image
:param query:
:type query:
:return:
:rtype:
"""
args = query.split(sep='_')
if args[2] == 'grey':
lena = ndimage.imread('lena.jpg', mode='L')
elif args[2] == 'rgb':
lena = ndimage.imread('lena.jpg', mode='RGB')
else:
raise ValueError('Invalid color type. Allowed rgb or grey')
if args[3] == 'small':
lena = misc.imresize(lena, (2048, 2048), interp='bilinear')
elif args[3] == 'large':
lena = misc.imresize(lena, (4096, 4096), interp='bilinear')
else:
raise ValueError('Invalid size. Allowed small or large')
if args[4] == 'uint8':
lena = lena.astype(np.uint8)
elif args[4] == 'float':
lena = lena.astype(np.float)
else:
raise ValueError('Invalid size. Allowed uint8 or float')
return lena
开发者ID:SpikingNeurons,项目名称:Python-Cython-CUDA,代码行数:33,代码来源:benchmark.py
示例12: depth_cluster_2
def depth_cluster_2(depth_map, rgb_downsampled, orb_depth, downsample=5, depth_ratio=1.0, rgb_ratio=1.0, position_ratio=0.1, remove_noise=False):
depth_downsampled = imresize(depth_map, (depth_map.shape[0] / downsample, depth_map.shape[1] / downsample), interp='bicubic')
rgb_downsampled = imresize(rgb_downsampled, (rgb_downsampled.shape[0] / downsample, rgb_downsampled.shape[1] / downsample), interp='bicubic')
rgb_r = rgb_downsampled[:, :, 0].reshape((rgb_downsampled.shape[0] * rgb_downsampled.shape[1],))
rgb_g = rgb_downsampled[:, :, 1].reshape((rgb_downsampled.shape[0] * rgb_downsampled.shape[1],))
rgb_b = rgb_downsampled[:, :, 2].reshape((rgb_downsampled.shape[0] * rgb_downsampled.shape[1],))
depth_flatten = depth_downsampled.reshape((depth_downsampled.size,))
x = np.arange(0, depth_downsampled.shape[1], 1).flatten()
y = np.arange(0, depth_downsampled.shape[0], 1).flatten()
xx, yy = np.meshgrid(x, y, sparse=False)
xx = xx.reshape((xx.size))
yy = yy.reshape((yy.size))
fit_data = np.stack((depth_flatten * depth_ratio, xx * position_ratio, yy * position_ratio,
rgb_r * rgb_ratio, rgb_g * rgb_ratio, rgb_b * rgb_ratio), axis=-1)
xx_init, yy_init = np.where(orb_depth > 0.0)
xx_init /= downsample
yy_init /= downsample
depth_init = depth_downsampled[(xx_init, yy_init)]
rgb_init = rgb_downsampled[(xx_init, yy_init)]
xx_init = xx_init.reshape((xx_init.size,))
yy_init = yy_init.reshape((yy_init.size,))
fit_init = np.stack((depth_init * depth_ratio, xx_init * position_ratio, yy_init * position_ratio,
rgb_init[:, 0] * rgb_ratio, rgb_init[:, 1] * rgb_ratio, rgb_init[:, 2] * rgb_ratio), axis=-1)
clt = KMeans(n_clusters=fit_init.shape[0], init=fit_init)
clt.fit(fit_data)
_result = clt.labels_.reshape(depth_downsampled.shape)
if remove_noise:
structure = np.ones((3, 3))
labels = np.unique(clt.labels_)
for label in labels:
mask = (_result == label)
eroded_mask = ndimage.binary_erosion(mask, structure)
border = (mask != eroded_mask)
_result[border] = 0
return imresize(_result, depth_map.shape)
开发者ID:hamiee,项目名称:ORB_SLAM_live-map,代码行数:35,代码来源:utils.py
示例13: fastguidedfilter
def fastguidedfilter(I, p, r, eps, s):
I_sub = imresize(I, 1.0/s, 'nearest')
p_sub = imresize(p, 1.0/s, 'nearest')
r_sub = r / s
h_sub, w_sub = I_sub.shape[:2]
N = gf.boxfilter(np.ones((h_sub, w_sub),np.float), r)
mean_I = gf.boxfilter(I_sub, r_sub) / N
mean_p = gf.boxfilter(I_sub, r_sub) / N
mean_Ip = gf.boxfilter(I_sub * p_sub, r_sub) / N
cov_Ip = mean_Ip - mean_I * mean_p
mean_II = gf.boxfilter(I_sub * I_sub, r_sub) / N
var_I = mean_II - mean_I * mean_I
a = cov_Ip / (var_I + eps)
b = mean_p - a * mean_I
mean_a = gf.boxfilter(a, r_sub) / N
mean_b = gf.boxfilter(b, r_sub) / N
mean_a = imresize(mean_a, I.shape[:2], 'bilinear')
mean_b = imresize(mean_b, I.shape[:2], 'bilinear')
q = mean_a * I + mean_b
return q
开发者ID:KhLiu2018,项目名称:Digital-Image-Processing,代码行数:26,代码来源:fastguidedfilter.py
示例14: PosterPreProc
def PosterPreProc(image,**kwargs):
"""
This method takes the image of the foil and creates a smoothed Kuwahara image
used to make the poster for regional thresholding.
Key-word Arguments:
Mask = 0 - Assign the Mask here
kern = 6 - Kernal size for poster opening and closing steps
KuSize = 17 - Size of Kuwahara Filter
Gaus1 = 5 - Size of first Gaussian Blur
Gaus2 = 3 - Size of second Gaussian Blur
rsize = .1 - Resize value
Kuw_only = False - Option to only return the Kuwahara filtered image
ExcludeDirt = True - Option to Exclude dirt
"""
Mask = kwargs.get("Mask",0) # Assign the Mask here
kern = kwargs.get("kern",6) # Kernal size for poster opening and closing steps
KuSize = kwargs.get("KuSize",17) # Size of Kuwahara Filter
Gaus1 = kwargs.get("Gaus1",5) # Size of first Gaussian Blur
Gaus2 = kwargs.get("Gaus2",3) # Size of second Gaussian Blur
rsize = kwargs.get("rsize",.1) # Resize value
Kuw_only = kwargs.get("Kuw_only",False) # Option to only return the Kuwahara filtered image
ExcludeDirt = kwargs.get("ExcludeDirt",True) # Option to Exclude dirt from approximation of shading
ExcludePt = kwargs.get("ExcludePt",False)
img = np.copy(image).astype(np.uint8)
# Calculate the average Apply mask if provided
if type(Mask)==np.ndarray and Mask.shape==image.shape:
if Mask.all() == 0:
averageColor = 0
else:
try:
averageColor = int(np.average(img[(Mask!=0)&(img>=10)&(img<=245)]))
except ValueError:
averageColor = int(np.average(img[(Mask!=0)]))
else:
try:
averageColor = int(np.average(img[(img>=10)&(img<=245)]))
except ValueError:
averageColor = int(np.average(img))
if ExcludeDirt:
img[img<=40]=averageColor
if ExcludePt:
img[img>=(img.max()-10)]=averageColor
if type(Mask)==np.ndarray and Mask.shape==image.shape:
img[Mask==0]=averageColor
proc = img.astype(np.uint8)
proc = misc.imresize(proc,rsize)
proc = cv2.morphologyEx(proc,cv2.MORPH_ERODE, (kern,kern)) # Eliminates most platinum spots
proc = cv2.morphologyEx(proc,cv2.MORPH_DILATE,(kern+1,kern+1)) # Eliminates most dirt spots
proc = cv2.GaussianBlur(proc,(Gaus1,Gaus1),0)
proc = Kuwahara.Kuwahara(proc,KuSize)
if Kuw_only:
return proc
proc = cv2.GaussianBlur(proc,(Gaus2,Gaus2),0)
proc = misc.imresize(proc,img.shape)
return proc
开发者ID:adussault,项目名称:GenesisSEMImgProc,代码行数:60,代码来源:mainanalysis.py
示例15: reshape_images
def reshape_images(cls, source_folder, target_folder, height=128, width=128,
extensions=('.jpg', '.jpeg', '.png')):
""" copy images and reshape them"""
# check source_folder and target_folder:
cls.check_folder_existance(source_folder, throw_error_if_no_folder=True)
cls.check_folder_existance(target_folder, display_msg=False)
if source_folder[-1] == "/":
source_folder = source_folder[:-1]
if target_folder[-1] == "/":
target_folder = target_folder[:-1]
# read images and reshape:
print("Resizing '", source_folder, "' images...")
for filename in os.listdir(source_folder):
if os.path.isdir(source_folder + '/' + filename):
cls.reshape_images(source_folder + '/' + filename,
target_folder + '/' + filename,
height, width, extensions=extensions)
else:
if extensions == '' and os.path.splitext(filename)[1] == '':
copy2(source_folder + "/" + filename,
target_folder + "/" + filename)
image = ndimage.imread(target_folder + "/" + filename, mode="RGB")
image_resized = misc.imresize(image, (height, width))
misc.imsave(target_folder + "/" + filename, image_resized)
else:
for extension in extensions:
if filename.endswith(extension):
copy2(source_folder + "/" + filename,
target_folder + "/" + filename)
image = ndimage.imread(target_folder + "/" + filename, mode="RGB")
image_resized = misc.imresize(image, (height, width))
misc.imsave(target_folder + "/" + filename, image_resized)
开发者ID:zchengquan,项目名称:images-web-crawler,代码行数:34,代码来源:dataset_builder.py
示例16: recon_gridrec
def recon_gridrec(im1, im2, angles, oversampling):
"""Reconstruct two sinograms (of the same CT scan) with direct Fourier algorithm.
Parameters
----------
im1 : array_like
Sinogram image data as numpy array.
im2 : array_like
Sinogram image data as numpy array.
angles : double
Value in radians representing the number of angles of the input sinogram.
oversampling : double
Input sinogram is rescaled to increase the sampling of the Fourier space and
avoid artifacts. Suggested value in the range [1.2,1.6].
"""
v_angles = linspace(0, angles, im1.shape[0], False).astype(float32)
# Call C-code for gridrec with oversampling:
[out1, out2] = paralrecon(im1, im2, v_angles, float(oversampling))
# Rescale output (if oversampling used):
out1 = imresize(out1, (im1.shape[1],im1.shape[1]), interp='bicubic', mode='F')
out2 = imresize(out2, (im2.shape[1],im2.shape[1]), interp='bicubic', mode='F')
# Rotate images 90 degrees towards the left:
out1 = rot90(out1)
out2 = rot90(out2)
# Return output:
return [out1.astype(float32), out2.astype(float32)]
开发者ID:ElettraSciComp,项目名称:STP-Core,代码行数:34,代码来源:rec_gridrec.py
示例17: setUpClass
def setUpClass(cls):
img = imread(get_path('AS15-M-0298_SML.png'), flatten=True)
img_coord = (482.09783936, 652.40679932)
cls.template = sp.clip_roi(img, img_coord, 5)
cls.template = rotate(cls.template, 90)
cls.template = imresize(cls.template, 1.)
cls.search = sp.clip_roi(img, img_coord, 21)
cls.search = rotate(cls.search, 0)
cls.search = imresize(cls.search, 1.)
cls.offset = (1, 1)
cls.offset_template = sp.clip_roi(img, np.add(img_coord, cls.offset), 5)
cls.offset_template = rotate(cls.offset_template, 0)
cls.offset_template = imresize(cls.offset_template, 1.)
cls.search_center = [math.floor(cls.search.shape[0]/2),
math.floor(cls.search.shape[1]/2)]
cls.upsampling = 10
cls.alpha = math.pi/2
cls.cifi_thresh = 90
cls.rafi_thresh = 90
cls.tefi_thresh = 100
cls.use_percentile = True
cls.radii = list(range(1, 3))
cls.cifi_number_of_warnings = 2
cls.rafi_number_of_warnings = 2
开发者ID:USGS-Astrogeology,项目名称:autocnet,代码行数:31,代码来源:test_ciratefi.py
示例18: load
def load(data_len, standarize = True, shrink = True, seed = 48):
import pandas as pd
from scipy.misc import imread, imsave, imresize
from sklearn.preprocessing import StandardScaler
np.random.seed(seed)
img_fnames = pd.read_csv("./lfw_files.txt").values.ravel()
Xb = []
yb = []
for i in range(data_len):
image = imread(np.random.choice(img_fnames))
if shrink:
size_x = 48
size_y = 48
else:
size_x = image.shape[0]
size_y = image.shape[1]
if np.random.random() > 0.5:
Xb.append(imresize(add_rect(image), (size_x,size_y,3)).swapaxes(0,2).swapaxes(1,2))
yb.append(0)
else:
Xb.append(imresize(add_circle(image), (size_x,size_y,3)).swapaxes(0,2).swapaxes(1,2))
yb.append(1)
Xb = np.array(Xb)
if standarize:
Xb = np.array(Xb, np.float32)
n,c,x,y = Xb.shape
Xb = Xb.reshape((n,x*y*c))
sc = StandardScaler(with_mean=True, with_std=True)
Xb = sc.fit_transform(Xb)
Xb = Xb.reshape((n,c,x,y))
return Xb, np.array(yb, dtype=np.int32)
开发者ID:jaykk,项目名称:PUG-Talk-7Dec2015,代码行数:32,代码来源:utils.py
示例19: build
def build(path,pathdir,files,files_eval,labels,labels_eval,all_count,size):
train_labels=labels
test_labels=labels_eval
assert len(train_labels)+len(test_labels)==all_count
train_dates={label:[] for label in train_labels}
test_dates={label:[] for label in test_labels}
for file in (files+files_eval):
label=file[-11:-7]
if label in train_labels:
train_dates[label].append(0.001*(255-np.float32(imresize(imread(file,1),size))))
else:
test_dates[label].append(0.001*(255-np.float32(imresize(imread(file,1),size))))
train_rank_dates={}
for i in range(len(train_dates)):
train_rank_dates[i]=train_dates[train_dates.keys()[i]]
if cnn_only:
return train_rank_dates
print '\ntrain keys:',train_dates.keys()
# print train_rank_dates.keys()
print 'test keys:',test_dates.keys(),'\n'
x_train,y_train=get_sequence_images(train_rank_dates,train_labels,path_length,total_labels_per_seq,size,total_roads)
# x_train,y_train=get_sequence_images(train_dates,train_labels,path_length,total_labels_per_seq,size,total_roads)
x_test,y_test=get_sequence_images(test_dates,test_labels,path_length,total_labels_per_seq,size,total_roads)
return x_train,y_train,x_test,y_test
开发者ID:shincling,项目名称:Deep-Rein4cement,代码行数:29,代码来源:image_all.py
示例20: crop_im
def crop_im(im, bbox, **kwargs):
'''
The bounding box is assumed to be in the form (xmin, ymin, xmax, ymax)
kwargs:
imSz: Size of the image required
'''
cropType = kwargs['cropType']
imSz = kwargs['imSz']
x1,y1,x2,y2 = bbox
x1 = max(0, x1)
y1 = max(0, y1)
x2 = min(im.shape[1], x2)
y2 = min(im.shape[0], y2)
if cropType=='resize':
imBox = im[y1:y2, x1:x2]
imBox = scm.imresize(imBox, (imSz, imSz))
if cropType=='contPad':
contPad = kwargs['contPad']
x1 = max(0, x1 - contPad)
y1 = max(0, y1 - contPad)
x2 = min(im.shape[1], x2 + contPad)
y2 = min(im.shape[0], y2 + contPad)
imBox = im[y1:y2, x1:x2]
imBox = scm.imresize(imBox, (imSz, imSz))
else:
raise Exception('Unrecognized crop type')
return imBox
开发者ID:akumar14,项目名称:pycaffe-utils,代码行数:27,代码来源:other_utils.py
注:本文中的scipy.misc.imresize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论