示例#1
0
 //@Override
 public CustomImage process(CustomImage imageIn)
 {
     Palette palette = this.Map.CreatePalette(0x100);
     byte[] red = palette.Red;
     byte[] green = palette.Green;
     byte[] blue = palette.Blue;
     CustomImage bitmap = imageIn.clone();
     bitmap.clearImage((255 << 24) + (255 << 16) + (255 << 8) + 255);
     int bfactor = (int) (this.BrightnessFactor * 255f);
     float cfactor = 1f + this.ContrastFactor;
     cfactor *= cfactor;
     int limit = ((int) (cfactor * 32768f)) + 1;
     for (int i = 0; i < imageIn.colorArray.Length; i++)
     {
     int r = (imageIn.colorArray[i]& 0x00FF0000) >> 16;
     int g = (imageIn.colorArray[i]& 0x0000FF00) >> 8;
     int b = imageIn.colorArray[i]& 0x000000FF;
     int index = (((r * 0x1b36) + (g * 0x5b8c)) + (b * 0x93e)) >> 15;
     if (bfactor != 0)
     {
         index += bfactor;
         index = (index > 0xff) ? 0xff : ((index < 0) ? 0 : index);
     }
     if (limit != 0x8001)
     {
         index -= 0x80;
         index = (index * limit) >> 15;
         index += 0x80;
         index = (index > 0xff) ? 0xff : ((index < 0) ? 0 : index);
     }
     bitmap.colorArray[i] = (0xff << 24) + (red[index] << 16) + (green[index] << 8) + blue[index];
     }
     return bitmap;
 }
        /// <summary>
        /// Make the Vent fractal from image.
        /// </summary>
        private void Vent_Fractal_Click(object sender, EventArgs e)
        {
            CustomImage img = GetImageToTransform();

            img.Transform(new AffineTransformation(
                              new DoubleMatrix[]
            {
                new double[, ] {
                    { 0, -0.5 }, { 0.5, 0 }
                }, new double[, ] {
                    { 0.5, 0 }, { 0, 0.5 }
                }, new double[, ] {
                    { 0.5, 0 },
                    { 0, 0.5 }
                }
            },

                              new DoubleMatrix[]
            {
                new double[, ] {
                    { img.Width / 2 }, { 0 }
                }, new double[, ] {
                    { 0 }, { img.Height / 2 }
                }, new double[, ] {
                    { img.Width / 2 }, { img.Height / 2 }
                }
            }
                              ));
            imgComparison.TransformedImage = img;
        }
        /// <summary>
        /// Reduce image to half its size.
        /// </summary>
        private void btnReduceHalf_Click(object sender, EventArgs e)
        {
            CustomImage img = GetImageToTransform();

            img.Transform(new AffineTransformation(
                              new DoubleMatrix[]
            {
                new double[, ] {
                    { 0.5, 0 }, { 0, 0.5 }
                }
            },
                              new DoubleMatrix[] {
                new double[, ] {
                    { 0 }, { 0 }
                }
            }));
            Matrix <Pixel> cropped = new Matrix <Pixel>(img.Width / 2, img.Height / 2);

            for (int x = 0; x < cropped.DimensionX; x++)
            {
                for (int y = 0; y < cropped.DimensionY; y++)
                {
                    cropped[x, y] = img.ImageData[x, y];
                }
            }

            img.ImageData = cropped;
            imgComparison.TransformedImage = img;
        }
        /// <summary>
        /// Transform image using greyscale.
        /// </summary>
        private void btnGreyscale_Click(object sender, EventArgs e)
        {
            CustomImage img = GetImageToTransform();

            img.Transform(new GreyscaleTransformation());
            imgComparison.TransformedImage = img;
        }
示例#5
0
文件: Form1.cs 项目: JFFby/MRO
        private void SetImage(CustomImage <ClassType> img)
        {
            if (img != null)
            {
                var watch = new Stopwatch();
                watch.Start();
                for (int i = 0; i < Config.Height; i++)
                {
                    for (int j = 0; j < Config.Width; j++)
                    {
                        var val = img.PixelValue(i, j);
                        dataGridView1.Rows[i].Cells[j].Value = val;

                        if (val == 1)
                        {
                            dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.DarkSeaGreen;
                        }
                        else
                        {
                            dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.White;
                        }
                    }
                }
                watch.Stop();
            }
        }
示例#6
0
        /// <summary>
        /// создает физ файлы но не добавляет их в бд(id объектов 0)
        /// </summary>
        /// <param name="images"></param>
        /// <param name="articleId"></param>
        /// <returns></returns>
        public async Task <List <CustomImage> > GetCreatableUploadObjects(List <IFormFile> images, long articleId)
        {
            if (images == null || images.Count == 0)
            {
                return(null);
            }

            List <CustomImage> imagesForAdd = new List <CustomImage>();

            foreach (var uploadedImg in images)
            {
                var physImg = await CreateUploadFileWithOutDbRecord(uploadedImg);

                var img = new CustomImage()
                {
                    ArticleId = articleId,
                    Path      = physImg,
                };
                imagesForAdd.Add(img);
            }

            //_db.Images.AddRange(imagesForAdd);
            //await _db.SaveChangesAsync();
            return(imagesForAdd);
        }
示例#7
0
 private void lblFile_Click(object sender, EventArgs e)
 {
     if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         try
         {
             _bytes = File.ReadAllBytes(ofd.FileName);
             var ext = Path.GetExtension(ofd.FileName);
             if (ext == ".ppm" || ext == ".pgm")
             {
                 _ci = new CustomImage(_bytes);
             }
             if (ext == ".wav")
             {
                 _wd = Lab4.GetWaveData(ofd.FileName);
             }
             ofd.FileName = ofd.SafeFileName;
             lblFile.Text = ofd.SafeFileName;
         }
         catch
         {
             MessageBox.Show(string.Format("Открыть файл {0} не удалось",
                                           ofd.FileName),
                             "Ошибка",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Error);
         }
         if (_ci != null || _wd != null)
         {
             FileOpened?.Invoke();
         }
     }
 }
