def hybrid2(F1,F2,sigH,sigL): A = io.imread(F1) # for not color? B = io.imread(F2) # for not color? l=imfilter(A, gauss(7,7,sigH)) h=imfilter(B, gauss(7,7,sigL)) A = io.imread(F1) l = A-l for i in range(h.shape[0]): for j in range(h.shape[1]): for k in range(h.shape[2]): l[i][j][k] = l[i][j][k]/2 h[i][j][k] = h[i][j][k]/2 return (l + h)
def diff_gauss(pixels, width, height): bigGauss = gauss(pixels, width, height, gb_kernel).load() smallGauss = gauss(pixels, width, height, gs_kernel).load() image = PIL.Image.new('RGB', (width, height)) pixels = image.load() for y in range(height): for x in range(width): pixels[x, y] = helpers.subtract(bigGauss[x, y], smallGauss[x, y]) return image
def hybrid1(F1, F2, sigH, sigL): l = io.imread(F1) # for not color? h = io.imread(F2) # for not color? n, m = l.shape[0], l.shape[1] l = np.array(l) h = np.array(h) for i in range(l.shape[2]): l[:, :, i] = filterFFT(l[:, :, i], gauss(n, m, sigH)) l[:, :, i] = filterFFT(h[:, :, i], gauss(n, m, sigL)) A = io.imread(F1) l[:, :, i] = A[:, :, i] - l[:, :, i] for i in range(h.shape[0]): for j in range(h.shape[1]): for k in range(h.shape[2]): h[i][j][k] = h[i][j][k] / 2 l[i][j][k] = l[i][j][k] / 2 return l + h
def harris_detector(imagepath, sigma, k, N): win = 2 * sigma + 1 winsmooth = 2 * sigma + 1 img = Image.open(imagepath).convert('L') im = np.array(img) gx = gaussian.gaussx(win, sigma) gy = gaussian.gaussy(win, sigma) # Ix = conv2D.conv2D(im,gx) slow # Iy = conv2D.conv2D(im,gy) slow Ix = signal.convolve2d(im, gx) Iy = signal.convolve2d(im, gy) Ixx = Ix * Ix Iyy = Iy * Iy Ixy = Ix * Iy gsmooth = gaussian.gauss(winsmooth, sigma) # Wxx = conv2D.conv2D(Ixx,gsmooth) slow # Wyy = conv2D.conv2D(Iyy,gsmooth) slow # Wxy = conv2D.conv2D(Ixy,gsmooth) slow Wxx = signal.convolve2d(Ixx, gsmooth) Wyy = signal.convolve2d(Iyy, gsmooth) Wxy = signal.convolve2d(Ixy, gsmooth) imfxx = Image.fromarray(Wxx) imfyy = Image.fromarray(Wyy) imfxy = Image.fromarray(Wxy) # imfxx.show() # imfyy.show() # imfxy.show() detA = Wxx * Wyy - Wxy**2 traceA = Wxx + Wyy H = detA - k * traceA**2 # himg = Image.fromarray(H) # himg.show() f = peak_local_max(H, min_distance=8, num_peaks=N, indices=True) siz = len(f) # print(len(y)) for k in range(siz): cv2.circle(im, (itemgetter(1)(f[k]), itemgetter(0)(f[k])), 4, (0, 0, 0), thickness=1, lineType=1, shift=0) imgf = Image.fromarray(im) imgf.show() return f
fptr = open("air_resistance.txt", "r", newline=None) list_of_results = fptr.readlines() data = [] for result in list_of_results: data.append(float(result)) standard_dev = 0.00573 # add in sigma here mean_val = 0.434038 # add in the mean value here print_file = "Gaussian_Module_Test.pdf" gauss(standard_dev, data, mean_val, print_file) A = plt.hist(data, 5, facecolor="m", alpha=0.75, edgecolor="k") # plots a histogram with five bins plt.savefig("gauss_hist.pdf") print( A ) # returns the amount of values in each bin, shown in first array in terminal values = A[0] # amount of values in each bin bin_vals = [] for i in range(0, len(values)): bin_vals.append(int(values[i]))