def run_foa(sample, gt): # Import image test_image = foai.ImageObject(sample, rgb=False) test_image.ground_truth = gt # Generate Gaussian Blur Prior - Time ~0.0020006 foveation_prior = foac.matlab_style_gauss2D(test_image.modified.shape, 300) # Generate Gamma Kernel k = np.array([1, 9], dtype=float) mu = np.array([0.2, 0.5], dtype=float) kernel = foac.gamma_kernel(mask_size=(14, 14), k=k, mu=mu) # plt.imshow(kernel) # Generate Saliency Map foac.convolution(test_image, kernel, foveation_prior) # Bound and Rank the most Salient Regions of Saliency Map foas.salience_scan(test_image, rank_count=3, bbox_size=(28, 28)) test_image.draw_image_patches() test_image.plot_main() test_image.plot_patches() plt.show() return test_image
def run_foa(sample, prior, kernel, bbox=(28, 28)): # Import image img = foai.ImageObject(sample, rgb=False) # Generate Saliency Map foac.convolution(img, kernel, prior) # Bound and Rank the most Salient Regions of Saliency Map foas.salience_scan(img, rank_count=1, bbox_size=bbox) img.draw_image_patches() # img.plot_main() # Pad patches to be the same size (28x28) patch = img.patch_list[0] if (patch.shape != bbox): pad = np.zeros(bbox) pad[:patch.shape[0], :patch.shape[1]] = patch patch = pad return patch.reshape(1, bbox[0], bbox[1])
def run_foa_svhn(input=SVHNImage, tf=int, gt=None, k=None, mu=None): assert (input.image is not None) img = np.array(input.image) x_dim = img.shape[0] y_dim = img.shape[1] print(np.array(img.shape)) # Load Image Object img = foai.ImageObject(img) img.ground_truth = gt # Generate Gaussian Blur Prior - Time ~0.0020006 foveation_prior = foac.matlab_style_gauss2D(img.modified.shape, 300) # Generate Gamma Kernel # k = np.array([1, 26, 1, 25, 1, 19], dtype=float) # mu = np.array([2, 2, 1, 1, 0.5, 0.5], dtype=float) k = np.array([1, 5, 1, 9, 1, 13], dtype=float) mu = np.array([0.8, 0.7, 0.3, 0.5, 0.1, 0.3], dtype=float) kernel = foac.gamma_kernel(img, mask_size=(32, 32), k=k, mu=mu) # Generate Saliency Map start = time.time() foac.convolution(img, kernel, foveation_prior) stop = time.time() print(f"Salience Map Generation: {stop - start} seconds") # Bound and Rank the most Salient Regions of Saliency Map foas.salience_scan(img, rank_count=4, bbox_size=(y_dim // 4, y_dim // 4)) bbt = 2 if (x_dim < 100 and y_dim < 100): bbt = 1 img.draw_image_patches(bbt=bbt) # Threshold img.salience_map = np.where(img.salience_map > tf, img.salience_map, 0) img.plot_main() img.plot_patched_map()
x, y = np.where(gt > 0) for i in zip(x, y): temp.append( np.log2(eps + smap[i[0], i[1]]) - np.log2(eps + baseline[i[0], i[1]])) return np.mean(temp) # Main Routine if __name__ == '__main__': plt.close('all') # Open test images as 8-bit RGB values - Time ~0.0778813 file = "./SMW_Test_Image.png" mario = foai.ImageObject(file) file = "../datasets/AIM/eyetrackingdata/original_images/22.jpg" banana = foai.ImageObject(file) file = "../datasets/AIM/eyetrackingdata/ground_truth/d22.jpg" gt_banana = Image.open(file) gt_banana.load() file = "../datasets/AIM/eyetrackingdata/original_images/120.jpg" corner = foai.ImageObject(file) file = "../datasets/AIM/eyetrackingdata/ground_truth/d120.jpg" gt_corner = Image.open(file) gt_corner.load() # Test Image test_image = corner test_image.ground_truth = np.array(gt_corner, dtype=np.float64)
os.makedirs(dir_path, exist_ok=True) # Read first frame success, image = movie.read() print("FIRST READ SUCCESS: ", success) # Get image dimensions: Mario - 224x256x3 height, width, channels = image.shape print("H: ", height, "W: ", width, "C: ", channels) start = time.time() # Generate Gaussian Blur Prior - Time ~0.0020006 prior = foac.matlab_style_gauss2D(image.shape, 300) # Generate Gamma Kernel image_curr = foai.ImageObject(image, fc=frame) image_prev = image_curr image_prev.salience_map = np.zeros(image_prev.original.shape[:-1]) kernel = foac.gamma_kernel(image_curr) # Step through each movie frame while success: frame += 1 image_name = str(frame) + ext image_curr = foai.ImageObject(image, fc=frame) # Generate Saliency Map with Gamma Filter foac.convolution(image_curr, kernel, prior) if (frame % 100 == 0): stop = time.time()
plt.rcParams.update({'font.size': 22}) #image_set = np.array([False]) # Main Routine if __name__ == '__main__': plt.close('all') # Load image set data if (image_set.any() == False): print("Importing data...") image_set = np.load("./STATE0.npy") # Test Image test_image = image_set[0] cv2.imwrite("0.png", test_image) test_image = foai.ImageObject(cv2.imread("0.png")) os.remove("0.png") # %% Generate Gaussian and Gamma Kernel # Generate Gaussian Blur Prior - Time ~0.0020006 foveation_prior = foac.matlab_style_gauss2D(test_image.modified.shape, 300) # Generate Gamma Kernel kernel = foac.gamma_kernel(test_image) # %% Process Images image_height = image_set.shape[1] image_width = image_set.shape[2] rankCount = 10 # Number of maps scans to run processed_data = np.empty(