示例#8
0
        private void drawTone(int a_x, int a_y, CustomImage imageIn)
        {
            int l_grayIntensity;
            int l_x;
            int l_y;

            for (int x = 0; x < DOT_AREA * DOT_AREA; x++)
            {
                l_x = x % DOT_AREA;
                l_y = x / DOT_AREA;

                if (a_x + l_x < imageIn.getWidth() && a_y + l_y < imageIn.getHeight())
                {

                    l_grayIntensity = 255 - (imageIn.getRComponent(a_x + l_x, a_y + l_y));
                    if (l_grayIntensity > arrDither[x])
                    {
                        imageIn.setPixelColor(a_x + l_x, a_y + l_y, 0, 0, 0);
                    }
                    else
                    {
                        imageIn.setPixelColor(a_x + l_x, a_y + l_y, 255, 255, 255);
                    }
                }
            }
        }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();//Draw inspector UI of ImageEditor

        CustomImage image = (CustomImage)target;

        image.selectID = EditorGUILayout.IntField("selectID", image.selectID);
        image.price    = EditorGUILayout.IntField("price", image.price);

        EditorGUILayout.Space();

        int newCount = Mathf.Max(0, EditorGUILayout.DelayedIntField("restriction size", image.restrictionImages.Count));

        while (newCount < image.restrictionImages.Count)
        {
            image.restrictionImages.RemoveAt(image.restrictionImages.Count - 1);
        }
        while (newCount > image.restrictionImages.Count)
        {
            image.restrictionImages.Add(null);
        }

        for (int i = 0; i < image.restrictionImages.Count; i++)
        {
            image.restrictionImages[i] = EditorGUILayout.ObjectField("restriction skill", image.restrictionImages[i], typeof(CustomImage), true) as CustomImage;
        }

        EditorGUILayout.Space();

        image.skillName        = EditorGUILayout.TextField("skill name", image.skillName);
        image.skillDescription = EditorGUILayout.TextField("skill description", image.skillDescription);
        image.defaultSprite    = EditorGUILayout.ObjectField("default", image.defaultSprite, typeof(Sprite), true) as Sprite;
        image.lockedSprite     = EditorGUILayout.ObjectField("locked", image.lockedSprite, typeof(Sprite), true) as Sprite;
        image.unlockedSprite   = EditorGUILayout.ObjectField("unlocked", image.unlockedSprite, typeof(Sprite), true) as Sprite;
    }
    void RefreshDescription(CustomImage image)
    {
        SkillName.text        = image.skillName;
        SkillDescription.text = image.skillDescription;
        if (image.isUnlock)
        {
            VitaePrices.text = "-----";
        }
        else
        {
            VitaePrices.text = image.price.ToString();
        }

        if (image.isUnlock)
        {
            Status.text = "UNLOCKED";
        }
        else if (!image.isUnlockable)
        {
            Status.text = "LOCKED";
        }
        else
        {
            Status.text = "UNLOCKABLE";
        }
    }
示例#11
0
        public override void LoadContent()
        {
            base.LoadContent();

            header      = new Label();
            header.Text = "Header";
            AddView(header, 0, RelativePosition.None,
                    0, RelativePosition.None,
                    1, RelativePosition.ScreenWidth,
                    10, RelativePosition.ScreenHeight);

            for (int i = 0; i < images.Length; i++)
            {
                string img = images[i];

                CustomImage image = new CustomImage();
                image.Source = img;

                stack.Children.Add(image);
                AddView(stack, image,
                        0, RelativePosition.None,
                        0, RelativePosition.None,
                        1, RelativePosition.ScreenWidth,
                        0, RelativePosition.None);
            }

            bottom      = new Label();
            bottom.Text = "Bottom";
            AddView(bottom, 0, RelativePosition.None,
                    0, RelativePosition.None,
                    1, RelativePosition.ScreenWidth,
                    30, RelativePosition.None);
        }
示例#12
0
        // RGB2YIQ
        public CustomImage <YIQPixel> RGB2YIQ(Color[][] RGBImage, bool normalize = true)
        {
            CustomImage <YIQPixel> image = new CustomImage <YIQPixel>
            {
                Width  = RGBImage[0].Length,
                Height = RGBImage[1].Length
            };

            List <YIQPixel> pixels = new List <YIQPixel>();

            for (int i = 0; i < RGBImage[0].Length; i++)
            {
                for (int j = 0; j < RGBImage[1].Length; j++)
                {
                    // Normalize each pixel value
                    float NR, NG, NB;
                    NR = normalize ? RGBImage[i][j].R / 255.00F : RGBImage[i][j].R;
                    NG = normalize ? RGBImage[i][j].G / 255.00F : RGBImage[i][j].G;
                    NB = normalize ? RGBImage[i][j].B / 255.00F : RGBImage[i][j].B;

                    YIQPixel Pixel = new YIQPixel()
                    {
                        Xpos = i,
                        Ypos = j,
                        Y    = NR * W_RGB2YIQ[0, 0] + NG * W_RGB2YIQ[0, 1] + NB * W_RGB2YIQ[0, 2],
                        I    = NR * W_RGB2YIQ[1, 0] + NG * W_RGB2YIQ[1, 1] + NB * W_RGB2YIQ[1, 2],
                        Q    = NR * W_RGB2YIQ[2, 0] + NG * W_RGB2YIQ[2, 1] + NB * W_RGB2YIQ[2, 2]
                    };
                    pixels.Add(Pixel);
                }
            }

            image.Pixels = pixels;
            return(image);
        }
示例#13
0
        public CustomImage <RGBPixel> LumaChrominance(CustomImage <YIQPixel> YIQImage, float alpha = 1.0F, float beta = 1.0F)
        {
            CustomImage <YIQPixel> result = new CustomImage <YIQPixel>
            {
                Width  = YIQImage.Width,
                Height = YIQImage.Height
            };

            List <YIQPixel> pixels = new List <YIQPixel>();

            foreach (var pixel in YIQImage.Pixels)
            {
                YIQPixel YIQModPixel = new YIQPixel
                {
                    Xpos = pixel.Xpos,
                    Ypos = pixel.Ypos,
                    Y    = ValidateYIQ(pixel.Y * alpha, 0F, 1F),
                    I    = ValidateYIQ(pixel.I * beta, -0.5957F, 0.5957F),
                    Q    = ValidateYIQ(pixel.Q * beta, -0.5226F, 0.5226F)
                };
                pixels.Add(YIQModPixel);
            }

            result.Pixels = pixels;
            return(YIQ2RGB(result));
        }
示例#14
0
文件: Form1.cs 项目: JFFby/MRO
        private void SetImage(CustomImage<ClassType> img)
        {
            if (img != null)
            {
                var watch = new Stopwatch();
                watch.Start();
                for (int i = 0; i < Config.Height; i++)
                {
                    for (int j = 0; j < Config.Width; j++)
                    {
                        var val = img.PixelValue(i, j);
                        dataGridView1.Rows[i].Cells[j].Value = val;

                        if (val == 1)
                        {
                            dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.DarkSeaGreen;
                        }
                        else
                        {
                            dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.White;
                        }
                    }
                }
                watch.Stop();
            }
        }
