Esempio n. 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.Read);

            var dweetResponse = Http.Post(Constants.DweetPostColorsHttp, new NameValueCollection
            {
                { "type", "colors" },
                { "value", ColorConversion.GetXMLString() }
            });

            DweetReader = new Intent(this, typeof(DweetReaderService));
            StartService(DweetReader);

            var filter = new IntentFilter("ArduinoReading");

            RegisterReceiver(new MyBroadcastReceiver(), filter);

            txtTempValue  = (TextView)FindViewById(Resource.Id.txtTempValue);
            txtHumidValue = (TextView)FindViewById(Resource.Id.txtHumidValue);

            btnTempValue  = (Button)FindViewById(Resource.Id.btnTempValue);
            btnHumidValue = (Button)FindViewById(Resource.Id.btnHumidValue);

            btnTempValue.SetBackgroundColor(Color.Transparent);
            btnHumidValue.SetBackgroundColor(Color.Transparent);
        }
Esempio n. 2
0
 void SetHSV()
 {
     ColorConversion.HSVColor hsvColor = ColorConversion.ConvertRGBToHSV(_Value);
     H = hsvColor.NormalizedH;
     S = hsvColor.NormalizedS;
     V = hsvColor.NormalizedV;
 }
Esempio n. 3
0
        /// <summary>
        /// Get a color channel for a given color space and channel
        /// </summary>
        /// <param name="colorSpace">color space / model</param>
        /// <param name="image">input image</param>
        /// <param name="channel">channel</param>
        /// <returns>color channel as grayscale image</returns>
        public static UMat GetColorChannelAsUMat(ColorSpace colorSpace, Image <Bgr, byte> image, int channel)
        {
            using (Image <Bgr, byte> imageCopy = image.Clone())
            {
                if ((int)colorSpace >= 0 && (int)colorSpace <= 7)
                {
                    int cs = (int)colorSpace;
                    return(GetColorDeconvolutedChannelAsUMat(imageCopy.Bitmap, (ColorDeconvolution.KnownStain)cs, channel));
                }
                else
                {
                    ColorConversion cc = ColorConversion.Bgr2Bgra;
                    switch (colorSpace)
                    {
                    case ColorSpace.HLS: cc = ColorConversion.Bgr2Hls; break;

                    case ColorSpace.HSV: cc = ColorConversion.Bgr2Hsv; break;

                    case ColorSpace.LAB: cc = ColorConversion.Bgr2Lab; break;

                    case ColorSpace.LUV: cc = ColorConversion.Bgr2Luv; break;

                    case ColorSpace.RGB: cc = ColorConversion.Bgr2Rgb; break;
                    }

                    return(GetColorChannel(imageCopy.ToUMat(), cc, channel));
                }
            }
        }
Esempio n. 4
0
        public static Mat CvtColor(this Mat src, ColorConversion code)
        {
            var dst = new Mat();

            Cv2.CvtColor(src, dst, code);
            return(dst);
        }
Esempio n. 5
0
        public void Spawn(GameObject obj)
        {
            var particles = Instantiate(obj, transform.position, transform.rotation, null);
            var main      = particles.GetComponent <ParticleSystem>().main;

            main.startColor = ColorConversion.GetColorFromType(GetComponent <IColored>().GetColorType());
        }
Esempio n. 6
0
        private void OnValueChangedEvent(object sender, RangeBaseValueChangedEventArgs args)
        {
            if (m_toolTip is ToolTip toolTip)
            {
                toolTip.Content = GetToolTipString();

                // ToolTip doesn't currently provide any way to re-run its placement logic if its placement target moves,
                // so toggling IsEnabled induces it to do that without incurring any visual glitches.
                toolTip.IsEnabled = false;
                toolTip.IsEnabled = true;
            }

            DependencyObject currentObject     = this;
            ColorPicker      owningColorPicker = null;

            while (currentObject != null && (owningColorPicker = currentObject as ColorPicker) == null)
            {
                currentObject = VisualTreeHelper.GetParent(currentObject);
            }

            if (owningColorPicker != null)
            {
                Color oldColor = owningColorPicker.Color;
                Hsv   hsv      = ColorConversion.RgbToHsv(ColorConversion.RgbFromColor(oldColor));
                hsv.V = args.NewValue / 100.0;
                Color newColor = ColorConversion.ColorFromRgba(ColorConversion.HsvToRgb(hsv));

                ColorPickerSliderAutomationPeer peer = FrameworkElementAutomationPeer.FromElement(this) as ColorPickerSliderAutomationPeer;
                peer.RaisePropertyChangedEvent(oldColor, newColor, (int)(Math.Round(args.OldValue)), (int)(Math.Round(args.NewValue)));
            }
        }
