def capture_video(self, sky, millis_end, millis_start=0, quiet=False): """ Captures a list of images, each one separated from the other at a rate of 1. / fps seconds Parameters: sky: sky object with stars and cubesats millis_end: time at which the last image is taken millis_start: time at which the first image is taken quiet: if True, no progress bar is displayed Returns a list of frames and a list of timestamps """ video = [] timestamps = [] millis = millis_start base = Image(width=self.camera.cols, height=self.camera.rows) # Base image with stars only progress_bar = ProgressBar('Capturing video', millis_start, millis_end, quiet) sky.draw_stars_on_image(base) while millis <= millis_end: captured = base.clone() sky.draw_cubesats_on_image(captured, millis) self._add_noise(captured) video.append(captured) timestamps.append(millis) progress_bar.update(millis) millis += 1000. / self.fps progress_bar.end() return timestamps, video
SP_PROB = .001 STARS = 25 led = LightSource(brightness=0.8, std=5, x=400, y=400) # Our cubesat image = Image(width=800, height=800, value=0.05) # Draw stars led.draw_on_image(image) for i in range(STARS): source = LightSource(brightness=np.random.uniform(0.01, 1.), std=np.random.uniform(0.1, 5.), x=np.random.randint(0, image.w), y=np.random.randint(0, image.h)) source.draw_on_image(image) # Generate noise and filtered image noised_backVar = image.clone() noised_backVar.add_noise_background_variation() noised_gauss = noised_backVar.clone() noised_gauss.add_gaussian_noise(std=GAUSS_STD) noised_sp = noised_gauss.clone() noised_sp.add_salt_pepper(prob=SP_PROB) filtered = noised_sp.clone() filtered.median_filter(kernel=(MEDIAN_FIL, MEDIAN_FIL)) # Ratios mse, snr, psnr = Image.noise_ratio(image.data, noised_sp.data) print('[Original vs noised ] mse: {:.3f} snr: {:.3f} dB psnr: {:2.3f} dB'.format(mse, snr, psnr)) mse, snr, psnr = Image.noise_ratio(image.data, filtered.data)