Example #1
0
        public RGBImage(RGBImage refImage, int l, int t, int w, int h)
        {
            if (refImage == null)
                throw new System.ArgumentException("Input is invalid!");

            int width = refImage.Width;
            int height = refImage.Height;

            if (l < 0) l = 0;
            if (l >= width) l = width - 1;
            if (t < 0) t = 0;
            if (t >= height) t = height - 1;

            if (l + w > width) w = width - l;
            if (t + h > height) h = height - t;
            if (w < 1) w = 1;
            if (h < 1) h = 1;

            // update image's info
            _width = w;
            _height = h;
            _length = _width * _height;

            // update image's data
            byte[][] src = (byte[][])refImage.Data;
            byte[][] data = new byte[3][];
            data[0] = Utilities.Crop(src[0], 1, width, height, l, t, w, h);
            data[1] = Utilities.Crop(src[1], 1, width, height, l, t, w, h);
            data[2] = Utilities.Crop(src[2], 1, width, height, l, t, w, h);

            _data = data;
        }
Example #2
0
        public RGBImage(RGBImage refImage, int l, int t, int w, int h)
        {
            if (refImage == null)
            {
                throw new System.ArgumentException("Input is invalid!");
            }

            int width  = refImage.Width;
            int height = refImage.Height;

            if (l < 0)
            {
                l = 0;
            }
            if (l >= width)
            {
                l = width - 1;
            }
            if (t < 0)
            {
                t = 0;
            }
            if (t >= height)
            {
                t = height - 1;
            }

            if (l + w > width)
            {
                w = width - l;
            }
            if (t + h > height)
            {
                h = height - t;
            }
            if (w < 1)
            {
                w = 1;
            }
            if (h < 1)
            {
                h = 1;
            }

            // update image's info
            _width  = w;
            _height = h;
            _length = _width * _height;

            // update image's data
            byte[][] src  = (byte[][])refImage.Data;
            byte[][] data = new byte[3][];
            data[0] = Utilities.Crop(src[0], 1, width, height, l, t, w, h);
            data[1] = Utilities.Crop(src[1], 1, width, height, l, t, w, h);
            data[2] = Utilities.Crop(src[2], 1, width, height, l, t, w, h);

            _data = data;
        }
Example #3
0
        public RGBImage(
            RGBImage refImage,
            int marginX, int marginY,
            bool trueIsExpanding_falseIsCropping,
            bool interpolationForExpandingOnly)
        {
            if (refImage == null)
            {
                throw new System.ArgumentException("Input is invalid!");
            }

            int new_width  = 0;
            int new_height = 0;

            byte[][] new_data = new byte[3][];

            byte[][] src = (byte[][])refImage.Data;

            if (trueIsExpanding_falseIsCropping) /* expand */
            {
                if (interpolationForExpandingOnly)
                {
                    new_data[0] = Utilities.ExpandAndInterpolate(
                        src[0], refImage.Width, refImage.Height,
                        marginX, marginY, ref new_width, ref new_height);
                    new_data[1] = Utilities.ExpandAndInterpolate(
                        src[1], refImage.Width, refImage.Height,
                        marginX, marginY, ref new_width, ref new_height);
                    new_data[2] = Utilities.ExpandAndInterpolate(
                        src[2], refImage.Width, refImage.Height,
                        marginX, marginY, ref new_width, ref new_height);
                }
                else
                {
                    new_data[0] =
                        Utilities.Expand(src[0], refImage.Width, refImage.Height,
                                         marginX, marginY, ref new_width, ref new_height);
                    new_data[1] =
                        Utilities.Expand(src[1], refImage.Width, refImage.Height,
                                         marginX, marginY, ref new_width, ref new_height);
                    new_data[2] =
                        Utilities.Expand(src[2], refImage.Width, refImage.Height,
                                         marginX, marginY, ref new_width, ref new_height);
                }
            }
            else /* crop */
            {
                new_data[0] =
                    Utilities.Crop(src[0], 1, refImage.Width, refImage.Height,
                                   marginX, marginY, ref new_width, ref new_height);
                new_data[1] =
                    Utilities.Crop(src[1], 1, refImage.Width, refImage.Height,
                                   marginX, marginY, ref new_width, ref new_height);
                new_data[2] =
                    Utilities.Crop(src[2], 1, refImage.Width, refImage.Height,
                                   marginX, marginY, ref new_width, ref new_height);
            }

            // update image's info
            _width  = new_width;
            _height = new_height;
            _length = _width * _height;

            // update image's data
            _data = new_data;
        }
Example #4
0
        private void OpenFile(string fileName)
        {
            ClearRenderingData();

            IImage rgbImage = new RGBImage();

            string sCommand = SupportedImageActions.Load;
            object[] inputs = new object[] { fileName };
            object[] outputs = null;

            rgbImage.DoCommand(sCommand, inputs, ref outputs);

            Image image = ToImage(rgbImage);

            // update currnt grey image
            FileName = fileName;
            _image = rgbImage;

            // update image for image viewer
            UpdateImageViewer(image);

            List<Word> wordList = null;
            this.UpdateImageViewer(wordList);
        }
Example #5
0
        public RGBImage(
            RGBImage refImage,
            int marginX, int marginY,
            bool trueIsExpanding_falseIsCropping,
            bool interpolationForExpandingOnly)
        {
            if (refImage == null)
                throw new System.ArgumentException("Input is invalid!");

            int new_width = 0;
            int new_height = 0;
            byte[][] new_data = new byte[3][];

            byte[][] src = (byte[][])refImage.Data;

            if (trueIsExpanding_falseIsCropping) /* expand */
            {
                if (interpolationForExpandingOnly)
                {
                    new_data[0] = Utilities.ExpandAndInterpolate(
                        src[0], refImage.Width, refImage.Height,
                        marginX, marginY, ref new_width, ref new_height);
                    new_data[1] = Utilities.ExpandAndInterpolate(
                        src[1], refImage.Width, refImage.Height,
                        marginX, marginY, ref new_width, ref new_height);
                    new_data[2] = Utilities.ExpandAndInterpolate(
                        src[2], refImage.Width, refImage.Height,
                        marginX, marginY, ref new_width, ref new_height);
                }
                else
                {
                    new_data[0] =
                        Utilities.Expand(src[0], refImage.Width, refImage.Height,
                        marginX, marginY, ref new_width, ref new_height);
                    new_data[1] =
                        Utilities.Expand(src[1], refImage.Width, refImage.Height,
                        marginX, marginY, ref new_width, ref new_height);
                    new_data[2] =
                        Utilities.Expand(src[2], refImage.Width, refImage.Height,
                        marginX, marginY, ref new_width, ref new_height);
                }
            }
            else /* crop */
            {
                new_data[0] =
                    Utilities.Crop(src[0], 1, refImage.Width, refImage.Height,
                    marginX, marginY, ref new_width, ref new_height);
                new_data[1] =
                    Utilities.Crop(src[1], 1, refImage.Width, refImage.Height,
                    marginX, marginY, ref new_width, ref new_height);
                new_data[2] =
                    Utilities.Crop(src[2], 1, refImage.Width, refImage.Height,
                    marginX, marginY, ref new_width, ref new_height);
            }

            // update image's info
            _width = new_width;
            _height = new_height;
            _length = _width * _height;

            // update image's data
            _data = new_data;
        }