Esempio n. 7
0
        public static Mat CvtColor(this Mat obj, ColorConversion code, int dstCn = 0)
        {
            Mat res = new Mat();

            CvInvoke.CvtColor(obj, res, ColorConversion.Bgr2Gray, dstCn);
            return(res);
        }
Esempio n. 8
0
        public static ImageSource Convert(ImageSource imageSource, ColorConversion conversion)
        {
            ImageSource  result       = null;
            BitmapSource bitmapSource = imageSource as BitmapSource;

            if (bitmapSource != null)
            {
                PixelFormat format = PixelFormats.Default;
                switch (conversion)
                {
                case ColorConversion.BlackAndWhite:
                    format = PixelFormats.BlackWhite;
                    break;

                case ColorConversion.GrayScale:
                    format = PixelFormats.Gray32Float;
                    break;
                }

                if (format != PixelFormats.Default)
                {
                    result = Convert(bitmapSource, format);
                }
            }

            return(result);
        }
Esempio n. 9
0
        /// <summary>
        /// Displays a flipping box with increasing speed
        /// </summary>
        private static void DisplayFlipBox()
        {
            // Create the auto bitmaps
            nano     = new ushort[400];
            black    = new ushort[400];
            nanoBlue = (ushort)ColorConversion.ToRgb565(Color888.NanoBlue);

            // Fill it with nanoFramework blue
            for (int i = 0; i < nano.Length; i++)
            {
                nano[i]  = nanoBlue;
                black[i] = 0;
            }

            // Do the flip
            for (int varDelay = 250; varDelay > 30; varDelay -= 20)
            {
                for (int i = 0; i < 2; i++)
                {
                    tft.Flush(120, 180, 20, 20, nano);
                    tft.Flush(140, 180, 20, 20, black);
                    tft.Flush(120, 200, 20, 20, black);
                    tft.Flush(140, 200, 20, 20, nano);
                    Thread.Sleep(varDelay);
                    tft.Flush(120, 180, 20, 20, black);
                    tft.Flush(140, 180, 20, 20, nano);
                    tft.Flush(120, 200, 20, 20, nano);
                    tft.Flush(140, 200, 20, 20, black);
                    Thread.Sleep(varDelay);
                }
            }
        }
Esempio n. 10
0
        private double[,] ReadPixels(BitmapSource source, ColorConversion convert)
        {
            int width     = source.PixelWidth;
            int height    = source.PixelHeight;
            var pixelSize = source.Format.BitsPerPixel / 8;

            byte[] pixels = new byte[height * width * pixelSize];
            source.CopyPixels(pixels, width * pixelSize, 0);

            double[,] data = new double[width, height];
            Parallel.For(0, height, h =>
            {
                var hPos = h * width * pixelSize;
                for (int w = 0; w < width; w++)
                {
                    var i = hPos + (w * pixelSize);

                    var gray = pixelSize == 1 ? pixels[i] : 0;

                    var blue  = pixelSize >= 3 ? pixels[i] : gray;
                    var green = pixelSize >= 3 ? pixels[i + 1] : gray;
                    //var red = pixelSize >= 3 ? pixels[i + 2] : gray; //U doesn't use Red

                    data[w, h] = convert(255, green, blue);
                }
            });

            return(data);
        }
