Beispiel #1
0
		private ResultImage OriginalTask(ImageJpeg image)
		{
			stopWatch.Stop();
			ResultImage result = new ResultImage(appConfig, EndpointController.rpcProfile, stopWatch.ElapsedMilliseconds);
			result.Image = image.ImageJpg;
			return result;
		}
Beispiel #2
0
		public ResultImage ExecuteTask(ImageJpeg imageFile, Filter filter, AppConfiguration appConfig, string photoName, Stopwatch stopWatch)
		{
			this.filter = filter;
			this.appConfig = appConfig;
			this.photoName = photoName;
			this.stopWatch = stopWatch;

			Debug.WriteLine("[BenchImage_DEBUG]: Iniciando aplicação de filtro");
			ResultImage result = null;
			switch (appConfig.Filter)
			{
				case "Original":
					result = OriginalTask(imageFile); break;
				case "Cartoonizer":
					result = CartoonizerTask(imageFile, filter); break;
				case "Benchmark":
					result = BenchmarkTask(filter); break;
				case "Sharpen":
					result = SharpenTask(imageFile, filter); break;
				default:
					result = FilterMapTask(imageFile, filter); break;
			}

			PhotoUtilities.ImageJpg = null;
			PhotoUtilities.FilterJpg = null;
			GC.Collect();

			Debug.WriteLine("[BenchImage_DEBUG]: Finalizou aplicação de filtro");
			return result;
		}
Beispiel #3
0
		private void LoadCompleteImage(ImageJpeg file)
		{
			ResultImage result = null;
			switch (AppConfig.Local)
			{
				case "Local":
					result = task.ExecuteTask(file, FilterLocal, AppConfig, photoName, stopWatch);
					break;

				case "Cloudlet":
					result = task.ExecuteTask(file, CloudletFilter, AppConfig, photoName, stopWatch);
					break;

				case "Internet":
					result = task.ExecuteTask(file, InternetFilter, AppConfig, photoName, stopWatch);
					break;
			}

			SetImageView(result.Image);

			ConfigureStatusView(result.TotalTime);

			ButtonExecute.Content = "Inicia";
			ButtonExecute.IsEnabled = true;

			Dispatcher.BeginInvoke(() =>
			{
				this.TextStatus.Text = "Status: Terminou Processamento!";
			});

			//clean
			fileLoader.RunCompleted -= new RunCompletedEventHandler<ImageJpeg>(LoadCompleteImage);
			result = null;
			GC.Collect();
		}
Beispiel #4
0
		private ResultImage FilterMapTask(ImageJpeg file, Filter filter)
		{
			byte[] imageResult = filter.MapTone(file.ImageJpg, file.FilterJpg);

			new FileSaveTask(GeneratePhotoFileName(), imageResult).RunSynchronous();

			stopWatch.Stop();
			ResultImage result = new ResultImage(appConfig, EndpointController.rpcProfile, stopWatch.ElapsedMilliseconds);
			result.Image = imageResult;
			Debug.WriteLine("[BenchImage_DEBUG]: Adiciona no banco de dados local");
			dao.Add(result);

			return result;
		}
Beispiel #5
0
		private ResultImage SharpenTask(ImageJpeg file, Filter filter)
		{
			double[][] mask = new double[3][];
			mask[0] = new double[3] { -1.0, -1.0, -1.0 };
			mask[1] = new double[3] { -1.0, 9.0, -1.0 };
			mask[2] = new double[3] { -1.0, -1.0, -1.0 };

			double factor = 1.0;
			double bias = 0.0;

			byte[] imageResult = filter.FilterApply(file.ImageJpg, mask, factor, bias);

			new FileSaveTask(GeneratePhotoFileName(), imageResult).RunSynchronous();

			stopWatch.Stop();
			ResultImage result = new ResultImage(appConfig, EndpointController.rpcProfile, stopWatch.ElapsedMilliseconds);
			result.Image = imageResult;
			Debug.WriteLine("[BenchImage_DEBUG]: Adiciona no banco de dados local");
			dao.Add(result);

			return result;
		}
Beispiel #6
0
		private ResultImage CartoonizerTask(ImageJpeg file, Filter filter)
		{
			return CartoonizerTask(file.ImageJpg, filter);
		}