Download - Стохастичні 4 Андрій
4 : .
: -36 ..: ..
: .: .1. ( , ); 2. ( , ) / ; 3. / . 4. ; 5. () ; 6. ( , ); 7. ( ); 8. ;
:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.IO;using AForge.Video;using AForge.Video.DirectShow;using System.Drawing.Imaging;using System.Runtime.InteropServices;
namespace stmethod{ public partial class Form1 : Form { Bitmap bmp, copyImg; string outputFile, folderPath = ""; ImgInfo ImageInfo; DateTime date;
private FilterInfoCollection VideoCaptureDevices; private VideoCaptureDevice Device; public int FrameCount = 0, GlobalFrameCount = 0;
public bool useOutputFile = true;
PictureBox newLayer = new PictureBox(); private int begin_x; private int begin_y; bool resize = false;
public MatrixAffine Affine = new MatrixAffine(); public PointAffine LT, LB, RT, RB; public Image IMG;
public Image OriginImage;
public Form1() {
InitializeComponent();
// bmp = (Bitmap)pictureBox1.Image; }
private void Form1_Load(object sender, EventArgs e) {
IMG = pictureBox1.Image; OriginImage = pictureBox1.Image;
LT = new PointAffine(pictureBox1.Location.X, pictureBox1.Location.Y); LB = new PointAffine(pictureBox1.Location.X, pictureBox1.Location.Y + IMG.Height); RT = new PointAffine(pictureBox1.Location.X + IMG.Width, pictureBox1.Location.Y); RB = new PointAffine(pictureBox1.Location.X + IMG.Width, pictureBox1.Location.Y + IMG.Height);
newLayer.Parent = pictureBox1; newLayer.BorderStyle = BorderStyle.FixedSingle;
newLayer.BackColor = Color.Transparent; newLayer.SizeMode = PictureBoxSizeMode.AutoSize; newLayer.BorderStyle = BorderStyle.FixedSingle; newLayer.Visible = false;
VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); foreach (FilterInfo d in VideoCaptureDevices) { comboBox1.Items.Add(d.Name); } comboBox1.SelectedIndex = 0; Device = new VideoCaptureDevice();
}
private void Median_Click(object sender, EventArgs e) { pictureBox1.Image = MedianFilter(pictureBox1.Image as Bitmap, (int)numericUpDown1.Value, (int)FilterType.SelectedIndex);
}
public Bitmap MedianFilter(Bitmap inputBitmap, int size, int FilterType) { Console.Write(FilterType); int current = 0; //
int[,] inputPixelValue = new int[inputBitmap.Width, inputBitmap.Height];
// for (int i = 0; i < inputBitmap.Width; i++) { for (int j = 0; j < inputBitmap.Height; j++) { inputPixelValue[i, j] = inputBitmap.GetPixel(i, j).ToArgb(); } }
// int[,] outputPix = new int[inputBitmap.Width, inputBitmap.Height]; // int x_Edge = size / 2, y_Edge = size / 2;
// for (int x = x_Edge; x < inputBitmap.Width - x_Edge; x++) { for (int y = y_Edge; y < inputBitmap.Height - y_Edge; y++) { int[,] window = new int[size, size];
// for (int fx = 0; fx < size; fx++) for (int fy = 0; fy < size; fy++) window[fx, fy] = inputPixelValue[x + fx - x_Edge, y + fy - y_Edge];
// List sort_list = new List(); // for (int i = 0; i