Esempio n. 11
0
        public void AllRGBColors()
        {
            double[] rgb;
            double[] hsv;
            double[] outputRGB;

            for (int r = 0; r <= 256; r += 8)
            {
                for (int g = 0; g <= 256; g += 8)
                {
                    for (int b = 0; b <= 256; b += 8)
                    {
                        rgb = new double[3] {
                            Math.Min(r, 255), Math.Min(g, 255), Math.Min(b, 255)
                        };
                        hsv = ColorConversion.RGBToHSV(rgb);

                        outputRGB = ColorConversion.HSVToRGB(hsv);

                        Assert.InRange(rgb[0], outputRGB[0] - 0.01, outputRGB[0] + 0.01);
                        Assert.InRange(rgb[1], outputRGB[1] - 0.01, outputRGB[1] + 0.01);
                        Assert.InRange(rgb[2], outputRGB[2] - 0.01, outputRGB[2] + 0.01);
                    }
                }
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Saturate a color in the HSV color space.
        /// </summary>
        /// <param name="rgb"></param>
        /// <param name="strength"></param>
        /// <returns></returns>
        public static Vector3 SaturateHsv(Vector3 rgb, float strength)
        {
            var hsv = ColorConversion.RgbToHsv(rgb);

            hsv[1] = MathEx.Clamp(hsv[1] + hsv[1] * strength, 0, 1);
            return(ColorConversion.HsvToRgb(hsv));
        }
Esempio n. 13
0
        public void AllHSVColors()
        {
            double[] hsv;
            double[] rgb;
            double[] outputHSV;

            for (double hue = 0.0; hue <= 360.0; hue += 16.0)
            {
                for (double saturation = 0.05; saturation <= 1.0; saturation += 0.05)
                {
                    for (double value = 16; value <= 255.0; value += 16.0)
                    {
                        hsv = new double[3] {
                            hue, saturation, Math.Min(value, 255)
                        };
                        rgb = ColorConversion.HSVToRGB(hsv);

                        outputHSV = ColorConversion.RGBToHSV(rgb);

                        Assert.InRange(hsv[0], outputHSV[0] - 0.01, outputHSV[0] + 0.01);
                        Assert.InRange(hsv[1], outputHSV[1] - 0.01, outputHSV[1] + 0.01);
                        Assert.InRange(hsv[2], outputHSV[2] - 0.01, outputHSV[2] + 0.01);
                    }
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Converts input image from one color space to another. The function ignores colorModel and channelSeq fields of IplImage header, so the source image color space should be specified correctly (including order of the channels in case of RGB space, e.g. BGR means 24-bit format with B0 G0 R0 B1 G1 R1 ... layout, whereas RGB means 24-bit format with R0 G0 B0 R1 G1 B1 ... layout).
        /// </summary>
        /// <param name="src">The source 8-bit (8u), 16-bit (16u) or single-precision floating-point (32f) image</param>
        /// <param name="code">Color conversion operation that can be specifed using CV_src_color_space2dst_color_space constants </param>
        /// <param name="dstCn">Number of channels in the output image; if the parameter is 0, the number of the channels is derived automatically from src and code .</param>
        /// <returns>The output image of the same data type as the source one. The number of channels may be different</returns>
        public static IOutputArray CvtColor(IInputArray src, ColorConversion code, int dstCn = 0)
        {
            Mat dst = new Mat();

            CvInvoke.CvtColor(src, dst, code, dstCn);
            return(dst);
        }
Esempio n. 15
0
        protected override Pixel QuantizatePixel(int x, int y)
        {
            // Get the color and add to the list
            Color color = image[y, x];

            int colorIndex;

            if (listColor.Count < this.MaxColors)
            {
                if (!listColor.Contains(color))
                {
                    listColor.Add(color);
                }
                colorIndex = listColor.IndexOf(color);
            }
            else
            {
                // Create the labpalette if so
                if (nearestNeighbour == null)
                {
                    LabColor[] labPalette = ColorConversion.ToLabPalette <Color>(listColor.ToArray());
                    nearestNeighbour = new ExhaustivePaletteSearch();
                    nearestNeighbour.Initialize(labPalette);
                }

                LabColor labNoTrans = ColorConversion.ToLabPalette <Color>(new Color[] { color })[0];
                colorIndex = nearestNeighbour.Search(labNoTrans);
            }

            return(new Pixel((uint)colorIndex, (uint)color.Alpha, true));
        }
        void RegenerateTexture()
        {
            if (ImageBind.texture != null)
            {
                DestroyImmediate(ImageBind.texture);
            }

            double h = 0;

            if (ColorPickerBind)
            {
                h = ColorPickerBind.H * 360;
            }

            var texture = new Texture2D(128, 128);

            texture.wrapMode  = TextureWrapMode.Clamp;
            texture.hideFlags = HideFlags.DontSave;

            for (int s = 0; s < 128; s++)
            {
                Color[] colors = new Color[128];
                for (int v = 0; v < 128; v++)
                {
                    colors[v] = ColorConversion.ConvertHSVToRGB(h, s / 128.0f, v / 128.0f, 1);
                }
                texture.SetPixels(s, 0, 1, 128, colors);
            }
            texture.Apply();
            ImageBind.texture = texture;
        }
        private static Difference[,] CalculateDistances(Color[][] palettes)
        {
            // Combination of each palette with each palette except with itself (diagonal)
            Difference[,] distances = new Difference[palettes.Length, palettes.Length];

            // Convert palettes to labcolor space to compute difference
            LabColor[][] labPalettes = new LabColor[palettes.Length][];
            for (int i = 0; i < palettes.Length; i++)
            {
                labPalettes[i] = ColorConversion.ToLabPalette <Color>(palettes[i]);
            }

            // Compute every possible difference
            for (int i = 0; i < palettes.Length; i++)
            {
                for (int j = 0; j < palettes.Length; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }

                    distances[i, j]            = new Difference();
                    distances[i, j].SrcPalette = i;
                    distances[i, j].DstPalette = j;
                    distances[i, j].Distance   = PaletteDistance.CalculateDistance(
                        labPalettes[i], labPalettes[j]);
                }
            }

            return(distances);
        }
Esempio n. 18
0
        public override void OnBackPressed()
        {
            List <TextView> badViews;

            if (VerifyValues(out badViews) == false)
            {
                foreach (var view in badViews)
                {
                    view.SetBackgroundColor(Color.Red);
                }
                var toast     = Toast.MakeText(this, "Configuración de colores inválida", ToastLength.Long);
                var toastView = toast.View;
                toastView.SetBackgroundColor(Color.DarkRed);
                toast.Show();
                return;
            }
            colors = ColorConversion.GetColorSetupFromXML();
            colors.TemperatureColor.LowColor.Threshold  = txtLowTemp.Text;
            colors.TemperatureColor.HighColor.Threshold = txtHighTemp.Text;
            colors.HumidityColor.LowColor.Threshold     = txtLowHumidity.Text;
            colors.HumidityColor.HighColor.Threshold    = txtHighHumidity.Text;
            colors.SaveToXML();
            var dweetResponse = Http.Post(Constants.DweetPostColorsHttp, new NameValueCollection
            {
                { "type", "colors" },
                { "value", ColorConversion.GetXMLString() }
            });

            base.OnBackPressed();
            var layout = (LinearLayout)FindViewById(Resource.Id.parentLayout);

            layout.RequestFocus();
        }
Esempio n. 19
0
        public static ImageSource Convert(ImageSource imageSource, ColorConversion conversion)
        {
            ImageSource result = null;
            BitmapSource bitmapSource = imageSource as BitmapSource;
            if (bitmapSource != null)
            {
                PixelFormat format = PixelFormats.Default;
                switch (conversion)
                {
                    case ColorConversion.BlackAndWhite:
                        format = PixelFormats.BlackWhite;
                        break;
                    case ColorConversion.GrayScale:
                        format = PixelFormats.Gray32Float;
                        break;
                }

                if (format != PixelFormats.Default)
                {
                    result = Convert(bitmapSource, format);
                }
            }

            return result;
        }
Esempio n. 20
0
 public void SetFromRGB(double r, double g, double b)
 {
     exRGB  = new double[] { r, g, b };
     exHsb  = ColorConversion.RGBToHSB(exRGB[0], exRGB[1], exRGB[2]);
     exHsl  = ColorConversion.RGBToHSL(exRGB[0], exRGB[1], exRGB[2]);
     exCMYK = ColorConversion.RGBToCMYK(exRGB[0], exRGB[1], exRGB[2]);
     setNewColor();
 }
 protected override void PreQuantization(EmguImage image)
 {
     // Convert image to Lab color space and get palette
     this.rgbImg     = image;
     this.labImg     = image.Convert <LabColor, byte>();
     this.labPalette = ColorConversion.ToLabPalette <Color>(this.Palette);
     this.nearestNeighbour.Initialize(labPalette);
 }
Esempio n. 22
0
    public static Vector3 FromTemperatureToLinearSRGB(double temperature)
    {
        Vector2 xy  = ColorConversion.FromTemperatureToCIExy(temperature);
        Vector3 XYZ = ColorConversion.FromCIExyTOCIEXYZ(xy, 1);
        Vector3 RGB = ColorConversion.FromCIEXYZtoLinearSRGB(XYZ);

        return(RGB);
    }
Esempio n. 23
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.Write);

            var dweetResponse = Http.Post(Constants.DweetPostColorsHttp, new NameValueCollection
            {
                { "type", "colors" },
                { "value", ColorConversion.GetXMLString() }
            });

            sensorType = Intent.GetStringExtra("SensorType") ?? "?????";

            txtSensorTitle      = (TextView)FindViewById(Resource.Id.txtSensorTitle);
            txtSensorTitle.Text = "Sensando " + sensorType;

            txtSensorValue      = (TextView)FindViewById(Resource.Id.txtSensorValue);
            txtSensorValue.Text = "";

            btnSensorValue = (Button)FindViewById(Resource.Id.btnSensorValue);
            btnSensorValue.SetBackgroundColor(Color.Transparent);

            var filter = new IntentFilter("AndroidReading");

            RegisterReceiver(new MyBroadcastReceiver(), filter);

            switch (sensorType)
            {
            case "Proximidad":
                currentSensorService            = new Intent(this, typeof(ProximitySensorService));
                btnSensorValue.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent);
                btnSensorValue.Visibility       = ViewStates.Visible;
                break;

            case "GPS":
                currentSensorService            = new Intent(this, typeof(GPSService));
                txtSensorValue.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent);
                btnSensorValue.Visibility       = ViewStates.Gone;
                txtSensorValue.Text             = "Esperando información...";
                break;

            case "Hora":
                currentSensorService            = new Intent(this, typeof(HourService));
                txtTitle                        = (TextView)FindViewById(Resource.Id.txtTitle);
                txtTitle.Text                   = "Hora actual";
                btnSensorValue.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent);
                txtSensorTitle.Visibility       = ViewStates.Gone;
                btnSensorValue.Visibility       = ViewStates.Visible;
                break;
            }

            if (currentSensorService != null)
            {
                StartService(currentSensorService);
            }
        }
