Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.
import numpy import scipy.misc as scm from pylab import * from scipy import ndimage from skimage import img_as_float, filter def dual_gradient_energy(img): R = img[:, :, 0] G = img[:, :, 1] B = img[:, :, 2] hColorR = filter.hsobel(R) vColorR = filter.vsobel(R) hColorG = filter.hsobel(G) vColorG = filter.vsobel(G) hColorB = filter.hsobel(B) vColorB = filter.vsobel(B) energyArr = hColorR*hColorR+vColorR*vColorR+hColorG*hColorG+vColorG*vColorG+hColorB*hColorB+vColorB*vColorB return energyArr def find_seam(img): height,width = img.shape[:2] seamFitness = dual_gradient_energy(img) #for i in range(0, width): #seamFitness[i] = img[i] for x in range(0, width-2): for y in range (1, height-2): #seamFitness[x][y] = img[x][y] if (x>0) and (x<width) and (y==0): seamFitness[x][y] += min(seamFitness[x][y-1], seamFitness[x+1][y-1]) if (x>0) and (x == width-1): seamFitness[x][y] += min(seamFitness[x][y-1], seamFitness[x-1][y-1]) if (x!=0): seamFitness[x][y] += min(seamFitness[x-1][y-1], seamFitness[x][y-1], seamFitness[x+1][y-1]) return seamFitness[y] def remove_seam(img,seam): attempt = 0 i = 0 height,width = img.shape[:2] seamFitness = np.zeros((height, width)) for attempt in range(attempt, img.size): bestRow = 0 for i in range(i, height-img.size): if (seamFitness[width-1][bestRow] > seamFitness[width-1][i]): bestRow = i x = width-1 if (x > 0): theMin = seamFitness[x-1][bestRow] if (bestRow > 0 and seamFitness[x-1][bestRow-1] <= theMin): bestRow = bestRow-1 elif (bestRow < height-1 and seamFitness[x-1][bestRow+1] <= theMin): bestRow = bestRow+1 return img def plot_seam(img, seam): height,width,dim = img.shape for i in xrange(0,len(seam)): img[i][seam[i]] = 255 img[i][seam[i]] = 0 img[i][seam[i]] = 0 #pass def main(): img = imread('someimage.png') img = img_as_float(img) l=dual_gradient_energy(img) #works! figure() gray() imshow(l) show() r = find_seam(img) print r s = remove_seam(img, r) imshow(plot_seam(img, r)) show() if __name__ == '__main__': main()
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|Java. Convert method from recursion based to iteration based ( loop based )||6||129|
|How do I count sequences in Python with itertools groupby?||3||122|
|Delphi: making a BW image transparent||10||133|
|How are Pi and the degrees in a circle related?||16||35|
Join the community of 500,000 technology professionals and ask your questions.