示例#15
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            float saturation = this.SaturationFactor + 1f;
            float negosaturation = 1f - saturation;

            int r, g, b, a;
            for (int x = 0; x < imageIn.getWidth(); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y++)
                {
                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);

                    float nego1 = negosaturation * 0.2126f;
                    float ngeo2 = nego1 + saturation;
                    float ngeo3 = negosaturation * 0.7152f;
                    float nego4 = ngeo3 + saturation;
                    float nego5 = negosaturation * 0.0722f;
                    float nego6 = nego5 + saturation;
                    float nego7 = ((r * ngeo2) + (g * ngeo3)) + (b * nego5);
                    float nego8 = ((r * nego1) + (g * nego4)) + (b * nego5);
                    float nego9 = ((r * nego1) + (g * ngeo3)) + (b * nego6);
                    r = (nego7 > 255f) ? ((byte)255f) : ((nego7 < 0f) ? ((byte)0f) : ((byte)nego7));
                    g = (nego8 > 255f) ? ((byte)255f) : ((nego8 < 0f) ? ((byte)0f) : ((byte)nego8));
                    b = (nego9 > 255f) ? ((byte)255f) : ((nego9 < 0f) ? ((byte)0f) : ((byte)nego9));
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return imageIn;
        }
示例#16
0
        public IHttpActionResult PutCustomImage(int id, CustomImage customImage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != customImage.ImageId)
            {
                return(BadRequest());
            }

            db.Entry(customImage).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomImageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        private async void ListViewSamplePage_Loaded(object sender, RoutedEventArgs e)
        {
            imageList = await CustomImage.GenerateImages();

            MyPager.NumberOfPages = (int)Math.Ceiling((double)imageList.Count / imagesPerPage);
            UpdateCollection();
        }
示例#18
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            int width = imageIn.getWidth();
            int height = imageIn.getHeight();
            CustomImage clone = imageIn.clone();
            int r = 0, g = 0, b = 0;
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    int k = NoiseFilter.getRandomInt(1, 123456);

                    int dx = x + k % 19;
                    int dy = y + k % 19;
                    if (dx >= width)
                    {
                        dx = width - 1;
                    }
                    if (dy >= height)
                    {
                        dy = height - 1;
                    }
                    r = clone.getRComponent(dx, dy);
                    g = clone.getGComponent(dx, dy);
                    b = clone.getBComponent(dx, dy);
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return imageIn;
        }
示例#19
0
        public async void CreateNewArticle_Created()
        {
            using var db = GetDbContext();

            new DefaultData().InitDbDefault(db);
            ImageRepository imgRepo    = new ImageRepository(db);
            var             newArticle = new Article()
            {
                Body  = "body1",
                Title = "title1",
            };

            db.Articles.Add(newArticle);
            db.SaveChanges();

            var imgForAdd = new CustomImage()
            {
                Path      = "10",
                ArticleId = newArticle.Id,
            };

            await imgRepo.Add(imgForAdd);

            var addedImg = db.Images.FirstOrDefault(x => x.Id == imgForAdd.Id);

            Assert.NotNull(addedImg);
            Assert.Equal(imgForAdd.Path, addedImg.Path);
            Assert.Equal(imgForAdd.ArticleId, addedImg.ArticleId);
        }
示例#20
0
 // Use this for initialization
 protected override void Awake()
 {
     Texture2D = CreateGameObject.CreateChildGameObject <CustomImage>(transform).GetComponent <CustomImage>();
     Text      = CreateGameObject.CreateChildGameObject <ControlText>(Texture2D.rectTransform).GetComponent <ControlText>();
     StopWatch = gameObject.AddComponent <StopWatch>();
     base.Awake();
 }
示例#21
0
        public CustomImage UpdateImage(CustomImage customImage)
        {
            var width              = customImage.Image.Width;
            var height             = customImage.Image.Height;
            var category           = customImage.Category;
            var name               = customImage.Name;
            var newImageCollection = new List <CustomImage>();

            var popUp = new TimedPopUp();

            popUp.Set("Обновляю изображение...");
            popUp.Show(autoHide: false);

            Image image = imageProvider.SetDefaultSize(width, height).GetImageByCategory(category);

            popUp.HideForm();

            var newImage = new CustomImage
            {
                Name        = $"{name}",
                Category    = category,
                AllowUpdate = true,
                Image       = image
            };

            libManager.RemoveImageFromCollection(customImage);
            newImageCollection.Add(newImage);
            newImageCollection.Add(newImage);
            libManager.InitializeNewCollection(newImageCollection);
            return(newImage);
        }
示例#22
0
    private void SetNewImage(CustomImage image)
    {
        if (m_CurrentImageSelected.isUnlock)
        {
            m_CurrentImageSelected.sprite = m_CurrentImageSelected.unlockedSprite;
        }
        else if (m_CurrentImageSelected.isUnlockable)
        {
            m_CurrentImageSelected.sprite = m_CurrentImageSelected.defaultSprite;
        }
        else
        {
            m_CurrentImageSelected.sprite = m_CurrentImageSelected.lockedSprite;
        }

        ServiceLocator.Instance.GetService <SoundManager>(ManagerType.SOUND_MANAGER).PlaySong("event:/SFX/UI/UI_Choose", 3);

        StartCoroutine(ZoomOut(m_CurrentImageSelected));

        m_CurrentImageSelected = image;
        m_CurrentSelectedID    = image.selectID;

        StartCoroutine(ZoomIn(m_CurrentImageSelected));

        if (RefreshDescription != null)
        {
            RefreshDescription(m_CurrentImageSelected);
        }
    }
示例#23
0
        public static List <CustomImage> GetIndividualSensorVisuals(Tile[,] tiles, bool draggable = true)
        {
            var imgList = new List <CustomImage>();

            for (var tileX = 0; tileX < tiles.GetLength(0); tileX++)
            {
                for (var tileY = 0; tileY < tiles.GetLength(1); tileY++)
                {
                    var tile         = tiles[tileX, tileY];
                    var tempTileList = new Tile[1, 1];
                    tempTileList[0, 0] = tile;
                    var img = new CustomImage
                    {
                        Source = BitmapToImageSource(
                            ConstructSensorDataBackground(tempTileList)),
                    };
                    img.SetValue(DraggableExtender.CanDragProperty, draggable);
                    img.TileData         = tile;
                    img.InCanvasPosition = (new System.Windows.Point(
                                                (tileX * tile.Sensors.GetLength(0)) * 3,
                                                (tileY * tile.Sensors.GetLength(1)) * 3));

                    RenderOptions.SetBitmapScalingMode(img, BitmapScalingMode.NearestNeighbor);
                    imgList.Add(img);
                }
            }

            return(imgList);
        }
