diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization.sln b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization.sln new file mode 100644 index 0000000..b21ccc7 --- /dev/null +++ b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageQuantization", "ImageQuantization\ImageQuantization.csproj", "{7CA8077F-C27A-400D-B6C9-7737665499AC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7CA8077F-C27A-400D-B6C9-7737665499AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7CA8077F-C27A-400D-B6C9-7737665499AC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7CA8077F-C27A-400D-B6C9-7737665499AC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7CA8077F-C27A-400D-B6C9-7737665499AC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/ImageOperations.cs b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/ImageOperations.cs new file mode 100644 index 0000000..1e1cfe7 --- /dev/null +++ b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/ImageOperations.cs @@ -0,0 +1,369 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Drawing; +using System.Windows.Forms; +using System.Drawing.Imaging; +using System.Linq; +///Algorithms Project +///Intelligent Scissors +/// + +namespace ImageQuantization +{ + /// + /// Holds the pixel color in 3 byte values: red, green and blue + /// + public struct RGBPixel + { + public byte red, green, blue; + } + public struct RGBPixelD + { + public double red, green, blue; + } + + + /// + /// Library of static functions that deal with images + /// + public class ImageOperations + { + /// + /// Open an image and load it into 2D array of colors (size: Height x Width) + /// + /// Image file path + /// 2D array of colors + public static RGBPixel[,] OpenImage(string ImagePath) + { + Bitmap original_bm = new Bitmap(ImagePath); + int Height = original_bm.Height; + int Width = original_bm.Width; + + RGBPixel[,] Buffer = new RGBPixel[Height, Width]; + + unsafe + { + BitmapData bmd = original_bm.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.ReadWrite, original_bm.PixelFormat); + int x, y; + int nWidth = 0; + bool Format32 = false; + bool Format24 = false; + bool Format8 = false; + + if (original_bm.PixelFormat == PixelFormat.Format24bppRgb) + { + Format24 = true; + nWidth = Width * 3; + } + else if (original_bm.PixelFormat == PixelFormat.Format32bppArgb || original_bm.PixelFormat == PixelFormat.Format32bppRgb || original_bm.PixelFormat == PixelFormat.Format32bppPArgb) + { + Format32 = true; + nWidth = Width * 4; + } + else if (original_bm.PixelFormat == PixelFormat.Format8bppIndexed) + { + Format8 = true; + nWidth = Width; + } + int nOffset = bmd.Stride - nWidth; + byte* p = (byte*)bmd.Scan0; + for (y = 0; y < Height; y++) + { + for (x = 0; x < Width; x++) + { + if (Format8) + { + Buffer[y, x].red = Buffer[y, x].green = Buffer[y, x].blue = p[0]; + p++; + } + else + { + Buffer[y, x].red = p[2]; + Buffer[y, x].green = p[1]; + Buffer[y, x].blue = p[0]; + if (Format24) p += 3; + else if (Format32) p += 4; + } + } + p += nOffset; + } + original_bm.UnlockBits(bmd); + } + MST(Buffer); + return Buffer; + } + + /// + /// Get the height of the image + /// + /// 2D array that contains the image + /// Image Height + public static int GetHeight(RGBPixel[,] ImageMatrix) + { + return ImageMatrix.GetLength(0); + } + + /// + /// Get the width of the image + /// + /// 2D array that contains the image + /// Image Width + public static int GetWidth(RGBPixel[,] ImageMatrix) + { + return ImageMatrix.GetLength(1); + } + + /// + /// Display the given image on the given PictureBox object + /// + /// 2D array that contains the image + /// PictureBox object to display the image on it + public static void DisplayImage(RGBPixel[,] ImageMatrix, PictureBox PicBox) + { + // Create Image: + //============== + int Height = ImageMatrix.GetLength(0); + int Width = ImageMatrix.GetLength(1); + + Bitmap ImageBMP = new Bitmap(Width, Height, PixelFormat.Format24bppRgb); + + unsafe + { + BitmapData bmd = ImageBMP.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.ReadWrite, ImageBMP.PixelFormat); + int nWidth = 0; + nWidth = Width * 3; + int nOffset = bmd.Stride - nWidth; + byte* p = (byte*)bmd.Scan0; + for (int i = 0; i < Height; i++) + { + for (int j = 0; j < Width; j++) + { + p[2] = ImageMatrix[i, j].red; + p[1] = ImageMatrix[i, j].green; + p[0] = ImageMatrix[i, j].blue; + p += 3; + } + + p += nOffset; + } + ImageBMP.UnlockBits(bmd); + } + PicBox.Image = ImageBMP; + } + + + /// + /// Apply Gaussian smoothing filter to enhance the edge detection + /// + /// Colored image matrix + /// Gaussian mask size + /// Gaussian sigma + /// smoothed color image + public static RGBPixel[,] GaussianFilter1D(RGBPixel[,] ImageMatrix, int filterSize, double sigma) + { + int Height = GetHeight(ImageMatrix); + int Width = GetWidth(ImageMatrix); + + RGBPixelD[,] VerFiltered = new RGBPixelD[Height, Width]; + RGBPixel[,] Filtered = new RGBPixel[Height, Width]; + + + // Create Filter in Spatial Domain: + //================================= + //make the filter ODD size + if (filterSize % 2 == 0) filterSize++; + + double[] Filter = new double[filterSize]; + + //Compute Filter in Spatial Domain : + //================================== + double Sum1 = 0; + int HalfSize = filterSize / 2; + for (int y = -HalfSize; y <= HalfSize; y++) + { + //Filter[y+HalfSize] = (1.0 / (Math.Sqrt(2 * 22.0/7.0) * Segma)) * Math.Exp(-(double)(y*y) / (double)(2 * Segma * Segma)) ; + Filter[y + HalfSize] = Math.Exp(-(double)(y * y) / (double)(2 * sigma * sigma)); + Sum1 += Filter[y + HalfSize]; + } + for (int y = -HalfSize; y <= HalfSize; y++) + { + Filter[y + HalfSize] /= Sum1; + } + + //Filter Original Image Vertically: + //================================= + int ii, jj; + RGBPixelD Sum; + RGBPixel Item1; + RGBPixelD Item2; + + for (int j = 0; j < Width; j++) + for (int i = 0; i < Height; i++) + { + Sum.red = 0; + Sum.green = 0; + Sum.blue = 0; + for (int y = -HalfSize; y <= HalfSize; y++) + { + ii = i + y; + if (ii >= 0 && ii < Height) + { + Item1 = ImageMatrix[ii, j]; + Sum.red += Filter[y + HalfSize] * Item1.red; + Sum.green += Filter[y + HalfSize] * Item1.green; + Sum.blue += Filter[y + HalfSize] * Item1.blue; + } + } + VerFiltered[i, j] = Sum; + } + + //Filter Resulting Image Horizontally: + //=================================== + for (int i = 0; i < Height; i++) + for (int j = 0; j < Width; j++) + { + Sum.red = 0; + Sum.green = 0; + Sum.blue = 0; + for (int x = -HalfSize; x <= HalfSize; x++) + { + jj = j + x; + if (jj >= 0 && jj < Width) + { + Item2 = VerFiltered[i, jj]; + Sum.red += Filter[x + HalfSize] * Item2.red; + Sum.green += Filter[x + HalfSize] * Item2.green; + Sum.blue += Filter[x + HalfSize] * Item2.blue; + } + } + Filtered[i, j].red = (byte)Sum.red; + Filtered[i, j].green = (byte)Sum.green; + Filtered[i, j].blue = (byte)Sum.blue; + } + + return Filtered; + } + + public static Dictionary G; + + public static Dictionary, double> constructGrapgh(RGBPixel[,] imageMatrix) + { + int height = GetHeight(imageMatrix), width = GetWidth(imageMatrix); + Dictionary distinctColors = new Dictionary(); + Dictionary, double> Graph = new Dictionary, double>(); + for (int i = 0; i < height; i++) + { + for (int j = 0; j < width; j++) + { + distinctColors[imageMatrix[i, j]] = 1; + } + } + foreach (KeyValuePair i in distinctColors) + { + foreach (KeyValuePair j in distinctColors) + { + int x = j.Key.red; + if (i.Key.red == j.Key.red && i.Key.blue == j.Key.blue && i.Key.green == j.Key.green) + { + continue; + } + KeyValuePair currentNode = new KeyValuePair(i.Key, j.Key); + Graph[currentNode] = (GetEgdeWeight(i.Key, j.Key)); + + } + + } + return Graph; + } + + public static double GetEgdeWeight(RGBPixel Color1, RGBPixel Color2) + { + return Math.Sqrt((Math.Pow(Color1.blue - Color2.blue, 2)) + (Math.Pow(Color1.red - Color2.red, 2)) + (Math.Pow(Color1.green - Color2.green, 2))); + } + + public static Dictionary, double> Sorttt(RGBPixel[,] imageMatrix) + { + Dictionary, double> Graph = constructGrapgh(imageMatrix); + + Dictionary, double> Graph2 = new Dictionary, double>(); + + foreach (KeyValuePair, double> item in Graph.OrderBy(key => key.Value)) + { + Graph2[item.Key] = item.Value; + } + + return Graph2; + } + + public struct DisjointSets + { + + Dictionary parent; + Dictionary rank; + // Constructor. + public DisjointSets(Dictionary, double> aa) + { + parent = new Dictionary(); + rank = new Dictionary(); + foreach (var item in aa) + { + + KeyValuePair p = item.Key; + parent[p.Key] = p.Key; + parent[p.Value] = p.Value; + rank[p.Value] = 0; + rank[p.Key] = 0; + } + } + public RGBPixel find(RGBPixel r) + { + if (r.blue != parent[r].blue && r.red != parent[r].red && r.green != parent[r].green) + parent[r] = find(parent[r]); + return parent[r]; + } + + public void merge(RGBPixel x, RGBPixel y) + { + x = find(x); + y = find(y); + + if (rank[x] > rank[y]) + parent[y] = x; + else + parent[x] = y; + + if (rank[x] == rank[y]) + rank[y]++; + } + }; + + public static double MST(RGBPixel[,] imageMatrix) + { + + Dictionary, double> Graphh = Sorttt(imageMatrix); + + double W = 0; + DisjointSets ds = new DisjointSets(Graphh); + foreach (var item in Graphh) + { + KeyValuePair p = item.Key; + RGBPixel u = p.Value; + RGBPixel v = p.Key; + + RGBPixel set_u = ds.find(u); + RGBPixel set_v = ds.find(v); + if (set_u.blue != set_v.blue && set_u.red != set_v.red && set_u.green != set_v.green) + { + W += item.Value; + ds.merge(set_u, set_v); + } + } + + return W; + + } + + } + +} diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/ImageQuantization.csproj b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/ImageQuantization.csproj new file mode 100644 index 0000000..ad08101 --- /dev/null +++ b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/ImageQuantization.csproj @@ -0,0 +1,88 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {7CA8077F-C27A-400D-B6C9-7737665499AC} + WinExe + Properties + ImageQuantization + ImageQuantization + v4.0 + + + + + 2.0 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + Form + + + MainForm.cs + + + + + + Designer + MainForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/MainForm.Designer.cs b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/MainForm.Designer.cs new file mode 100644 index 0000000..699525b --- /dev/null +++ b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/MainForm.Designer.cs @@ -0,0 +1,300 @@ +namespace ImageQuantization +{ + partial class MainForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.pictureBox2 = new System.Windows.Forms.PictureBox(); + this.btnOpen = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.btnGaussSmooth = new System.Windows.Forms.Button(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.txtHeight = new System.Windows.Forms.TextBox(); + this.nudMaskSize = new System.Windows.Forms.NumericUpDown(); + this.txtWidth = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.txtGaussSigma = new System.Windows.Forms.TextBox(); + this.panel1 = new System.Windows.Forms.Panel(); + this.panel2 = new System.Windows.Forms.Panel(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nudMaskSize)).BeginInit(); + this.panel1.SuspendLayout(); + this.panel2.SuspendLayout(); + this.SuspendLayout(); + // + // pictureBox1 + // + this.pictureBox1.Location = new System.Drawing.Point(4, 4); + this.pictureBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(427, 360); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.pictureBox1.TabIndex = 0; + this.pictureBox1.TabStop = false; + // + // pictureBox2 + // + this.pictureBox2.Location = new System.Drawing.Point(4, 4); + this.pictureBox2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.pictureBox2.Name = "pictureBox2"; + this.pictureBox2.Size = new System.Drawing.Size(412, 360); + this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.pictureBox2.TabIndex = 1; + this.pictureBox2.TabStop = false; + // + // btnOpen + // + this.btnOpen.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnOpen.Location = new System.Drawing.Point(480, 526); + this.btnOpen.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnOpen.Name = "btnOpen"; + this.btnOpen.Size = new System.Drawing.Size(109, 76); + this.btnOpen.TabIndex = 2; + this.btnOpen.Text = "Open Image"; + this.btnOpen.UseVisualStyleBackColor = true; + this.btnOpen.Click += new System.EventHandler(this.btnOpen_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(217, 484); + this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(162, 24); + this.label1.TabIndex = 3; + this.label1.Text = "Original Image"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.Location = new System.Drawing.Point(807, 484); + this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(184, 24); + this.label2.TabIndex = 4; + this.label2.Text = "Smoothed Image"; + // + // btnGaussSmooth + // + this.btnGaussSmooth.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnGaussSmooth.Location = new System.Drawing.Point(628, 526); + this.btnGaussSmooth.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnGaussSmooth.Name = "btnGaussSmooth"; + this.btnGaussSmooth.Size = new System.Drawing.Size(109, 76); + this.btnGaussSmooth.TabIndex = 5; + this.btnGaussSmooth.Text = "Gauss Smooth"; + this.btnGaussSmooth.UseVisualStyleBackColor = true; + this.btnGaussSmooth.Click += new System.EventHandler(this.btnGaussSmooth_Click); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(788, 529); + this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(94, 21); + this.label3.TabIndex = 7; + this.label3.Text = "Mask Size"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label4.Location = new System.Drawing.Point(788, 577); + this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(120, 21); + this.label4.TabIndex = 9; + this.label4.Text = "Gauss Sigma"; + // + // txtHeight + // + this.txtHeight.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txtHeight.Location = new System.Drawing.Point(375, 574); + this.txtHeight.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.txtHeight.Name = "txtHeight"; + this.txtHeight.ReadOnly = true; + this.txtHeight.Size = new System.Drawing.Size(75, 27); + this.txtHeight.TabIndex = 8; + // + // nudMaskSize + // + this.nudMaskSize.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.nudMaskSize.Increment = new decimal(new int[] { + 2, + 0, + 0, + 0}); + this.nudMaskSize.Location = new System.Drawing.Point(913, 527); + this.nudMaskSize.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.nudMaskSize.Maximum = new decimal(new int[] { + 99, + 0, + 0, + 0}); + this.nudMaskSize.Minimum = new decimal(new int[] { + 3, + 0, + 0, + 0}); + this.nudMaskSize.Name = "nudMaskSize"; + this.nudMaskSize.Size = new System.Drawing.Size(76, 27); + this.nudMaskSize.TabIndex = 10; + this.nudMaskSize.Value = new decimal(new int[] { + 3, + 0, + 0, + 0}); + // + // txtWidth + // + this.txtWidth.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txtWidth.Location = new System.Drawing.Point(375, 527); + this.txtWidth.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.txtWidth.Name = "txtWidth"; + this.txtWidth.ReadOnly = true; + this.txtWidth.Size = new System.Drawing.Size(75, 27); + this.txtWidth.TabIndex = 11; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label5.Location = new System.Drawing.Point(301, 530); + this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(61, 21); + this.label5.TabIndex = 12; + this.label5.Text = "Width"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label6.Location = new System.Drawing.Point(301, 577); + this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(67, 21); + this.label6.TabIndex = 13; + this.label6.Text = "Height"; + // + // txtGaussSigma + // + this.txtGaussSigma.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txtGaussSigma.Location = new System.Drawing.Point(913, 574); + this.txtGaussSigma.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.txtGaussSigma.Name = "txtGaussSigma"; + this.txtGaussSigma.Size = new System.Drawing.Size(75, 27); + this.txtGaussSigma.TabIndex = 14; + this.txtGaussSigma.Text = "1"; + // + // panel1 + // + this.panel1.AutoScroll = true; + this.panel1.AutoScrollMinSize = new System.Drawing.Size(1, 1); + this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.panel1.Controls.Add(this.pictureBox1); + this.panel1.Location = new System.Drawing.Point(16, 15); + this.panel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(583, 456); + this.panel1.TabIndex = 15; + // + // panel2 + // + this.panel2.AutoScroll = true; + this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.panel2.Controls.Add(this.pictureBox2); + this.panel2.Location = new System.Drawing.Point(628, 15); + this.panel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(560, 456); + this.panel2.TabIndex = 16; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1205, 615); + this.Controls.Add(this.panel2); + this.Controls.Add(this.panel1); + this.Controls.Add(this.txtGaussSigma); + this.Controls.Add(this.label6); + this.Controls.Add(this.label5); + this.Controls.Add(this.txtWidth); + this.Controls.Add(this.nudMaskSize); + this.Controls.Add(this.label4); + this.Controls.Add(this.txtHeight); + this.Controls.Add(this.label3); + this.Controls.Add(this.btnGaussSmooth); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.btnOpen); + this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.Name = "MainForm"; + this.Text = "Image Quantization..."; + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nudMaskSize)).EndInit(); + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + this.panel2.ResumeLayout(false); + this.panel2.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.PictureBox pictureBox2; + private System.Windows.Forms.Button btnOpen; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button btnGaussSmooth; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.TextBox txtHeight; + private System.Windows.Forms.NumericUpDown nudMaskSize; + private System.Windows.Forms.TextBox txtWidth; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.TextBox txtGaussSigma; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Panel panel2; + } +} + diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/MainForm.cs b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/MainForm.cs new file mode 100644 index 0000000..c34df34 --- /dev/null +++ b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/MainForm.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace ImageQuantization +{ + public partial class MainForm : Form + { + public MainForm() + { + InitializeComponent(); + } + + RGBPixel[,] ImageMatrix; + + private void btnOpen_Click(object sender, EventArgs e) + { + OpenFileDialog openFileDialog1 = new OpenFileDialog(); + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + //Open the browsed image and display it + string OpenedFilePath = openFileDialog1.FileName; + ImageMatrix = ImageOperations.OpenImage(OpenedFilePath); + ImageOperations.DisplayImage(ImageMatrix, pictureBox1); + } + txtWidth.Text = ImageOperations.GetWidth(ImageMatrix).ToString(); + txtHeight.Text = ImageOperations.GetHeight(ImageMatrix).ToString(); + } + + private void btnGaussSmooth_Click(object sender, EventArgs e) + { + double sigma = double.Parse(txtGaussSigma.Text); + int maskSize = (int)nudMaskSize.Value ; + ImageMatrix = ImageOperations.GaussianFilter1D(ImageMatrix, maskSize, sigma); + ImageOperations.DisplayImage(ImageMatrix, pictureBox2); + } + + + + } +} \ No newline at end of file diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/MainForm.resx b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/MainForm.resx new file mode 100644 index 0000000..d58980a --- /dev/null +++ b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/MainForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Program.cs b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Program.cs new file mode 100644 index 0000000..daadacf --- /dev/null +++ b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace ImageQuantization +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + + + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + } +} \ No newline at end of file diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Properties/AssemblyInfo.cs b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..343fe02 --- /dev/null +++ b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("IntelligentScissors")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Home")] +[assembly: AssemblyProduct("IntelligentScissors")] +[assembly: AssemblyCopyright("Copyright © Home 2009")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("cbb49b1a-1dc1-45f2-99cc-c9e1de537251")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Properties/Resources.Designer.cs b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Properties/Resources.Designer.cs new file mode 100644 index 0000000..3bf2611 --- /dev/null +++ b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ImageQuantization.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ImageQuantization.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Properties/Resources.resx b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Properties/Settings.Designer.cs b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Properties/Settings.Designer.cs new file mode 100644 index 0000000..bcb019b --- /dev/null +++ b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ImageQuantization.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Properties/Settings.settings b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/bin/Debug/ImageQuantization.exe b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/bin/Debug/ImageQuantization.exe new file mode 100644 index 0000000..15ed89c Binary files /dev/null and b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/bin/Debug/ImageQuantization.exe differ diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/bin/Debug/ImageQuantization.pdb b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/bin/Debug/ImageQuantization.pdb new file mode 100644 index 0000000..138e231 Binary files /dev/null and b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/bin/Debug/ImageQuantization.pdb differ diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.MainForm.resources b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.MainForm.resources new file mode 100644 index 0000000..6c05a97 Binary files /dev/null and b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.MainForm.resources differ diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.Properties.Resources.resources b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.Properties.Resources.resources new file mode 100644 index 0000000..6c05a97 Binary files /dev/null and b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.Properties.Resources.resources differ diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.csproj.FileListAbsolute.txt b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..27a453e --- /dev/null +++ b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.csproj.FileListAbsolute.txt @@ -0,0 +1,8 @@ +C:\Users\Andrew\Desktop\Image-Color-Quantization--master\Image Quantization Startup Code\[TEMPLATE] ImageQuantization\ImageQuantization\bin\Debug\ImageQuantization.exe +C:\Users\Andrew\Desktop\Image-Color-Quantization--master\Image Quantization Startup Code\[TEMPLATE] ImageQuantization\ImageQuantization\bin\Debug\ImageQuantization.pdb +C:\Users\Andrew\Desktop\Image-Color-Quantization--master\Image Quantization Startup Code\[TEMPLATE] ImageQuantization\ImageQuantization\obj\Debug\ImageQuantization.csprojAssemblyReference.cache +C:\Users\Andrew\Desktop\Image-Color-Quantization--master\Image Quantization Startup Code\[TEMPLATE] ImageQuantization\ImageQuantization\obj\Debug\ImageQuantization.MainForm.resources +C:\Users\Andrew\Desktop\Image-Color-Quantization--master\Image Quantization Startup Code\[TEMPLATE] ImageQuantization\ImageQuantization\obj\Debug\ImageQuantization.Properties.Resources.resources +C:\Users\Andrew\Desktop\Image-Color-Quantization--master\Image Quantization Startup Code\[TEMPLATE] ImageQuantization\ImageQuantization\obj\Debug\ImageQuantization.csproj.GenerateResource.cache +C:\Users\Andrew\Desktop\Image-Color-Quantization--master\Image Quantization Startup Code\[TEMPLATE] ImageQuantization\ImageQuantization\obj\Debug\ImageQuantization.exe +C:\Users\Andrew\Desktop\Image-Color-Quantization--master\Image Quantization Startup Code\[TEMPLATE] ImageQuantization\ImageQuantization\obj\Debug\ImageQuantization.pdb diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.csproj.GenerateResource.cache b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.csproj.GenerateResource.cache new file mode 100644 index 0000000..bebd680 Binary files /dev/null and b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.csproj.GenerateResource.cache differ diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.csprojAssemblyReference.cache b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.csprojAssemblyReference.cache new file mode 100644 index 0000000..de1b3c2 Binary files /dev/null and b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.csprojAssemblyReference.cache differ diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.exe b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.exe new file mode 100644 index 0000000..15ed89c Binary files /dev/null and b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.exe differ diff --git a/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.pdb b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.pdb new file mode 100644 index 0000000..138e231 Binary files /dev/null and b/Image-Color-Quantization--master/Image Quantization Startup Code/[TEMPLATE] ImageQuantization/ImageQuantization/obj/Debug/ImageQuantization.pdb differ