Exemple #1
0
        public MarchingSquaresByte(ImageBuffer imageToMarch, PositiveArea0to1 thresholdFunction, int debugColor)
        {
            thersholdPerPixel = new double[imageToMarch.Width * imageToMarch.Height];
            {
                byte[] buffer        = imageToMarch.GetBuffer();
                int    strideInBytes = imageToMarch.StrideInBytes();
                for (int y = 0; y < imageToMarch.Height; y++)
                {
                    int imageBufferOffset     = imageToMarch.GetBufferOffsetY(y);
                    int thresholdBufferOffset = y * imageToMarch.Width;

                    for (int x = 0; x < imageToMarch.Width; x++)
                    {
                        int imageBufferOffsetWithX = imageBufferOffset + x * 4;
                        thersholdPerPixel[thresholdBufferOffset + x] = thresholdFunction(GetRGBA(buffer, imageBufferOffsetWithX));
                    }
                }
            }

            this.thresholdFunction = thresholdFunction;
            this.imageToMarch      = imageToMarch;
            this.debugColor        = debugColor;

            CreateLineSegments();
        }
		public MarchingSquaresByte(ImageBuffer imageToMarch, PositiveArea0to1 thresholdFunction, int debugColor)
		{
			thersholdPerPixel = new double[imageToMarch.Width * imageToMarch.Height];
			{
				byte[] buffer = imageToMarch.GetBuffer();
				int strideInBytes = imageToMarch.StrideInBytes();
				for (int y = 0; y < imageToMarch.Height; y++)
				{
					int imageBufferOffset = imageToMarch.GetBufferOffsetY(y);
					int thresholdBufferOffset = y * imageToMarch.Width;

					for (int x = 0; x < imageToMarch.Width; x++)
					{
						int imageBufferOffsetWithX = imageBufferOffset + x * 4;
						thersholdPerPixel[thresholdBufferOffset + x] = thresholdFunction(GetRGBA(buffer, imageBufferOffsetWithX));
					}
				}
			}

			this.thresholdFunction = thresholdFunction;
			this.imageToMarch = imageToMarch;
			this.debugColor = debugColor;

			CreateLineSegments();
		}