示例#24
0
        public List <CustomImage> GenerateImageCollectionByCategory(PuzzleTag baseForm, string category, int weidth, int height)
        {
            var newImageCollection = new List <CustomImage>(16);
            var capacity           = 16;

            for (int i = 0; i < capacity; i++)
            {
                Image image = imageProvider.SetDefaultSize(weidth, height).GetImageByCategory(category);

                baseForm.UpdateStatusMessage($"ПОИСК ИЗОБРАЖЕНИЙ ПО КАТЕГОРИИ '{category.ToUpper()}' ... ({i+1} из 16)");

                var newImage = new CustomImage
                {
                    Name        = $"{category}{i}.Jpeg",
                    Category    = category,
                    AllowUpdate = true,
                    Image       = image
                };

                newImageCollection.Add(newImage);
                newImageCollection.Add(newImage);
            }

            libManager.AddCategory(category);
            libManager.InitializeNewCollection(newImageCollection);

            return(libManager.GetImageCollection());
        }
示例#25
0
    private static void ImageSourceStringChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
    {
        CustomImage currentImage = obj as CustomImage;
        string      path         = e.NewValue as string;

        MainPage.logMsg("ImageSource = " + path);
        if (string.IsNullOrEmpty(path))
        {
            Uri imageFileUri = new Uri("ms-appx:///Assets/Images/failed.png");
            currentImage.mainImage.ImageSource = new BitmapImage(imageFileUri);
        }
        else
        {
            Uri imageFileUri = null;
            try
            {
                imageFileUri = new Uri(path);
            }
            catch
            {
                imageFileUri = new Uri("ms-appx:///Assets/Images/failed.png");
            }
            if (imageFileUri != null)
            {
                currentImage.mainImage.ImageSource = new BitmapImage(imageFileUri);
            }
        }
    }
示例#26
0
        public CustomImage <RGBPixel> YIQ2RGB(CustomImage <YIQPixel> YIQImage, bool normalize = true)
        {
            CustomImage <RGBPixel> image = new CustomImage <RGBPixel>
            {
                Width  = YIQImage.Width,
                Height = YIQImage.Height
            };

            List <RGBPixel> pixels         = new List <RGBPixel>();
            int             normalizerTerm = normalize ? 255 : 1;

            foreach (var pixel in YIQImage.Pixels)
            {
                RGBPixel Pixel = new RGBPixel()
                {
                    Xpos = pixel.Xpos,
                    Ypos = pixel.Ypos,
                    R    = ValidateRange(((pixel.Y * W_YIQ2RGB[0, 0] + pixel.I * W_YIQ2RGB[0, 1] + pixel.Q * W_YIQ2RGB[0, 2]) * normalizerTerm)),
                    G    = ValidateRange(((pixel.Y * W_YIQ2RGB[1, 0] + pixel.I * W_YIQ2RGB[1, 1] + pixel.Q * W_YIQ2RGB[1, 2]) * normalizerTerm)),
                    B    = ValidateRange(((pixel.Y * W_YIQ2RGB[2, 0] + pixel.I * W_YIQ2RGB[2, 1] + pixel.Q * W_YIQ2RGB[2, 2]) * normalizerTerm))
                };
                pixels.Add(Pixel);
            }

            image.Pixels = pixels;
            return(image);
        }
示例#27
0
 //@Override
 public CustomImage process(CustomImage imageIn)
 {
     int width = imageIn.getWidth();
     int height = imageIn.getHeight();
     int r = 0, g = 0, b = 0;
     for (int y = 0; y < height; y++)
     {
         for (int x = 0; x < width; x++)
         {
             if (y % MosiacSize == 0)
             {
                 if (x % MosiacSize == 0)
                 {
                     r = imageIn.getRComponent(x, y);
                     g = imageIn.getGComponent(x, y);
                     b = imageIn.getBComponent(x, y);
                 }
                 imageIn.setPixelColor(x, y, r, g, b);
             }
             else
             {
                 imageIn.setPixelColor(x, y, imageIn.getPixelColor(x, y - 1));
             }
         }
     }
     return imageIn;
 }
示例#28
0
        private CustomImage ProcessColor(int k00, int k01, int k02, int k20, int k21, int k22, CustomImage imageIn, int thresholdSq)
        {
            int width = imageIn.getWidth();
            int height = imageIn.getHeight();
            int r, g, b;
            CustomImage clone = imageIn.clone();
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    int color1 = GetPixelColor(clone, x - 1, y - 1, width, height);
                    int color2 = GetPixelColor(clone, x, y - 1, width, height);
                    int color3 = GetPixelColor(clone, x + 1, y - 1, width, height);
                    int color4 = GetPixelColor(clone, x - 1, y, width, height);
                    int color5 = GetPixelColor(clone, x + 1, y, width, height);
                    int color6 = GetPixelColor(clone, x - 1, y + 1, width, height);
                    int color7 = GetPixelColor(clone, x, y + 1, width, height);
                    int color8 = GetPixelColor(clone, x + 1, y + 1, width, height);

                    int color1RGB = (0x00FF0000 & color1) >> 16;
                    int color3RGB = (0x00FF0000 & color3) >> 16;
                    int color6RGB = (0x00FF0000 & color6) >> 16;
                    int color8RGB = (0x00FF0000 & color8) >> 16;
                    int colorSum1 = (color1RGB * k00 + color3RGB * k02 + ((0x00FF0000 & color2) >> 16) * k01 + color6RGB * k20 + ((0x00FF0000 & color7) >> 16) * k21 + color8RGB * k22) >> 8;
                    int colorSum2 = (color1RGB * k00 + color3RGB * k20 + ((0x00FF0000 & color4) >> 16) * k01 + color6RGB * k02 + ((0x00FF0000 & color5) >> 16) * k21 + color8RGB * k22) >> 8;
                    r = (((colorSum1 * colorSum1) + (colorSum2 * colorSum2)) > thresholdSq) ? 0 : 0xff;
                    if (this.DoInversion)
                    {
                        r = 255 - r;
                    }

                    color1RGB = (0x0000FF00 & color1) >> 8;
                    color3RGB = (0x0000FF00 & color3) >> 8;
                    color6RGB = (0x0000FF00 & color6) >> 8;
                    color8RGB = (0x0000FF00 & color8) >> 8;
                    colorSum1 = (color1RGB * k00 + color3RGB * k02 + ((0x0000FF00 & color2) >> 8) * k01 + color6RGB * k20 + ((0x0000FF00 & color7) >> 8) * k21 + color8RGB * k22) >> 8;
                    colorSum2 = (color1RGB * k00 + color3RGB * k20 + ((0x0000FF00 & color4) >> 8) * k01 + color6RGB * k02 + ((0x0000FF00 & color5) >> 8) * k21 + color8RGB * k22) >> 8;
                    g = (((colorSum1 * colorSum1) + (colorSum2 * colorSum2)) > thresholdSq) ? 0 : 0xff;
                    if (this.DoInversion)
                    {
                        g = 255 - g;
                    }

                    color1RGB = 0x000000FF & color1;
                    color3RGB = 0x000000FF & color3;
                    color6RGB = 0x000000FF & color6;
                    color8RGB = 0x000000FF & color8;
                    colorSum1 = (color1RGB * k00 + color3RGB * k02 + (0x000000FF & color2) * k01 + color6RGB * k20 + (0x000000FF & color7) * k21 + color8RGB * k22) >> 8;
                    colorSum2 = (color1RGB * k00 + color3RGB * k20 + (0x000000FF & color4) * k01 + color6RGB * k02 + (0x000000FF & color5) * k21 + color8RGB * k22) >> 8;
                    b = (((colorSum1 * colorSum1) + (colorSum2 * colorSum2)) > thresholdSq) ? 0 : 0xff;
                    if (DoInversion)
                    {
                        b = 255 - b;
                    }
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return imageIn;
        }
 /// <summary>
 /// Compress image using fractal compression and using specified options.
 /// </summary>
 /// <param name="image"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 public FractalCompressionResult CompressUsingFractalCompression(CustomImage image, FractalCompressionOptions options)
 {
     using (var timer = new CustomTimer("Fractal Compression"))
     {
         FractalCompression compression = new FractalCompression(options);
         return(compression.Compress(image));
     }
 }
