当前位置: 首页>>代码示例>>C#>>正文


C# Draw.ResizeTo方法代码示例

本文整理汇总了C#中Draw.ResizeTo方法的典型用法代码示例。如果您正苦于以下问题:C# Draw.ResizeTo方法的具体用法?C# Draw.ResizeTo怎么用?C# Draw.ResizeTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Draw的用法示例。


在下文中一共展示了Draw.ResizeTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Distance

		public override float Distance(Draw.Image other)
		{
			float result = 0;
			if (other.IsNull())
				result = float.MaxValue;
			else if (!(other is YuvPacked))
				using (YuvPacked o = other.Convert<YuvPacked>())
					result = this.Distance(o);
			else if (this.Size != other.Size)
				using (YuvPacked o = other.ResizeTo(this.Size) as YuvPacked)
					result = this.Distance(o);
			else
			{
				for (int y = 0; y < this.Size.Height; y++)
					for (int x = 0; x < this.Size.Width; x++)
					{
						Color.Yuv c = this[x, y];
						Color.Yuv o = (other as YuvPacked)[x, y];
						if (c.Distance(o) > 0)
						{
							Color.Yuv maximum = o;
							Color.Yuv minimum = o;
							for (int otherY = Integer.Maximum(0, y - this.DistanceRadius); otherY < Integer.Minimum(y + 1 + this.DistanceRadius, this.Size.Height); otherY++)
								for (int otherX = Integer.Maximum(0, x - this.DistanceRadius); otherX < Integer.Minimum(x + 1 + this.DistanceRadius, this.Size.Width); otherX++)
									if (otherX != x || otherY != y)
									{
										Color.Yuv pixel = (other as YuvPacked)[otherX, otherY];
										if (maximum.Y < pixel.Y)
											maximum.Y = pixel.Y;
										else if (minimum.Y > pixel.Y)
											minimum.Y = pixel.Y;
										if (maximum.U < pixel.U)
											maximum.U = pixel.U;
										else if (minimum.U > pixel.U)
											minimum.U = pixel.U;
										if (maximum.V < pixel.V)
											maximum.V = pixel.V;
										else if (minimum.V > pixel.V)
											minimum.V = pixel.V;
									}
							float distance = 0;
							if (c.Y < minimum.Y)
								distance += Single.Squared(minimum.Y - c.Y);
							else if (c.Y > maximum.Y)
								distance += Single.Squared(c.Y - maximum.Y);
							if (c.U < minimum.U)
								distance += Single.Squared(minimum.U - c.U);
							else if (c.U > maximum.U)
								distance += Single.Squared(c.U - maximum.U);
							if (c.V < minimum.V)
								distance += Single.Squared(minimum.V - c.V);
							else if (c.V > maximum.V)
								distance += Single.Squared(c.V - maximum.V);
							result += Single.SquareRoot(distance) / 3;
						}
					}
				result /= this.Size.Length;
			}
			return result;
		}
开发者ID:imintsystems,项目名称:Kean,代码行数:60,代码来源:YuvPacked.cs

示例2: Distance

		public override float Distance(Draw.Image other)
		{
			float result = 0;
			if (other.IsNull())
				result = float.MaxValue;
			else if (!(other is Bgr))
				using (Bgr o = other.Convert<Bgr>())
					result = this.Distance(o);
			else if (this.Size != other.Size)
				using (Bgr o = other.ResizeTo(this.Size) as Bgr)
					result = this.Distance(o);
			else
			{
				for (int y = 0; y < this.Size.Height; y++)
					for (int x = 0; x < this.Size.Width; x++)
					{
						Color.Bgr c = this[x, y];
						Color.Bgr o = (other as Bgr)[x, y];
						if (c.Distance(o) > 0)
						{
							Color.Bgr maximum = o;
							Color.Bgr minimum = o;
							for (int otherY = Integer.Maximum(0, y - this.DistanceRadius); otherY < Integer.Minimum(y + 1 + this.DistanceRadius, this.Size.Height); otherY++)
								for (int otherX = Integer.Maximum(0, x - this.DistanceRadius); otherX < Integer.Minimum(x + 1 + this.DistanceRadius, this.Size.Width); otherX++)
									if (otherX != x || otherY != y)
									{
										Color.Bgr pixel = (other as Bgr)[otherX, otherY];
										if (maximum.Blue < pixel.Blue)
											maximum.Blue = pixel.Blue;
										else if (minimum.Blue > pixel.Blue)
											minimum.Blue = pixel.Blue;
										if (maximum.Green < pixel.Green)
											maximum.Green = pixel.Green;
										else if (minimum.Green > pixel.Green)
											minimum.Green = pixel.Green;
										if (maximum.Red < pixel.Red)
											maximum.Red = pixel.Red;
										else if (minimum.Red > pixel.Red)
											minimum.Red = pixel.Red;
									}
							float distance = 0;
							if (c.Blue < minimum.Blue)
								distance += Single.Squared(minimum.Blue - c.Blue);
							else if (c.Blue > maximum.Blue)
								distance += Single.Squared(c.Blue - maximum.Blue);
							if (c.Green < minimum.Green)
								distance += Single.Squared(minimum.Green - c.Green);
							else if (c.Green > maximum.Green)
								distance += Single.Squared(c.Green - maximum.Green);
							if (c.Red < minimum.Red)
								distance += Single.Squared(minimum.Red - c.Red);
							else if (c.Red > maximum.Red)
								distance += Single.Squared(c.Red - maximum.Red);
							result += Single.SquareRoot(distance) / 3;
						}
					}
				result /= this.Size.Length;
			}
			return result;
		}
开发者ID:imintsystems,项目名称:Kean,代码行数:60,代码来源:Bgr.cs

示例3: Distance

		public override float Distance(Draw.Image other)
		{
			float result = 0;
			if (other.IsNull())
				result = float.MaxValue;
			else if (!(other is Monochrome))
				using (Monochrome o = other.Convert<Monochrome>())
					result = this.Distance(o);
			else if (this.Size != other.Size)
				using (Monochrome o = other.ResizeTo(this.Size) as Monochrome)
					result = this.Distance(o);
			else
			{
				for (int y = 0; y < this.Size.Height; y++)
					for (int x = 0; x < this.Size.Width; x++)
					{
						Color.Monochrome c = this[x, y];
						Color.Monochrome o = (other as Monochrome)[x, y];
						if (c.Distance(o) > 0)
						{
							Color.Monochrome maximum = o;
							Color.Monochrome minimum = o;
							for (int otherY = Integer.Maximum(0, y - 2); otherY < Integer.Minimum(y + 3, this.Size.Height); otherY++)
								for (int otherX = Integer.Maximum(0, x - 2); otherX < Integer.Minimum(x + 3, this.Size.Width); otherX++)
									if (otherX != x || otherY != y)
									{
										Color.Monochrome pixel = (other as Monochrome)[otherX, otherY];
										if (maximum.Y < pixel.Y)
											maximum.Y = pixel.Y;
										else if (minimum.Y > pixel.Y)
											minimum.Y = pixel.Y;
									}
							float distance = 0;
							if (c.Y < minimum.Y)
								distance += Single.Squared(minimum.Y - c.Y);
							else if (c.Y > maximum.Y)
								distance += Single.Squared(c.Y - maximum.Y);
							result += Single.SquareRoot(distance);
						}
					}
				result /= this.Size.Length;
			}
			return result;
		}
开发者ID:imintsystems,项目名称:Kean,代码行数:44,代码来源:Monochrome.cs


注:本文中的Draw.ResizeTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。