Esempio n. 24
0
        public override void Awake()
        {
            base.Awake();

            rig         = GetComponent <Rigidbody2D>();
            ren         = GetComponent <SpriteRenderer>();
            ren.color   = ColorConversion.GetColorFromType(colorType);
            boxCollider = GetComponent <BoxCollider2D>();
        }
Esempio n. 25
0
        /// <summary>
        /// Get default color model and channel from openCV.
        /// </summary>
        /// <param name="input">input image</param>
        /// <param name="type">color model / color conversion type</param>
        /// <param name="channel">color channel</param>
        /// <returns>extracted color channel</returns>
        public static UMat GetColorChannel(UMat input, ColorConversion type, int channel)
        {
            UMat channels = new UMat();

            CvInvoke.CvtColor(input, channels, type);
            if (channels.NumberOfChannels > channel)
            {
                return(channels.Split()[channel]);
            }
            return(null);
        }
Esempio n. 26
0
    public void HSVtoRGB()
    {
        for (int i = 0; i < rgbs.Length; i++)
        {
            Color rgb = ColorConversion.HSVtoRGB(hsvs[i][0], hsvs[i][1], hsvs[i][2]);

            Assert.AreEqual(rgb.r, rgbs[i].r);
            Assert.AreEqual(rgb.g, rgbs[i].g);
            Assert.AreEqual(rgb.b, rgbs[i].b);
        }
    }