示例#30
0
        public Admin_window()
        {
            InitializeComponent();
            FrontEndHelper.SetAdminWindow(this);
            CustomImage logo = new CustomImage("resources/images/logo.png");

            this.Logo.Source = logo.GetImage().Source;
        }
示例#31
0
        public void Lab3Test()
        {
            var bytes = File.ReadAllBytes(@"C:\Repos\Simple_compression_algorithms\Simple_compression_algorithms\Simple_compression_algorithms\Resources\house_1.ppm");
            var ci    = new CustomImage(bytes);

            new CustomImage(Lab3.Encode(ci.Image)).Save(@"C:\Users\q1\Desktop\FreeSpace\Test\testLab3EncodeResult.ppm");
            new CustomImage(Lab3.Decode(ci.Image)).Save(@"C:\Users\q1\Desktop\FreeSpace\Test\testLab3DecodeResult.ppm");
        }
示例#32
0
 IEnumerator ZoomOut(CustomImage image)
 {
     for (float t = 0; t < 1; t += Time.deltaTime / ZoomTime)
     {
         image.rectTransform.sizeDelta = Vector2.Lerp(ZoomSize, DefaultSize, t);
         yield return(null);
     }
 }
        /// <summary>
        /// Set the Original Bitmap.
        /// </summary>
        /// <param name="bmp">Bitmap to show</param>
        public void SetOriginalBitmap(Bitmap bmp, string fileName)
        {
            var oldImage = _originalImage;
            var fileInfo = new FileInfo(fileName);

            OriginalImage = new CustomImage(bmp);

            lblOriginalSizeOnDisk.Text = (fileInfo.Length / (1024d * 1024d)).ToString("0.00") + " mb";
        }
示例#34
0
 public Room(int number, Hotel hotel, RoomType type,
             CustomImage image, List <RoomView> views)
 {
     this.number = number;
     this.hotel  = hotel;
     this.type   = type;
     this.views  = views;
     this.image  = image;
 }
示例#35
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            HistogramEqualFilter hee = new HistogramEqualFilter();
            hee.ContrastIntensity = 0.5f;
            imageIn = hee.process(imageIn);

            AutoLevelFilter ale = new AutoLevelFilter();
            ale.Intensity = 0.5f;
            return ale.process(imageIn);
        }
示例#36
0
 protected override void OnElementChanged(ElementChangedEventArgs <Image> e)
 {
     base.OnElementChanged(e);
     element = (CustomImage)Element;
     if (Control == null)
     {
         return;
     }
     LoadImageAsync();
 }
示例#37
0
 public Hotel(int licenseNumber, String name, CustomImage image,
              Location location, List <HotelFacility> facilities, List <MealPlan> mealPlans)
 {
     this.licenseNumber = licenseNumber;
     this.name          = name;
     this.image         = image;
     this.location      = location;
     this.facilities    = facilities;
     this.mealPlans     = mealPlans;
 }
示例#38
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            int r, g, b;
            // Convert to integer factors
            int bfi = (int)(BrightnessFactor * 255);
            float cf = 1f + ContrastFactor;
            cf *= cf;
            int cfi = (int)(cf * 32768) + 1;
            for (int x = 0; x < imageIn.getWidth(); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y++)
                {
                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);
                    // Modify brightness (addition)
                    if (bfi != 0)
                    {
                        // Add brightness
                        int ri = r + bfi;
                        int gi = g + bfi;
                        int bi = b + bfi;
                        // Clamp to byte boundaries
                        r = (byte)(ri > 255 ? 255 : (ri < 0 ? 0 : ri));
                        g = (byte)(gi > 255 ? 255 : (gi < 0 ? 0 : gi));
                        b = (byte)(bi > 255 ? 255 : (bi < 0 ? 0 : bi));
                    }
                    // Modifiy contrast (multiplication)
                    if (cfi != 32769)
                    {
                        // Transform to range [-128, 127]
                        int ri = r - 128;
                        int gi = g - 128;
                        int bi = b - 128;

                        // Multiply contrast factor
                        ri = (ri * cfi) >> 15;
                        gi = (gi * cfi) >> 15;
                        bi = (bi * cfi) >> 15;

                        // Transform back to range [0, 255]
                        ri = ri + 128;
                        gi = gi + 128;
                        bi = bi + 128;

                        // Clamp to byte boundaries
                        r = (byte)(ri > 255 ? 255 : (ri < 0 ? 0 : ri));
                        g = (byte)(gi > 255 ? 255 : (gi < 0 ? 0 : gi));
                        b = (byte)(bi > 255 ? 255 : (bi < 0 ? 0 : bi));
                    }
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return imageIn;
        }
