def resize_all_images(size): imageids = imagesHandler.get_all_img_ids_string() for img_id in imageids: img = imagesHandler.get_image(img_id) url = imagesHandler.get_full_url(img_id) filename = url.split(dirm.rootDirectory)[1] imgr = cv2.resize(img, (size, size)) cv2.imwrite(dirm.rootDirectory + "/small/" + filename, imgr)
def resize_all_images(size): imageids = imagesHandler.get_all_img_ids_string() for img_id in imageids: img = imagesHandler.get_image(img_id) url = imagesHandler.get_full_url(img_id) filename = url.split(dirm.rootDirectory)[1] imgr = cv2.resize(img, (size, size)) cv2.imwrite(dirm.rootDirectory+"/small/"+ filename, imgr )
def plot_raw_TSNE(tsneValues, imageIDs, filename): print "Plotting " + filename filename = filename + "_raw" locations = [ ] #loc keeps track of where the images are being placed in the visualisation #Load Tsne Values x = np.array(tsneValues) #subtract the min of each column x = x - x.min(axis=0) #devide by the max of each column x = x / x.max(axis=0) #get filename fs = imageIDs N = len(fs) #N = length(fs); # size of every individual image s = 250 # size of final image S = 10004 # the final images intitialised G = np.ones((S, S, 3)) # ,'uint8' G = G * 255 for i in range(0, N): a = math.ceil(x[i, 0] * (S - s) + 1) b = math.ceil(x[i, 1] * (S - s) + 1) a = a - ((a - 1) % s) + 1 b = b - ((b - 1) % s) + 1 #print meta,b imgid = fs[i].rstrip('\n') if i % 100 == 0: print i, "/", len(fs) if i == N: print i, "/", len(fs) img = imagesHandler.get_image(imgid) #CROPING #img_crop = util.cropImage(img,100,100) imgr = cv2.resize(img, (s, s)) c = a + s #print c d = b + s G[a:c, b:d, :] = imgr loc = [imgid, a, c, b, d] locations.append(loc) print "Saving Image:" + dirm.outputDirectory + filename + ".jpg" cv2.imwrite(dirm.outputDirectory + filename + ".jpg", G) print "Image Saved" tsneHandler.storeLoc(filename, locations) return G
def plot_raw_TSNE(tsneValues, imageIDs, filename): print "Plotting " + filename filename = filename + "_raw" locations = [] # loc keeps track of where the images are being placed in the visualisation # Load Tsne Values x = np.array(tsneValues) # subtract the min of each column x = x - x.min(axis=0) # devide by the max of each column x = x / x.max(axis=0) # get filename fs = imageIDs N = len(fs) # N = length(fs); # size of every individual image s = 250 # size of final image S = 10004 # the final images intitialised G = np.ones((S, S, 3)) # ,'uint8' G = G * 255 for i in range(0, N): a = math.ceil(x[i, 0] * (S - s) + 1) b = math.ceil(x[i, 1] * (S - s) + 1) a = a - ((a - 1) % s) + 1 b = b - ((b - 1) % s) + 1 # print meta,b imgid = fs[i].rstrip("\n") if i % 100 == 0: print i, "/", len(fs) if i == N: print i, "/", len(fs) img = imagesHandler.get_image(imgid) # CROPING # img_crop = util.cropImage(img,100,100) imgr = cv2.resize(img, (s, s)) c = a + s # print c d = b + s G[a:c, b:d, :] = imgr loc = [imgid, a, c, b, d] locations.append(loc) print "Saving Image:" + dirm.outputDirectory + filename + ".jpg" cv2.imwrite(dirm.outputDirectory + filename + ".jpg", G) print "Image Saved" tsneHandler.storeLoc(filename, locations) return G