Esempio n. 27
0
        public void _colorSwatches_OnColorSelected(object sender, ColorSelectionEventArgs e)
        {
            var colorBytes = new[] { e.Color.R, e.Color.G, e.Color.B };

            ColorConversion.GetHsv(colorBytes, out var H, out _, out _);

            _colorPicker.SelectedColor = e.Color;
            _huePicker.SelectedHue     = H;

            _selectedHueLabel.Content = H;
        }
    private PostProcessorConstants GenerateConstants(ToneMappingSettings toneMappingSettings)
    {
        float   exposureAdjustment = (float)Math.Pow(2, toneMappingSettings.ExposureValue - 12);
        Vector3 balanceAdjustment  = ColorConversion.FromTemperatureToLinearSRGB(toneMappingSettings.WhiteBalance) / NeutralWhiteBalanceAsLinearSRGB;

        return(new PostProcessorConstants {
            exposureAndBalanceAdjustment = exposureAdjustment * balanceAdjustment,
            burnHighlightsValue = (float)toneMappingSettings.BurnHighlights,
            crushBlacksValue = (float)toneMappingSettings.CrushBlacks
        });
    }
Esempio n. 29
0
        public static Texture2D Convert(Texture texture, ColorSpace dstColorSpace, ColorConversion colorConversion, Material convertMaterial)
        {
            var copyTexture = CopyTexture(texture, dstColorSpace, convertMaterial);

            if (colorConversion != null)
            {
                copyTexture.SetPixels32(copyTexture.GetPixels32().Select(x => colorConversion(x)).ToArray());
                copyTexture.Apply();
            }
            copyTexture.name = texture.name;
            return(copyTexture);
        }