示例#39
0
    // Token: 0x06001F7A RID: 8058 RVA: 0x003C1BD0 File Offset: 0x003BFDD0
    public override void OnOpen(int arg1, int arg2)
    {
        this.TransCache = base.transform;
        GUIManager  instance  = GUIManager.Instance;
        Font        ttffont   = GUIManager.Instance.GetTTFFont();
        DataManager instance2 = DataManager.Instance;
        CustomImage component = this.TransCache.transform.GetComponent <CustomImage>();

        component.hander = instance;
        Transform child = this.TransCache.transform.GetChild(0);

        component                  = child.GetComponent <CustomImage>();
        component.hander           = instance;
        component                  = child.GetChild(0).GetComponent <CustomImage>();
        component.hander           = instance;
        component                  = child.GetChild(1).GetComponent <CustomImage>();
        component.hander           = instance;
        this.TitleText             = child.GetChild(2).GetComponent <UIText>();
        this.TitleText.font        = ttffont;
        this.TitleText.text        = instance2.mStringTable.GetStringByID(15006u);
        this.Text1Text             = child.GetChild(3).GetComponent <UIText>();
        this.Text1Text.font        = ttffont;
        this.Text1Str              = StringManager.Instance.SpawnString(200);
        this.Text2Text             = child.GetChild(4).GetComponent <UIText>();
        this.Text2Text.font        = ttffont;
        this.Text2Text.text        = instance2.mStringTable.GetStringByID(15004u);
        this.SendBtnBackImg        = child.GetChild(5).GetComponent <CustomImage>();
        this.SendBtnBackImg.hander = instance;
        this.SendBtn               = child.GetChild(5).GetComponent <UIButton>();
        this.SendBtn.m_Handler     = this;
        this.SendBtn.m_BtnID1      = 1;
        this.NeedText              = child.GetChild(5).GetChild(1).GetComponent <UIText>();
        this.NeedText.font         = ttffont;
        this.UseText               = child.GetChild(5).GetChild(0).GetComponent <UIText>();
        this.UseText.font          = ttffont;
        this.UseText.text          = instance2.mStringTable.GetStringByID(15006u);
        this.NeedCtStr             = StringManager.Instance.SpawnString(30);
        Transform child2 = child.GetChild(6);

        component               = child2.GetChild(1).GetComponent <CustomImage>();
        component.hander        = instance;
        this.ItemNameText       = child2.GetChild(0).GetComponent <UIText>();
        this.ItemNameText.font  = ttffont;
        this.ItemNameText.text  = instance2.mStringTable.GetStringByID(11577u);
        this.ItemCountText      = child2.GetChild(1).GetChild(0).GetComponent <UIText>();
        this.ItemCountText.font = ttffont;
        this.ItemCountStr       = StringManager.Instance.SpawnString(30);
        GUIManager.Instance.InitianHeroItemImg(child2.GetChild(2), eHeroOrItem.Item, 1317, 0, 0, 0, false, false, true, false);
        this.CheckSuicideItem();
        component               = child.GetChild(7).GetComponent <CustomImage>();
        component.hander        = instance;
        this.CloseBtn           = child.GetChild(7).GetComponent <UIButton>();
        this.CloseBtn.m_Handler = this;
        this.CloseBtn.m_BtnID1  = 2;
    }
示例#40
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            int r, g, b, a;
            int ratio = imageIn.getWidth() > imageIn.getHeight() ? imageIn.getHeight() * 32768 / imageIn.getWidth() : imageIn.getWidth() * 32768 / imageIn.getHeight();

            // Calculate center, min and max
            int cx = imageIn.getWidth() >> 1;
            int cy = imageIn.getHeight() >> 1;
            int max = cx * cx + cy * cy;
            int min = (int)(max * (1 - Size));
            int diff = max - min;

            for (int x = 0; x < imageIn.getWidth(); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y++)
                {
                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);

                    // Calculate distance to center and adapt aspect ratio
                    int dx = cx - x;
                    int dy = cy - y;
                    if (imageIn.getWidth() > imageIn.getHeight())
                    {
                        dx = (dx * ratio) >> 15;
                    }
                    else
                    {
                        dy = (dy * ratio) >> 15;
                    }
                    int distSq = dx * dx + dy * dy;

                    if (distSq > min)
                    {
                        // Calculate vignette
                        int v = ((max - distSq) << 8) / diff;
                        v *= v;

                        // Apply vignette
                        int ri = (r * v) >> 16;
                        int gi = (g * v) >> 16;
                        int bi = (b * v) >> 16;

                        // Check bounds
                        r = (byte)(ri > 255 ? 255 : (ri < 0 ? 0 : ri));
                        g = (byte)(gi > 255 ? 255 : (gi < 0 ? 0 : gi));
                        b = (byte)(bi > 255 ? 255 : (bi < 0 ? 0 : bi));
                    }

                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return imageIn;
        }
示例#41
0
 //@Override
 public CustomImage process(CustomImage imageIn)
 {
     for (int x = 0; x < imageIn.getWidth(); x += DOT_AREA)
     {
         for (int y = 0; y < imageIn.getHeight(); y += DOT_AREA)
         {
             drawTone(x, y, imageIn);
         }
     }
     return imageIn;
 }
示例#42
0
 //@Override
 public CustomImage process(CustomImage imageIn)
 {
     ParamEdgeDetectFilter pde = new ParamEdgeDetectFilter();
     pde.K00 = 1;
     pde.K01 = 2;
     pde.K02 = 1;
     pde.Threshold = 0.25f;
     pde.DoGrayConversion = false;
     ImageBlender ib = new ImageBlender();
     ib.Mode = (int)BlendMode.Multiply;
     return ib.Blend(imageIn.clone(), pde.process(imageIn));
 }
示例#43
0
 //@Override
 public CustomImage process(CustomImage imageIn)
 {
     int r, g, b;
     int[] array = new int[256];
     int[] numArray = new int[imageIn.getHeight() * imageIn.getWidth()];
     int contrast = (int)(this.ContrastIntensity * 255f);
     int pos = 0;
     for (int x = 0; x < imageIn.getWidth(); x++)
     {
         for (int y = 0; y < imageIn.getHeight(); y++)
         {
             r = imageIn.getRComponent(x, y);
             g = imageIn.getGComponent(x, y);
             b = imageIn.getBComponent(x, y);
             int index = (r * 0x1b36 + g * 0x5b8c + b * 0x93e) >> 15;
             array[index]++;
             numArray[pos] = index;
             pos++;
         }
     }
     for (int i = 1; i < 0x100; i++)
     {
         array[i] += array[i - 1];
     }
     for (int i = 0; i < 0x100; i++)
     {
         array[i] = (array[i] << 8) / imageIn.getHeight() * imageIn.getWidth();
         array[i] = ((contrast * array[i]) >> 8) + (((0xff - contrast) * i) >> 8);
     }
     pos = 0;
     for (int x = 0; x < imageIn.getWidth(); x++)
     {
         for (int y = 0; y < imageIn.getHeight(); y++)
         {
             r = imageIn.getRComponent(x, y);
             g = imageIn.getGComponent(x, y);
             b = imageIn.getBComponent(x, y);
             if (numArray[pos] != 0)
             {
                 int num = array[numArray[pos]];
                 r = (r * num) / numArray[pos];
                 g = (g * num) / numArray[pos];
                 b = (b * num) / numArray[pos];
                 r = (r > 0xff) ? ((byte)0xff) : ((r < 0) ? ((byte)0) : ((byte)r));
                 g = (g > 0xff) ? ((byte)0xff) : ((g < 0) ? ((byte)0) : ((byte)g));
                 b = (b > 0xff) ? ((byte)0xff) : ((b < 0) ? ((byte)0) : ((byte)b));
             }
             imageIn.setPixelColor(x, y, r, g, b);
             pos++;
         }
     }
     return imageIn;
 }
