// Apply filter on the image private static void ApplyFilter(IFilter filter, ref Bitmap image) { if (filter is IFilterInformation) { IFilterInformation filterInfo = (IFilterInformation)filter; if (!filterInfo.FormatTransalations.ContainsKey(image.PixelFormat)) { if (filterInfo.FormatTransalations.ContainsKey(PixelFormat.Format24bppRgb)) { MessageBox.Show("The selected image processing routine may be applied to color image only.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show( "The selected image processing routine may be applied to grayscale or binary image only.\n\nUse grayscale (and threshold filter if required) before.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return; } } try { // apply filter to the image image = filter.Apply(image); } catch { MessageBox.Show("Error occured applying selected filter to the image", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ApplyFilter(IFilter filter) { try { // set wait cursor this.Cursor = Cursors.WaitCursor; // apply filter to the image Bitmap newImage = filter.Apply((Bitmap)this.Image.Image); if (backup == null) { backup = this.Image.Image; } this.Image.Image = newImage; } catch (ArgumentException) { MessageBox.Show("Selected filter can not be applied to the image", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }
// Apply filter to the source image and show the filtered image private void ApplyFilter(IFilter filter) { ClearCurrentImage( ); // apply filter filteredImage = filter.Apply(sourceImage); // display filtered image pictureBox.Image = filteredImage; }
// Process new frame public void ProcessFrame(ref Bitmap image) { if (backgroundFrame == null) { // create initial backgroung image backgroundFrame = grayscaleFilter.Apply(image); // just return for the first time return; } Bitmap tmpImage; // apply the the grayscale file tmpImage = grayscaleFilter.Apply(image); if (++counter == 2) { counter = 0; // move background towards current frame moveTowardsFilter.OverlayImage = tmpImage; Bitmap tmp = moveTowardsFilter.Apply(backgroundFrame); // dispose old background backgroundFrame.Dispose(); backgroundFrame = tmp; } // set backgroud frame as an overlay for difference filter differenceFilter.OverlayImage = backgroundFrame; // apply the the filters sequence Bitmap tmpImage2 = processingFilter.Apply(tmpImage); tmpImage.Dispose(); // extract red channel from the original image Bitmap redChannel = extrachChannel.Apply(image); // merge red channel with moving object borders mergeFilter.OverlayImage = tmpImage2; Bitmap tmpImage3 = mergeFilter.Apply(redChannel); redChannel.Dispose(); tmpImage2.Dispose(); // replace red channel in the original image replaceChannel.ChannelImage = tmpImage3; Bitmap tmpImage4 = replaceChannel.Apply(image); tmpImage3.Dispose(); image.Dispose(); image = tmpImage4; }
public async Task <object> Render() { _filter.Apply(); var pagger = await GetPagger(); var query = GetSqlGrid(pagger); var rows = await _connection.QueryAsync <TResult>(query, _optionsFilter); var result = rows.Select(CreateRowResult).ToList(); return(new { Pager = pagger, Rows = result }); }
/// <summary> /// Generate a binary BitmapImage /// </summary> /// <param name="bitmapImage"></param> /// <param name="thresholdLevel"></param> /// <returns></returns> public static BitmapImage Binary(this BitmapImage bitmapImage, int thresholdLevel) { Bitmap bitmap = bitmapImage.BitmapImage2Bitmap(); Threshold threshold = new Threshold(thresholdLevel); IFilter filter = Grayscale.CommonAlgorithms.BT709; bitmap = filter.Apply(bitmap); return(threshold.Apply(bitmap).ToBitmapImage()); }
// Apply filter public Bitmap Apply(Bitmap srcImg) { Bitmap tmpImg = dilatation.Apply(srcImg); Bitmap dstImg = errosion.Apply(tmpImg); tmpImg.Dispose(); return(dstImg); }
private void grayscale() // Apply Grayscale filter { // Declare image Bitmap bmp = new Bitmap(pictureBox1.Image); IFilter filter = Grayscale.CommonAlgorithms.BT709; bmp = filter.Apply(bmp); pictureBox1.Image = bmp; }
// Apply filter to the source image and show the filtered image void ApplyFilter(IFilter filter) { #if !UNITY_WEBPLAYER ClearCurrentImage(); // apply filter filteredImage = filter.Apply(sourceImage); // display filtered image pictureBox.Image = filteredImage; #endif }
public static Image <Pixel8> ApplyFilter(this Image <Pixel8> image, IFilter filter) { Pixel8 pixelFilterOperator(Pixel8[] neighbourhood, Pixel8 currentPixel) { var value = filter.Apply(GetComponentFromNeighbourhood(neighbourhood, p => p.Value)); return(new Pixel8(value)); }; return(image.ApplyFilter(pixelFilterOperator, filter)); }
private void buttonMirror_Click(object sender, EventArgs e) { if (pictureBoxAffineIn.Image == null) { return; } pictureBoxAffineOut.SizeMode = PictureBoxSizeMode.StretchImage; filter = new Mirror(false, true); pictureBoxAffineOut.Image = filter.Apply(AForge.Imaging.Image.Clone((Bitmap)pictureBoxAffineIn.Image, PixelFormat.Format24bppRgb)); }
private void buttonScale_Click(object sender, EventArgs e) { if (pictureBoxAffineIn.Image == null) { return; } pictureBoxAffineOut.SizeMode = PictureBoxSizeMode.CenterImage; filter = new ResizeBicubic(trackBarHalf.Value, trackBarWidth.Value); pictureBoxAffineOut.Image = filter.Apply(AForge.Imaging.Image.Clone((Bitmap)pictureBoxAffineIn.Image, PixelFormat.Format24bppRgb)); }
public Bitmap Apply(BitmapData imageData) { Bitmap bitmap = baseFilter.Apply(imageData); for (int i = 1; i < iterations; i++) { Bitmap bitmap2 = bitmap; bitmap = baseFilter.Apply(bitmap2); bitmap2.Dispose(); } return(bitmap); }
public T Apply(T input) { var val = Process(input); if (_next != null) { val = _next.Apply(val); } return(val); }
// 过滤器 private void ApplyFilter(IFilter filter) { //ClearCurrentImage(); // apply filter Bitmap sourceimage = new Bitmap(System.Windows.Forms.Application.StartupPath + "\\test.jpg"); Bitmap filteredImage = filter.Apply(sourceimage); //canvas.Source =BitmapToBitmapImage(filteredImage); // display filtered image //pictureBox.Image = filteredImage; }
public IEnumerable <Tag> Apply(IEnumerable <Tag> tags) { foreach (var tag in tags) { if (filter.Apply(new[] { tag }).Count() == 0) { yield return(tag); } } }
public static IBitmap ApplyFilter(IBitmap iBitmap, FilterImplementations filterImplementation) { IFilter filter = GetFilter(filterImplementation); if (filter != null && iBitmap != null) { return(filter.Apply(iBitmap)); } return(iBitmap); }
// Apply filter using mask public Bitmap Apply(Bitmap srcImg) { if (baseFilter == null) { throw new NullReferenceException("Base filter is not set"); } // initial iteration Bitmap dstImg = baseFilter.Apply(srcImg); Bitmap tmpImg; // continue iterate for (int i = 1; i < iterations; i++) { tmpImg = dstImg; dstImg = baseFilter.Apply(tmpImg); tmpImg.Dispose(); } return(dstImg); }
public async Task MakeAllFollowingsFollowersFollowRequestAsync(int top = 1000, IFilter <UserInfo> filter = null) { List <UserInfo> currentUserFollowingList = await instaService.GetCurrentUserFollowings(); List <UserInfo> requestList = new List <UserInfo>(); RandomGenerator random = new RandomGenerator(currentUserFollowingList.Count); for (int i = 0; i < currentUserFollowingList.Count; i++) { int index = random.Different(); var following = currentUserFollowingList[index]; logger.Write($"Random UserName : {following.UserName}, Index Order {i}"); List <UserInfo> userInfoList = await instaService.GetUserFollowers(following.UserName, 10); filter = filter ?? FollowerFilter.DefaultFilter(); var filtered = filter.Apply(userInfoList); filtered.RemoveAll(u => currentUserFollowingList.Exists(c => c.Id == u.Id)); if (filtered != null && filtered.Count > 0) { requestList.AddRange(filtered); } if (requestList.Count >= top) { requestList = requestList.Take(top).ToList(); break; } } int requestIndex = 0; try { for (requestIndex = 0; requestIndex < requestList.Count; requestIndex++) { logger.Write($"Requested UserName : {requestList[requestIndex].UserName}, Remaining User {requestList.Count - requestIndex - 1}"); await Retry.DoAsync(() => instaService.FollowUserAsync(requestList[requestIndex].Id), TimeSpan.FromSeconds(3)); } } catch (Exception ex) { logger.Write(ex.ToString()); } finally { if (requestIndex > 0) { FileUtils.WriteAllToRequestedFile(requestList.Take(requestIndex).ToList()); } } }
private Bitmap ProcessCurrentFrame() { Bitmap bmp; //curr_gs = pixelFilter.Apply(curr_gs); if (first) { back = (Bitmap)curr_gs.Clone(); first = false; } /* Detection */ diffFilter.OverlayImage = back; bmp = diffFilter.Apply(curr_gs); bmp = thresholdFilter.Apply(bmp); bmp = blobFilter.Apply(bmp); //bmp = erosionFilter.Apply(bmp); //bmp = openFilter.Apply(bmp); //bmp = edgeFilter.Apply(bmp); try { //blobCount.Text = blobGrabber.Apply(bmp).Size.ToString(); } catch (Exception) { } /* Transcribe to original image */ // extract red channel from the original image //IFilter extrachChannel = new ExtractChannel(RGB.R); //Bitmap redChannel = extrachChannel.Apply(curr_c); // merge red channel with motion regions //Merge mergeFilter = new Merge(); //mergeFilter.OverlayImage = bmp; //Bitmap tmp4 = mergeFilter.Apply(redChannel); // replace red channel in the original image //ReplaceChannel replaceChannel = new ReplaceChannel(RGB.R,tmp4); //curr_c = replaceChannel.Apply(curr_c); /* Background Update */ //towardsFilter.OverlayImage = curr_gs; //back = towardsFilter.Apply(back); morphFilter.OverlayImage = curr_gs; back = morphFilter.Apply(back); return(bmp); }
private void ApplyFilter(IFilter filter) { pictureBox2.Image = null; pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage; // apply filter Bitmap filteredImage = filter.Apply(sourceImage); // display filtered image pictureBox2.Image = filteredImage; pictureBox2.Image.Save(@"e:\BTWork\MachineL\machine_vision\Test\图片处理\12.jpg"); }
private void ActualizarFiltro() { ColorFiltering filtroColor = new ColorFiltering(); filtroColor.Red = red; filtroColor.Green = green; filtroColor.Blue = blue; IFilter filtro = filtroColor; Bitmap bmp = new Bitmap(peCaptcha.Image); Bitmap xImage = filtro.Apply(bmp); peCaptcha.Image = xImage; }
private void ApplyFilter(IFilter filter) { Bitmap sourceImage = (Bitmap)ImagePanel.Image; // apply filter Bitmap filteredImage = null; if (sourceImage != null) { filteredImage = filter.Apply(sourceImage); // display filtered image } else { MessageBox.Show("No image was loaded.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } ImagePanel.Image = filteredImage; }
private void ActualizarFiltro() { ColorFiltering FiltroColor = new ColorFiltering(); FiltroColor.Red = red; FiltroColor.Green = green; FiltroColor.Blue = blue; IFilter Filtro = FiltroColor; Bitmap bmp = new Bitmap(pictureCapchaE.Image); Bitmap XImage = Filtro.Apply(bmp); pictureCapchaE.Image = XImage; }
public async Task <IEnumerable <WorkOrder> > GetWorkOrders(IFilter <WorkOrder> filter, bool includeHistorical) { IQueryable <WorkOrder> workOrders = _repairsContext.WorkOrders.RestrictContractor(_currentUserService) .Include(wo => wo.AssignedToPrimary); workOrders = filter.Apply(workOrders); if (!includeHistorical) { workOrders = workOrders.Where(w => w.Id > 10000000); } return(await workOrders.ToListAsync()); }
public void applyfilter1(IFilter filter) { try { Grayscale g = new Grayscale(0.2125, 0.7154, 0.0721); image = g.Apply(image); Bitmap newImage = filter.Apply(image); pictureBox2.Image = newImage; } catch (ArgumentException) { MessageBox.Show("Selected filter can not be applied to the image", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Filter(IFilter <TDmn, TPermissions> filter) { filter.ValidateNotNullParameter(nameof(filter)); HttpStatusCode filterPermissions = filter.HasPermissions(this.permissions); if (filterPermissions != HttpStatusCode.OK) { throw new RestfulException(filterPermissions); } this.isGetAll = false; this.internalQuery = filter.Apply(this.internalQuery); }
/// <summary> /// Apply filter to an image. /// </summary> /// /// <param name="imageData">Source image to apply filter to.</param> /// /// <returns>Returns filter's result obtained by applying the filter to /// the source image.</returns> /// /// <remarks>The filter accepts bitmap data as input and returns the result /// of image processing filter as new image. The source image data are kept /// unchanged.</remarks> /// public Bitmap Apply(BitmapData imageData) { // initial iteration Bitmap dstImg = baseFilter.Apply(imageData); Bitmap tmpImg; // continue to iterate for (int i = 1; i < iterations; i++) { tmpImg = dstImg; dstImg = baseFilter.Apply(tmpImg); tmpImg.Dispose( ); } return(dstImg); }
private static Bitmap ApplyFilter(IFilter filter, Bitmap image) { IFilterInformation filterInformation = filter as IFilterInformation; if (filterInformation != null && !filterInformation.FormatTranslations.ContainsKey(image.PixelFormat)) { if (filterInformation.FormatTranslations.ContainsKey(PixelFormat.Format24bppRgb)) { return(null); } return(null); } return(filter.Apply(image)); }
private void trackBar_Scroll(object sender, EventArgs e) { if (pictureBoxAffineIn.Image == null) { return; } pictureBoxAffineOut.SizeMode = PictureBoxSizeMode.StretchImage; if (label2.Text == "Height") { return; } filter = new RotateBilinear(trackBarHalf.Value, true); pictureBoxAffineOut.Image = filter.Apply(AForge.Imaging.Image.Clone((Bitmap)pictureBoxAffineIn.Image, PixelFormat.Format24bppRgb)); }
public static bool RotateTest32bpp(IFilter filter, Bitmap input, Bitmap output) { var itm = new ImageToMatrix(); // Test directly Color[,] actual; itm.Convert(filter.Apply(input), out actual); Color[,] expected; itm.Convert(output, out expected); if (!actual.IsEqual(expected)) return false; // Rotate and re-test var rotate = new RotateNearestNeighbor(90, false); input = rotate.Apply(input); output = rotate.Apply(output); itm.Convert(filter.Apply(input), out actual); itm.Convert(output, out expected); return actual.IsEqual(expected); }
private void apply() { if (dataGridView2.CurrentRow != null) { IFilter filter = (dataGridView2.CurrentRow.DataBoundItem as FilterDescriptor).Filter; propertyGrid1.SelectedObject = filter; if (filter == null) { dataGridView1.DataSource = sourceTable; } else { dataGridView1.DataSource = filter.Apply(dataGridView1.DataSource as DataTable); } } }
private void ApplyFilter(IFilter filter) { this.Cursor = Cursors.WaitCursor; Bitmap newImage = filter.Apply(image); if (backup != null) { backup.Dispose(); } backup = image; image = newImage; UpdateNewImage(); this.Cursor = Cursors.Default; }
private void ApplyFilter(IFilter filter) { ClearCurrentImage(); Bitmap filteredImage = null; try { filteredImage = filter.Apply(image.SourceImage); } catch (Exception exc) { MessageBox.Show(exc.ToString()); return; } if (isFilterSet || isContrastBarSetValue || isBrightnesstBarSetValue) { pictureBox1.Image = image.SourceImage = filteredImage; painter.setContext(image.Context); isFilterSet = isContrastBarSetValue = isBrightnesstBarSetValue = false; } else pictureBox1.Image = filteredImage; }
private Bitmap ApplyFilter(IFilter filter) { filteredImage = filter.Apply(sourceImage); return filteredImage; }
public void ApplyFilter(IFilter filter) { filter.Apply(this._bitmap); }
public static Bitmap Apply(this Bitmap bitmap, IFilter filter) { return filter.Apply(bitmap); }
// Apply filter on the image private void ApplyFilter(IFilter filter) { try { // set wait cursor this.Cursor = Cursors.WaitCursor; // apply filter to the image Bitmap newImage = filter.Apply(image); if (host.CreateNewDocumentOnChange) { // open new image in new document host.NewDocument(newImage); } else { if (host.RememberOnChange) { // backup current image if (backup != null) backup.Dispose(); backup = image; } else { // release current image image.Dispose(); } image = newImage; // update UpdateNewImage(); } } catch (ArgumentException) { MessageBox.Show("Selected filter can not be applied to the image", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { // restore cursor this.Cursor = Cursors.Default; } }
public void ApplyFilter(IFilter filter) { try { this.Cursor = Cursors.WaitCursor; SetUndo(); Bitmap newBitmap = filter.Apply(bitmap); if (cropped) newBitmap = filter.Apply(zoomBitmap); if (toGrayscale) { Bitmap tempBitmap = ColorToGrayscale(newBitmap); bitmap = (Bitmap)tempBitmap.Clone(); tempBitmap.Dispose(); toGrayscale = false; } else { bitmap = new Bitmap(newBitmap.Size.Width, newBitmap.Size.Height, PixelFormat.Format24bppRgb); Graphics g = Graphics.FromImage(bitmap); g.DrawImage(newBitmap, new Point(0, 0)); g.Dispose(); } newBitmap.Dispose(); MenuItemUndo.Enabled = true; toolStripButtonUndo.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "SPixel", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } this.imageDisplay.Invalidate(); }
// Apply filter to the source image and show the filtered image private void ApplyFilter( IFilter filter ) { ClearCurrentImage( ); // apply filter filteredImage = filter.Apply( sourceImage ); // display filtered image pictureBox.Image = filteredImage; }
// Apply filter on the image private void ApplyFilter( IFilter filter ) { if ( filter is IFilterInformation ) { IFilterInformation filterInfo = (IFilterInformation) filter; if ( !filterInfo.FormatTransalations.ContainsKey( image.PixelFormat ) ) { if ( filterInfo.FormatTransalations.ContainsKey( PixelFormat.Format24bppRgb ) ) { MessageBox.Show( "The selected image processing routine may be applied to color image only.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); } else { MessageBox.Show( "The selected image processing routine may be applied to grayscale or binary image only.\n\nUse grayscale (and threshold filter if required) before.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); } return; } } try { // set wait cursor this.Cursor = Cursors.WaitCursor; // apply filter to the image Bitmap newImage = filter.Apply( image ); if ( host.CreateNewDocumentOnChange ) { // open new image in new document host.NewDocument( newImage ); } else { if ( host.RememberOnChange ) { // backup current image if ( backup != null ) backup.Dispose( ); backup = image; } else { // release current image image.Dispose( ); } image = newImage; // update UpdateNewImage( ); } } catch { MessageBox.Show( "Error occured applying selected filter to the image", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); } finally { // restore cursor this.Cursor = Cursors.Default; } }
public static HtmlDocument ApplyFilter(this HtmlDocument doc, IFilter filter) { filter.Apply(doc); return doc; }