Esempio n. 30
0
 public void SetFromHSB(int h, double s, double b)
 {
     if (s > 1 || b > 1 || h > 360 || h < 0)
     {
         throw new ArgumentException();
     }
     exHsb  = new double[] { h, s, b };
     exRGB  = ColorConversion.HSBToRGB(h, s, b);
     exHsl  = ColorConversion.RGBToHSL(exRGB[0], exRGB[1], exRGB[2]);
     exCMYK = ColorConversion.RGBToCMYK(exRGB[0], exRGB[1], exRGB[2]);
     setNewColor();
 }
Esempio n. 31
0
 public void SetFromCMYK(double c, double m, double y, double k)
 {
     if (c > 1 || m > 1 || y > 1 || k > 1)
     {
         throw new ArgumentException();
     }
     exCMYK = new double[] { c, m, y, k };
     exRGB  = ColorConversion.CMYKToRGB(c, m, y, k);
     exHsb  = ColorConversion.RGBToHSB(exRGB[0], exRGB[1], exRGB[2]);
     exHsl  = ColorConversion.RGBToHSL(exRGB[0], exRGB[1], exRGB[2]);
     setNewColor();
 }
Esempio n. 32
0
        public void CreateLookupTable(ColorConversion conversion)
        {
            if (conversion == null)
                return;

            for (int r = 255; r >= 0; --r)
            {
                for (int g = 255; g >= 0; --g)
                {
                    for (int b = 255; b >= 0; --b)
                    {
                        lut[r, g, b] = conversion(Color.FromArgb(r, g, b));
                    }
                }
            }
        }
Esempio n. 33
0
    /// <summary>
    /// 画像の色空間を変換します.
    /// </summary>
    /// <param name="code">色空間の変換コード.</param>
    /// <param name="dstCn">出力画像のチャンネル数.この値が 0 の場合,チャンネル数は src と code から自動的に求められます</param>
    /// <returns>src と同じサイズ,同じタイプの出力画像</returns>
#else
        /// <summary>
        /// Converts image from one color space to another
        /// </summary>
        /// <param name="code">The color space conversion code</param>
        /// <param name="dstCn">The number of channels in the destination image; if the parameter is 0, the number of the channels will be derived automatically from src and the code</param>
        /// <returns>The destination image; will have the same size and the same depth as src</returns>
#endif
        public Mat CvtColor(ColorConversion code, int dstCn = 0)
        {
            var dst = new Mat();
            Cv2.CvtColor(this, dst, code, dstCn);
            return dst;
        }
Esempio n. 34
0
 public static extern void cvCvtColor(IntPtr src, IntPtr dst, ColorConversion code);