示例#44
0
 /**
  * Method to extrapolate out
  *
  * @param imageIn
  * @param a_x
  * @param a_y
  * @param squareSize
  * @param a_rgb
  */
 private void fillRect(CustomImage imageIn, int a_x, int a_y, int squareSize, int a_rgb)
 {
     for (int x = a_x; x < a_x + squareSize; x++)
     {
         for (int y = a_y; y < a_y + squareSize; y++)
         {
             if (x < imageIn.getWidth() && y < imageIn.getHeight())
             {
                 imageIn.setPixelColor(x, y, a_rgb);
             }
         }
     }
 }
示例#45
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            int l_rgb;
            for (int x = 0; x < imageIn.getWidth(); x += pixelSize)
            {
                for (int y = 0; y < imageIn.getHeight(); y += pixelSize)
                {
                    l_rgb = getPredominantRGB(imageIn, x, y, pixelSize);
                    fillRect(imageIn, x, y, pixelSize, l_rgb);
                }
            }

            return imageIn;
        }
示例#46
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            int k00 = (int)(K00 * 255f);
            int k01 = (int)(K01 * 255f);
            int k02 = (int)(K02 * 255f);
            int thresholdSqFactor = (int)(Threshold * 255f * 2f);
            int thresholdSq = thresholdSqFactor * thresholdSqFactor;

            if (!DoGrayConversion)
            {
                return ProcessColor(k00, k01, k02, -k00, -k01, -k02, imageIn.clone(), thresholdSq);
            }
            return ProcessGray(k00, k01, k02, -k00, -k01, -k02, imageIn, thresholdSq);
        }
示例#47
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            GradientMapFilter gmf = new GradientMapFilter(Gradient.BlackSepia());
            gmf.ContrastFactor = 0.15f;

            ImageBlender ib = new ImageBlender();
            ib.Mixture = 0.7f;
            ib.Mode = BlendMode.Overlay;
            imageIn = ib.Blend(imageIn.clone(), gmf.process(imageIn));

            VignetteFilter vigette = new VignetteFilter();
            vigette.Size = 0.7f;
            return vigette.process(imageIn);
        }
示例#48
0
 public CustomImage process(CustomImage imageIn)
 {
     int r, g, b;
     for (int x = 0; x < imageIn.getWidth(); x++)
     {
         for (int y = 0; y < imageIn.getHeight(); y++)
         {
             r = (255 - imageIn.getRComponent(x, y));
             g = (255 - imageIn.getGComponent(x, y));
             b = (255 - imageIn.getBComponent(x, y));
             imageIn.setPixelColor(x, y, r, g, b);
         }
     }
     return imageIn;
 }
示例#49
0
 //@Override
 public CustomImage process(CustomImage imageIn)
 {
     int r, g, b, corfinal;
     for (int x = 0; x < imageIn.getWidth(); x++)
     {
         for (int y = 0; y < imageIn.getHeight(); y++)
         {
             r = imageIn.getRComponent(x, y);
             g = imageIn.getGComponent(x, y);
             b = imageIn.getBComponent(x, y);
             corfinal = (int)((r * 0.3) + (b * 0.59) + (g * 0.11));
             imageIn.setPixelColor(x, y, corfinal, corfinal, corfinal);
         }
     }
     return imageIn;
 }
示例#50
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            int r, g, b;
            for (int x = 0; x < imageIn.getWidth(); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y += 3)
                {
                    r = 0;
                    g = 0;
                    b = 0;
                    for (int w = 0; w < 3; w++)
                    {
                        if (y + w < imageIn.getHeight())
                        {
                            r += (imageIn.getRComponent(x, y + w)) / 2;
                            g += (imageIn.getGComponent(x, y + w)) / 2;
                            b += (imageIn.getBComponent(x, y + w)) / 2;
                        }
                    }
                    r = getValidInterval(r);
                    g = getValidInterval(g);
                    b = getValidInterval(b);

                    for (int w = 0; w < 3; w++)
                    {
                        if (y + w < imageIn.getHeight())
                        {
                            if (w == 0)
                            {
                                imageIn.setPixelColor(x, y + w, r, 0, 0);
                            }
                            else if (w == 1)
                            {
                                imageIn.setPixelColor(x, y + w, 0, g, 0);
                            }
                            else if (w == 2)
                            {
                                imageIn.setPixelColor(x, y + w, 0, 0, b);
                            }
                        }
                    }
                }
            }
            return imageIn;
        }
示例#51
0
 //@Override
 public CustomImage process(CustomImage imageIn)
 {
     int width = imageIn.getWidth();
     int height = imageIn.getHeight();
     float[] imageArray = ConvertImageWithPadding(imageIn, width, height);
     imageArray = ApplyBlur(imageArray, width, height);
     int newwidth = width + Padding * 2;
     for (int i = 0; i < height; i++)
     {
         int num = ((i + 3) * newwidth) + 3;
         for (int j = 0; j < width; j++)
         {
             int pos = (num + j) * 3;
             imageIn.setPixelColor(j, i, (byte)(imageArray[pos] * 255f), (byte)(imageArray[pos + 1] * 255f), (byte)(imageArray[pos + 2] * 255f));
         }
     }
     return imageIn;
 }
示例#52
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            int r, g, b;
             int width = imageIn.getWidth();
             int height = imageIn.getHeight();
             int ratio = width >  height ?  height * 32768 / width : width * 32768 /  height;

             // Calculate center, min and max
             int cx = width >> 1;
             int cy = height >> 1;
             int max = cx * cx + cy * cy;
             int min = (int)(max * (1 - Size));
             int diff = max - min;

             for (int x = 0; x < width; x++) {
             for (int y = 0; y < height; y++) {
             	  r = imageIn.getRComponent(x, y);
                  g = imageIn.getGComponent(x, y);
                  b = imageIn.getBComponent(x, y);

                  // Calculate distance to center and adapt aspect ratio
                  int dx = cx - x;
                  int dy = cy - y;
                  if (width > height){
                     dx = (dx * ratio) >> 15;
                  }
                  else{
                     dy = (dy * ratio) >> 15;
                  }
                  int distSq = dx * dx + dy * dy;
                  float v =  ((float)distSq / diff) * 255;
                  r = (int)(r + (v));
                  g = (int)(g + (v));
                  b = (int)(b + (v));
                  r = (byte)(r > 255 ? 255 : (r < 0 ? 0 : r));
                  g = (byte)(g > 255 ? 255 : (g < 0 ? 0 : g));
                  b = (byte)(b > 255 ? 255 : (b < 0 ? 0 : b));
                  imageIn.setPixelColor(x,y,r,g,b);
              }
             }
             return imageIn;
        }