Esempio n. 35
0
 public static Mat CvtColor(this Mat src, ColorConversion code)
 {
     var dst = new Mat();
     Cv2.CvtColor(src, dst, code);
     return dst;
 }
        /// <summary>
        /// 画像の色空間を変換します.
        /// </summary>
        /// <param name="src">8ビット符号なし整数型,16ビット符号なし整数型,または単精度浮動小数型の入力画像</param>
        /// <param name="dst">src と同じサイズ,同じタイプの出力画像</param>
        /// <param name="code">色空間の変換コード.</param>
        /// <param name="dstCn">出力画像のチャンネル数.この値が 0 の場合,チャンネル数は src と code から自動的に求められます</param>
#else
        /// <summary>
        /// Converts image from one color space to another
        /// </summary>
        /// <param name="src">The source image, 8-bit unsigned, 16-bit unsigned or single-precision floating-point</param>
        /// <param name="dst">The destination image; will have the same size and the same depth as src</param>
        /// <param name="code">The color space conversion code</param>
        /// <param name="dstCn">The number of channels in the destination image; if the parameter is 0, the number of the channels will be derived automatically from src and the code</param>
#endif
        public static void CvtColor(InputArray src, OutputArray dst, ColorConversion code, int dstCn = 0)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            src.ThrowIfDisposed();
            dst.ThrowIfNotReady();
            
            NativeMethods.imgproc_cvtColor(src.CvPtr, dst.CvPtr, (int)code, dstCn);
            dst.Fix();
        }
Esempio n. 37
0
        /// <summary>
        /// 画像の色空間を変換します.
        /// </summary>
        /// <param name="src">8ビット符号なし整数型,16ビット符号なし整数型,または単精度浮動小数型の入力画像</param>
        /// <param name="dst">src と同じサイズ,同じタイプの出力画像</param>
        /// <param name="code">色空間の変換コード.</param>
        /// <param name="dstCn">出力画像のチャンネル数.この値が 0 の場合,チャンネル数は src と code から自動的に求められます</param>
#else
        /// <summary>
        /// Converts image from one color space to another
        /// </summary>
        /// <param name="src">The source image, 8-bit unsigned, 16-bit unsigned or single-precision floating-point</param>
        /// <param name="dst">The destination image; will have the same size and the same depth as src</param>
        /// <param name="code">The color space conversion code</param>
        /// <param name="dstCn">The number of channels in the destination image; if the parameter is 0, the number of the channels will be derived automatically from src and the code</param>
#endif
        public static void CvtColor(Mat src, Mat dst, ColorConversion code, int dstCn = 0)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            CppInvoke.cv_cvtColor(src.CvPtr, dst.CvPtr, code, dstCn);
        }
Esempio n. 38
0
        /// <summary>
        /// 画像の色空間を変換します.
        /// </summary>
        /// <param name="src">8ビット符号なし整数型,16ビット符号なし整数型,または単精度浮動小数型の入力画像</param>
        /// <param name="dst">src と同じサイズ,同じタイプの出力画像</param>
        /// <param name="code">色空間の変換コード.</param>
        /// <param name="dstCn">出力画像のチャンネル数.この値が 0 の場合,チャンネル数は src と code から自動的に求められます</param>
#else
        /// <summary>
        /// Converts image from one color space to another
        /// </summary>
        /// <param name="src">The source image, 8-bit unsigned, 16-bit unsigned or single-precision floating-point</param>
        /// <param name="dst">The destination image; will have the same size and the same depth as src</param>
        /// <param name="code">The color space conversion code</param>
        /// <param name="dstCn">The number of channels in the destination image; if the parameter is 0, the number of the channels will be derived automatically from src and the code</param>
#endif
        public static void CvtColor(InputArray src, OutputArray dst, ColorConversion code, int dstCn = 0)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            src.ThrowIfDisposed();
            dst.ThrowIfNotReady();
            try
            {
                NativeMethods.imgproc_cvtColor(src.CvPtr, dst.CvPtr, (int)code, dstCn);
                dst.Fix();
            }
            catch (BadImageFormatException ex)
            {
                throw PInvokeHelper.CreateException(ex);
            }
        }
Esempio n. 39
0
 public LUT(ColorConversion conversion = null)
 {
     lut = new Color[256, 256, 256];
     CreateLookupTable(conversion);
 }