示例#53
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            int r, g, b;
            int threshold = (int)(this.Threshold * 255f);

            for (int x = 0; x < imageIn.getWidth(); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y++)
                {
                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);

                    int rgb = (((r * 0x1b36) + (g * 0x5b8c)) + (b * 0x93e)) >> 15;
                    r = g = b = rgb > threshold ? 0xff : 0;
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return imageIn;
        }
示例#54
0
 //@Override
 public CustomImage process(CustomImage imageIn)
 {
     int width = imageIn.getWidth();
     int height = imageIn.getHeight();
     CustomImage clone = imageIn.clone();
     int r = 0, g = 0, b = 0, avg = 0;
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             r = clone.getRComponent(x, y);
             g = clone.getGComponent(x, y);
             b = clone.getBComponent(x, y);
             avg = (r + g + b) / 3;
             avg = avg >= ThreshHold ? 255 : 0;
             imageIn.setPixelColor(x, y, avg, avg, avg);
         }
     }
     return imageIn;
 }
示例#55
0
 //@Override
 public CustomImage process(CustomImage imageIn)
 {
     int r, g, b, a;
     for (int x = 0; x < imageIn.getWidth(); x++)
     {
         for (int y = 0; y < imageIn.getHeight(); y++)
         {
             r = imageIn.getRComponent(x, y);
             g = imageIn.getGComponent(x, y);
             b = imageIn.getBComponent(x, y);
             float quanR = (((float)((int)(r * 0.003921569f * levels))) / levels) * 255f;
             float quanG = (((float)((int)(g * 0.003921569f * levels))) / levels) * 255f;
             float quanB = (((float)((int)(b * 0.003921569f * levels))) / levels) * 255f;
             r = (quanR > 255f) ? 255 : ((quanR < 0f) ? 0 : ((byte)quanR));
             g = (quanG > 255f) ? 255 : ((quanG < 0f) ? 0 : ((byte)quanG));
             b = (quanB > 255f) ? 255 : ((quanB < 0f) ? 0 : ((byte)quanB));
             imageIn.setPixelColor(x, y, r, g, b);
         }
     }
     return imageIn;
 }
示例#56
0
 //@Override
 public CustomImage process(CustomImage imageIn)
 {
     int width = imageIn.getWidth();
     int height = imageIn.getHeight();
     CustomImage clone = imageIn.clone();
     int r = 0, g = 0, b = 0, xx = 0, yy = 0;
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             int pos = NoiseFilter.getRandomInt(1, 10000) % Model;
             xx = (x + pos) < width ? (x + pos) : (x - pos) >= 0 ? (x - pos) : x;
             yy = (y + pos) < height ? (y + pos) : (y - pos) >= 0 ? (y - pos) : y;
             r = clone.getRComponent(xx, yy);
             g = clone.getGComponent(xx, yy);
             b = clone.getBComponent(xx, yy);
             imageIn.setPixelColor(x, y, r, g, b);
         }
     }
     return imageIn;
 }
示例#57
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            for (int x = 0; x < (imageIn.getWidth() - 1); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y++)
                {
                    int rr = imageIn.getRComponent(x, y) - imageIn.getRComponent(x + 1, y) + 128;
                    int gg = imageIn.getGComponent(x, y) - imageIn.getGComponent(x + 1, y) + 128;
                    int bb = imageIn.getBComponent(x, y) - imageIn.getBComponent(x + 1, y) + 128;

                    if (rr > 255) rr = 255;
                    if (rr < 0) rr = 0;
                    if (gg > 255) gg = 255;
                    if (gg < 0) gg = 0;
                    if (bb > 255) bb = 255;
                    if (bb < 0) bb = 0;

                    imageIn.setPixelColor(x, y, rr, gg, bb);
                }
            }
            return imageIn;
        }
示例#58
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            int r, g, b;

            int height = imageIn.getHeight();
            int width = imageIn.getWidth();
            int start;
            int limit;
            CustomImage clone = imageIn.clone();

            if (this.IsHorizontal)
            {
                int y_offset = (int)(this.Offset * height);
                if (this.Offset > 0.5f)
                {
                    start = y_offset - (height - y_offset);
                    limit = y_offset;
                }
                else
                {
                    start = y_offset;
                    limit = y_offset + y_offset;
                }
                if (start < 0)
                {
                    start = 0;
                }
                for (int y = start; (y < limit) && (y < height); y++)
                {
                    int y_pos = (-y + (2 * y_offset)) - 1;
                    y_pos = (y_pos < 0) ? 0 : (y_pos >= height ? height - 1 : y_pos);
                    for (int x = 0; x < width; x++)
                    {
                        r = clone.getRComponent(x, y);
                        g = clone.getGComponent(x, y);
                        b = clone.getBComponent(x, y);
                        imageIn.setPixelColor(x, y_pos, r, g, b);
                    }
                }
            }
            else
            {
                int x_offset = (int)(this.Offset * width);
                if (this.Offset > 0.5f)
                {
                    start = x_offset - (width - x_offset);
                    limit = x_offset;
                }
                else
                {
                    start = x_offset;
                    limit = x_offset + x_offset;
                }
                if (start < 0)
                {
                    start = 0;
                }
                for (int x = start; (x < limit) && (x < width); x++)
                {
                    int x_pos = (-x + (2 * x_offset)) - 1;
                    x_pos = x_pos < 0 ? 0 : (x_pos >= width ? width - 1 : x_pos);
                    for (int y = 0; y < height; y++)
                    {
                        r = clone.getRComponent(x, y);
                        g = clone.getGComponent(x, y);
                        b = clone.getBComponent(x, y);
                        imageIn.setPixelColor(x_pos, y, r, g, b);
                    }
                }
            }
            return imageIn;
        }
示例#59
0
文件: Perceptron.cs 项目: JFFby/MRO
 private void ExamineImage(CustomImage<ClassType> image)
 {
     AcceptIMage(image);
     GetDeltaSign(image.Class);
 }
示例#60
0
 //@Override
 public CustomImage process(CustomImage imageIn)
 {
     imageIn = gradientMapFx.process(imageIn);
     return saturationFx.process(imageIn);
 }