OpenCLImageFilter hinzugefügt

This commit is contained in:
BlubbFish 2017-03-09 20:44:48 +00:00
commit 487a0819ce
25 changed files with 3394 additions and 0 deletions

View File

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCLImageFilter", "WindowsFormsApplication1\OpenCLImageFilter.csproj", "{25E1C72C-5114-4EA3-8DD8-F9435E832214}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{25E1C72C-5114-4EA3-8DD8-F9435E832214}.Debug|x86.ActiveCfg = Debug|x86
{25E1C72C-5114-4EA3-8DD8-F9435E832214}.Debug|x86.Build.0 = Debug|x86
{25E1C72C-5114-4EA3-8DD8-F9435E832214}.Release|x86.ActiveCfg = Release|x86
{25E1C72C-5114-4EA3-8DD8-F9435E832214}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

303
WindowsFormsApplication1/Form1.Designer.cs generated Normal file
View File

@ -0,0 +1,303 @@
namespace OpenCLImageFilter
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pictureBrowse = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.pictureFile = new System.Windows.Forms.TextBox();
this.openclBrowse = new System.Windows.Forms.Button();
this.openCLFile = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.openFileDialog2 = new System.Windows.Forms.OpenFileDialog();
this.buttonApplyFilter = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.buttonBrowseFilter = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.textStatus = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.filterSelector = new System.Windows.Forms.ComboBox();
this.openFileDialog3 = new System.Windows.Forms.OpenFileDialog();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// pictureBrowse
//
this.pictureBrowse.Location = new System.Drawing.Point(224, 16);
this.pictureBrowse.Name = "pictureBrowse";
this.pictureBrowse.Size = new System.Drawing.Size(85, 20);
this.pictureBrowse.TabIndex = 0;
this.pictureBrowse.Text = "Browse...";
this.pictureBrowse.UseVisualStyleBackColor = true;
this.pictureBrowse.Click += new System.EventHandler(this.button1_Click);
//
// openFileDialog1
//
this.openFileDialog1.Filter = "Images|*.bmp;*.jpg;*.png";
this.openFileDialog1.Title = "Select Source Image";
//
// pictureFile
//
this.pictureFile.Location = new System.Drawing.Point(73, 16);
this.pictureFile.Name = "pictureFile";
this.pictureFile.Size = new System.Drawing.Size(145, 20);
this.pictureFile.TabIndex = 1;
this.pictureFile.Text = "..\\..\\Bild2.png";
this.pictureFile.TextChanged += new System.EventHandler(this.pictureFile_TextChanged);
//
// openclBrowse
//
this.openclBrowse.Location = new System.Drawing.Point(224, 42);
this.openclBrowse.Name = "openclBrowse";
this.openclBrowse.Size = new System.Drawing.Size(85, 20);
this.openclBrowse.TabIndex = 2;
this.openclBrowse.Text = "Browse...";
this.openclBrowse.UseVisualStyleBackColor = true;
this.openclBrowse.Click += new System.EventHandler(this.openclBrowse_Click);
//
// openCLFile
//
this.openCLFile.Location = new System.Drawing.Point(73, 42);
this.openCLFile.Name = "openCLFile";
this.openCLFile.Size = new System.Drawing.Size(145, 20);
this.openCLFile.TabIndex = 3;
this.openCLFile.Text = "..\\..\\filter.cl";
this.openCLFile.TextChanged += new System.EventHandler(this.openCLFile_TextChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 20);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(64, 13);
this.label1.TabIndex = 4;
this.label1.Text = "Image-Path:";
this.label1.Click += new System.EventHandler(this.label1_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 45);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(50, 13);
this.label2.TabIndex = 5;
this.label2.Text = "\"filter.cl\":";
//
// openFileDialog2
//
this.openFileDialog2.Filter = "OpenCL|*.cl";
this.openFileDialog2.Title = "Select OpenCL-File";
//
// buttonApplyFilter
//
this.buttonApplyFilter.Location = new System.Drawing.Point(234, 41);
this.buttonApplyFilter.Name = "buttonApplyFilter";
this.buttonApplyFilter.Size = new System.Drawing.Size(75, 21);
this.buttonApplyFilter.TabIndex = 6;
this.buttonApplyFilter.Text = "Apply Filter";
this.buttonApplyFilter.UseVisualStyleBackColor = true;
this.buttonApplyFilter.Click += new System.EventHandler(this.button1_Click_1);
//
// pictureBox1
//
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox1.Location = new System.Drawing.Point(9, 110);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(300, 300);
this.pictureBox1.TabIndex = 7;
this.pictureBox1.TabStop = false;
//
// pictureBox2
//
this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox2.Location = new System.Drawing.Point(9, 112);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(300, 300);
this.pictureBox2.TabIndex = 8;
this.pictureBox2.TabStop = false;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.pictureBox1);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.openCLFile);
this.groupBox1.Controls.Add(this.pictureFile);
this.groupBox1.Controls.Add(this.pictureBrowse);
this.groupBox1.Controls.Add(this.openclBrowse);
this.groupBox1.Location = new System.Drawing.Point(15, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(319, 421);
this.groupBox1.TabIndex = 11;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Source-Image";
this.groupBox1.Enter += new System.EventHandler(this.groupBox1_Enter);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.textBox1);
this.groupBox2.Controls.Add(this.button1);
this.groupBox2.Controls.Add(this.buttonBrowseFilter);
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.textStatus);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.filterSelector);
this.groupBox2.Controls.Add(this.pictureBox2);
this.groupBox2.Controls.Add(this.buttonApplyFilter);
this.groupBox2.Location = new System.Drawing.Point(349, 12);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(319, 421);
this.groupBox2.TabIndex = 12;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Output-Image";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(74, 41);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(73, 20);
this.textBox1.TabIndex = 8;
this.textBox1.Text = "100";
//
// button1
//
this.button1.Location = new System.Drawing.Point(153, 41);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 21);
this.button1.TabIndex = 13;
this.button1.Text = "Apply Again";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click_2);
//
// buttonBrowseFilter
//
this.buttonBrowseFilter.Location = new System.Drawing.Point(234, 15);
this.buttonBrowseFilter.Name = "buttonBrowseFilter";
this.buttonBrowseFilter.Size = new System.Drawing.Size(75, 21);
this.buttonBrowseFilter.TabIndex = 8;
this.buttonBrowseFilter.Text = "Browse...";
this.buttonBrowseFilter.UseVisualStyleBackColor = true;
this.buttonBrowseFilter.Click += new System.EventHandler(this.buttonBrowseFilter_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(6, 70);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(37, 13);
this.label4.TabIndex = 12;
this.label4.Text = "Status";
//
// textStatus
//
this.textStatus.BackColor = System.Drawing.SystemColors.Control;
this.textStatus.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textStatus.Enabled = false;
this.textStatus.Location = new System.Drawing.Point(9, 86);
this.textStatus.Name = "textStatus";
this.textStatus.Size = new System.Drawing.Size(300, 13);
this.textStatus.TabIndex = 11;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(6, 20);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(62, 13);
this.label3.TabIndex = 10;
this.label3.Text = "Select Filter";
this.label3.Click += new System.EventHandler(this.label3_Click);
//
// filterSelector
//
this.filterSelector.FormattingEnabled = true;
this.filterSelector.Location = new System.Drawing.Point(74, 15);
this.filterSelector.Name = "filterSelector";
this.filterSelector.Size = new System.Drawing.Size(154, 21);
this.filterSelector.TabIndex = 9;
this.filterSelector.SelectedIndexChanged += new System.EventHandler(this.filterSelector_SelectedIndexChanged);
//
// openFileDialog3
//
this.openFileDialog3.Filter = "Filter-Matrix|filter*.txt";
this.openFileDialog3.Title = "Select Filter-File";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(681, 450);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.groupBox2);
this.Name = "Form1";
this.Text = "OpenCL ImageFilter";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button pictureBrowse;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.TextBox pictureFile;
private System.Windows.Forms.Button openclBrowse;
private System.Windows.Forms.TextBox openCLFile;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.OpenFileDialog openFileDialog2;
private System.Windows.Forms.Button buttonApplyFilter;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ComboBox filterSelector;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textStatus;
private System.Windows.Forms.Button buttonBrowseFilter;
private System.Windows.Forms.OpenFileDialog openFileDialog3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
}
}

View File

@ -0,0 +1,171 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using SimpleOpenCLRunner;
namespace OpenCLImageFilter
{
public partial class Form1 : Form
{
private ImageFilter oImageFilter;
public Form1()
{
InitializeComponent();
this.oImageFilter = new ImageFilter();
this.setPicture();
this.readCL();
}
private void button1_Click(object sender, EventArgs e)
{
this.openFileDialog1.FileName = this.pictureFile.Text;
if (this.openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if (!File.Exists(this.openFileDialog1.FileName))
{
MessageBox.Show("Invalid Picture Path");
return;
}
this.pictureFile.Text = openFileDialog1.FileName;
this.setPicture();
}
}
private void openclBrowse_Click(object sender, EventArgs e)
{
this.openFileDialog2.FileName = this.openCLFile.Text;
if (this.openFileDialog2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if (!File.Exists(this.openFileDialog2.FileName))
{
MessageBox.Show("Invalid OpenCL-File Path");
return;
}
this.openCLFile.Text = openFileDialog2.FileName;
this.readCL();
}
}
private void button1_Click_1(object sender, EventArgs e)
{
this.readCL();
if (!File.Exists(this.pictureFile.Text))
{
MessageBox.Show("Invalid Picture Path");
return;
}
Bitmap org_file = new Bitmap(this.pictureFile.Text);
this.pictureBox1.Image = org_file;
this.Refresh();
this.pictureBox2.Image = this.oImageFilter.run(org_file, this.textStatus);
this.Refresh();
}
private void label4_Click(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
private void label3_Click(object sender, EventArgs e)
{
}
private void buttonBrowseFilter_Click(object sender, EventArgs e)
{
this.openFileDialog3.FileName = this.openCLFile.Text;
if (this.openFileDialog3.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if (!File.Exists(this.openFileDialog3.FileName))
{
MessageBox.Show("Invalid Filter-File Path");
return;
}
if (!this.filterSelector.Items.Contains(this.openFileDialog3.FileName))
{
this.filterSelector.Items.Add(this.openFileDialog3.FileName);
}
this.filterSelector.SelectedIndex = this.filterSelector.Items.IndexOf(this.openFileDialog3.FileName);
this.setFilter();
}
}
private void filterSelector_SelectedIndexChanged(object sender, EventArgs e)
{
this.setFilter();
}
private void setFilter()
{
this.textStatus.Text = "Preparing Filter...";
this.Refresh();
string oFileName = (string)this.filterSelector.Items[this.filterSelector.SelectedIndex];
this.oImageFilter.readMask(oFileName);
this.textStatus.Text += " Done!";
this.Refresh();
}
private void setPicture()
{
this.textStatus.Text = "Reading Source-Image...";
this.Refresh();
Bitmap org_file = new Bitmap(this.pictureFile.Text);
this.pictureBox1.Image = org_file;
this.textStatus.Text += " Done!";
this.Refresh();
}
private void readCL()
{
this.textStatus.Text = "Preparing OpenCL-File...";
this.Refresh();
this.oImageFilter.readCL(this.openCLFile.Text);
this.textStatus.Text += " Done!";
this.Refresh();
}
private void button1_Click_2(object sender, EventArgs e)
{
this.textStatus.Text = "Running " + this.textBox1.Text + " times incrementell...";
this.pictureBox2.Image = this.oImageFilter.run_again(int.Parse(this.textBox1.Text));
this.Refresh();
this.textStatus.Text += " Done!";
}
private void pictureFile_TextChanged(object sender, EventArgs e)
{
this.setPicture();
}
private void openCLFile_TextChanged(object sender, EventArgs e)
{
this.readCL();
}
}
}

View File

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="openFileDialog2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>150, 17</value>
</metadata>
<metadata name="textStatus.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="openFileDialog3.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>283, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,181 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using OpenCLTemplate;
using System.Windows.Forms;
using System.IO;
using SimpleOpenCLRunner;
namespace OpenCLImageFilter
{
class ImageFilter
{
private float[] afMask;
private bool bInit = false;
private Bitmap oInputImage;
private byte[] bPicture;
private byte[] bPictureOut;
private int[] anWorkers;
public ImageFilter()
{
OpenCLRunner.init();
}
public void readCL(string oFileName)
{
OpenCLRunner.readCL(oFileName);
OpenCLRunner.compile();
}
public void readMask(string oFileName)
{
StreamReader oBuffer = new StreamReader(oFileName, System.Text.Encoding.UTF8);
int size = int.Parse(oBuffer.ReadLine());
float[] afMask = new float[size * size];
String[] oVars;
for (int nI = 0; nI < size; nI++)
{
oVars = (oBuffer.ReadLine()).Split(',');
for (int nJ = 0; nJ < size; nJ++)
{
afMask[nJ * size + nI] = float.Parse(oVars[nJ]);
}
}
this.setMask(afMask);
}
public void setMask(float[] afMask)
{
this.afMask = afMask;
this.bInit = true;
int nMaskSize = (int)Math.Sqrt((double)this.afMask.Length);
OpenCLRunner.createVariable("mask", this.afMask);
OpenCLRunner.createVariable("maskSize", new int[] { nMaskSize });
}
public Bitmap run_again(int times)
{
if (!this.bInit)
{
MessageBox.Show("Select an Filter first!");
return new Bitmap(1,1);
}
Bitmap oOutputImage = new Bitmap(this.oInputImage.Width, this.oInputImage.Height);
OpenCLRunner.createFunction("recycle", new string[] {"pictureIn",
"pictureOut",
"dimensions"});
for (int nI = 0; nI < times; nI++)
{
OpenCLRunner.runFunction("recycle");
OpenCLRunner.runFunction("filter");
}
OpenCLRunner.returnData("pictureOut", ref bPictureOut);
//unserialzing the image
long i;
i = 0;
for (int nI = 0; nI < oInputImage.Height; nI++)
{
for (int nJ = 0; nJ < oInputImage.Width; nJ++)
{
oOutputImage.SetPixel(nJ, nI, Color.FromArgb((int)bPictureOut[i + 0], (int)bPictureOut[i + 1], (int)bPictureOut[i + 2], (int)bPictureOut[i + 3]));
i += 4;
}
}
return oOutputImage;
}
public Bitmap run(Bitmap oInputImage, TextBox textStatus)
{
if (!this.bInit)
{
MessageBox.Show("Select an Filter first!");
return oInputImage;
}
textStatus.Text = "Preparing Image...";
textStatus.Parent.Refresh();
Bitmap oOutputImage = new Bitmap(oInputImage.Width, oInputImage.Height);
this.oInputImage = oInputImage;
this.bPicture = new byte[oInputImage.Width * oInputImage.Height * 4];
this.bPictureOut = new byte[oInputImage.Width * oInputImage.Height * 4];
this.anWorkers = new int[] { oInputImage.Height, oInputImage.Width };
OpenCLRunner.setWorkers(this.anWorkers);
//serializing the Image
long i = 0;
for (int nI = 0; nI < oInputImage.Height; nI++)
{
for (int nJ = 0; nJ < oInputImage.Width; nJ++)
{
this.bPicture[i + 0] = oInputImage.GetPixel(nJ, nI).A;
this.bPicture[i + 1] = oInputImage.GetPixel(nJ, nI).R;
this.bPicture[i + 2] = oInputImage.GetPixel(nJ, nI).G;
this.bPicture[i + 3] = oInputImage.GetPixel(nJ, nI).B;
i += 4;
}
}
textStatus.Text = "Sending Image to GPU...";
textStatus.Parent.Refresh();
OpenCLRunner.createVariable("pictureIn", bPicture);
OpenCLRunner.createVariable("pictureOut", bPictureOut);
OpenCLRunner.createVariable("dimensions", new int[] { oInputImage.Width, oInputImage.Height });
textStatus.Text = "Calculating...";
textStatus.Parent.Refresh();
OpenCLRunner.createFunction("filter", new string[] { "pictureIn",
"pictureOut",
"dimensions",
"mask",
"maskSize" });
OpenCLRunner.runFunction("filter");
textStatus.Text = "Pulling back the data...";
textStatus.Parent.Refresh();
OpenCLRunner.returnData("pictureOut", ref bPictureOut);
//unserializing the image
i = 0;
for (int nI = 0; nI < oInputImage.Height; nI++)
{
for (int nJ = 0; nJ < oInputImage.Width; nJ++)
{
oOutputImage.SetPixel(nJ, nI, Color.FromArgb((int)bPictureOut[i + 0], (int)bPictureOut[i + 1], (int)bPictureOut[i + 2], (int)bPictureOut[i + 3]));
i += 4;
}
}
textStatus.Text += " Done!";
textStatus.Parent.Refresh();
return oOutputImage;
}
}
}

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{25E1C72C-5114-4EA3-8DD8-F9435E832214}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OpenCLImageFilter</RootNamespace>
<AssemblyName>WindowsFormsApplication1</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="OpenCL.NET, Version=1.0.48.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Code Snippets\OpenCLTemplate\OpenCL.NET.dll</HintPath>
</Reference>
<Reference Include="OpenCLTemplate, Version=1.0.8.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Code Snippets\OpenCLTemplate\OpenCLTemplate.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ImageFilter.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="OpenCLRunner.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,560 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using OpenCLTemplate;
using System.Windows.Forms;
namespace SimpleOpenCLRunner
{
class OpenCLRunner
{
private static String oCLCode;
private static bool bInit = false;
private static bool bCompiled = false;
private static bool bRead = false;
private static int[] anWorkers = new int[] { 1 };
private static TimeSpan oElapsedExecutionTime;
private static TimeSpan oElapsedInitTime;
private static TimeSpan oElapsedCompileTime;
private static System.Diagnostics.Stopwatch oWatch = new System.Diagnostics.Stopwatch();
private static Dictionary<string, OpenCLFunction> oFunctionDict = new Dictionary<string, OpenCLFunction>();
private static Dictionary<string, OpenCLVariable> oVarDict = new Dictionary<string, OpenCLVariable>();
private static List<string> oCompileLogsList = new List<string>();
public static bool init()
{
try
{
System.Diagnostics.Stopwatch oWatch = new System.Diagnostics.Stopwatch();
oWatch.Start();
//init
CLCalc.InitCL();
OpenCLRunner.bInit = true;
oWatch.Stop();
OpenCLRunner.oElapsedInitTime = oWatch.Elapsed; CLCalc.InitCL();
}
catch (Exception e)
{
MessageBox.Show("CLCalc-Error:\n===================\n\n" + e.ToString() + "\n\n" + e.Message);
OpenCLRunner.bInit = false;
}
return OpenCLRunner.bInit;
}
public static void start()
{
OpenCLRunner.oWatch.Start();
}
public static TimeSpan stop()
{
OpenCLRunner.oWatch.Stop();
return OpenCLRunner.oWatch.Elapsed;
}
public static void setWorkers(int[] anWorkers)
{
OpenCLRunner.anWorkers = anWorkers;
}
public static int[] getWorkers()
{
return OpenCLRunner.anWorkers;
}
public static TimeSpan getExecutionTime()
{
return OpenCLRunner.oElapsedExecutionTime;
}
public static TimeSpan getInitTime()
{
return OpenCLRunner.oElapsedInitTime;
}
public static TimeSpan getCompileTime()
{
return OpenCLRunner.oElapsedCompileTime;
}
public static void readCL(String oFilename)
{
if (!OpenCLRunner.bInit)
{
OpenCLRunner.init();
}
if (!File.Exists(oFilename))
{
MessageBox.Show("Datei \"" + oFilename + "\" nicht vorhanden");
OpenCLRunner.bRead = false;
}
else
{
StreamReader oBuffer = new StreamReader(oFilename, System.Text.Encoding.UTF8);
OpenCLRunner.bRead = false;
OpenCLRunner.oCLCode = "";
while (!oBuffer.EndOfStream)
{
OpenCLRunner.oCLCode += oBuffer.ReadLine() + "\r\n";
}
oBuffer.Close();
OpenCLRunner.bCompiled = false;
OpenCLRunner.bRead = true;
}
}
public static bool compile()
{
if (OpenCLRunner.bInit)
{
if (OpenCLRunner.bRead)
{
try
{
System.Diagnostics.Stopwatch oWatch = new System.Diagnostics.Stopwatch();
oWatch.Start();
OpenCLRunner.bCompiled = false;
CLCalc.Program.Compile(OpenCLRunner.oCLCode, out OpenCLRunner.oCompileLogsList);
OpenCLRunner.bCompiled = true;
oWatch.Stop();
OpenCLRunner.oElapsedCompileTime = oWatch.Elapsed;
}
catch (Exception e)
{
MessageBox.Show("CLCalc-Error:\n===================\n\n" + e.ToString() + "\n\n" + e.Data);
List<string>.Enumerator iCompileLogs = OpenCLRunner.oCompileLogsList.GetEnumerator();
while(iCompileLogs.MoveNext())
{
MessageBox.Show("CompileLogs:\n===================\n\n" + iCompileLogs.Current);
}
}
}
else
{
MessageBox.Show("CL-Code must be read before compile!");
}
}
else
{
MessageBox.Show("CL-Device must be initiated before compile!");
}
return OpenCLRunner.bCompiled;
}
public static OpenCLFunction createFunction(String oCLFunctionName, string[] oVarNames)
{
return OpenCLRunner.createFunction(oCLFunctionName, OpenCLRunner.Variables(oVarNames));
}
public static OpenCLFunction createFunction(String oCLFunctionName, OpenCLVariable[] aoCLVars)
{
OpenCLFunction oCLFunction = OpenCLRunner.createFunction(oCLFunctionName);
oCLFunction.setVars(aoCLVars);
return oCLFunction;
}
public static OpenCLFunction createFunction(String oCLFunctionName)
{
OpenCLFunction oCLFunction;
if (OpenCLRunner.oFunctionDict.ContainsKey(oCLFunctionName))
{
OpenCLRunner.oFunctionDict.TryGetValue(oCLFunctionName, out oCLFunction);
}
else
{
oCLFunction = new OpenCLFunction(oCLFunctionName);
OpenCLRunner.oFunctionDict.Add(oCLFunctionName, oCLFunction);
}
return oCLFunction;
}
public static OpenCLVariable createVariable(string oVarName, float[] fInput)
{
OpenCLVariable oCLVar;
if (OpenCLRunner.oVarDict.TryGetValue(oVarName, out oCLVar))
{
oCLVar.set(fInput);
}
else
{
oCLVar = new OpenCLVariable(fInput);
OpenCLRunner.oVarDict.Add(oVarName, oCLVar);
}
return oCLVar;
}
public static OpenCLVariable createVariable(string oVarName, byte[] bInput)
{
OpenCLVariable oCLVar;
if (OpenCLRunner.oVarDict.TryGetValue(oVarName, out oCLVar))
{
oCLVar.set(bInput);
}
else
{
oCLVar = new OpenCLVariable(bInput);
OpenCLRunner.oVarDict.Add(oVarName, oCLVar);
}
return oCLVar;
}
public static OpenCLVariable createVariable(string oVarName, double[] dInput)
{
OpenCLVariable oCLVar;
if (OpenCLRunner.oVarDict.TryGetValue(oVarName, out oCLVar))
{
oCLVar.set(dInput);
}
else
{
oCLVar = new OpenCLVariable(dInput);
OpenCLRunner.oVarDict.Add(oVarName, oCLVar);
}
return oCLVar;
}
public static OpenCLVariable createVariable(string oVarName, char[] cInput)
{
OpenCLVariable oCLVar;
if (OpenCLRunner.oVarDict.TryGetValue(oVarName, out oCLVar))
{
oCLVar.set(cInput);
}
else
{
oCLVar = new OpenCLVariable(cInput);
OpenCLRunner.oVarDict.Add(oVarName, oCLVar);
}
return oCLVar;
}
public static OpenCLVariable createVariable(string oVarName, int[] nInput)
{
OpenCLVariable oCLVar;
if (OpenCLRunner.oVarDict.TryGetValue(oVarName, out oCLVar))
{
oCLVar.set(nInput);
}
else
{
oCLVar = new OpenCLVariable(nInput);
OpenCLRunner.oVarDict.Add(oVarName, oCLVar);
}
return oCLVar;
}
public static OpenCLVariable createVariable(string oVarName, long[] lInput)
{
OpenCLVariable oCLVar;
if (OpenCLRunner.oVarDict.TryGetValue(oVarName, out oCLVar))
{
oCLVar.set(lInput);
}
else
{
oCLVar = new OpenCLVariable(lInput);
OpenCLRunner.oVarDict.Add(oVarName, oCLVar);
}
return oCLVar;
}
public static OpenCLVariable Variable(string oVarName)
{
OpenCLVariable oCLVar;
if (!OpenCLRunner.oVarDict.TryGetValue(oVarName, out oCLVar))
{
MessageBox.Show("Variable \"" + oVarName + "\" existiert nicht!");
}
return oCLVar;
}
public static OpenCLVariable[] Variables(string[] oVarNames)
{
OpenCLVariable[] oCLVars = new OpenCLVariable[oVarNames.Length];
for (int nI = 0; nI < oVarNames.Length; nI++)
{
if (!OpenCLRunner.oVarDict.TryGetValue(oVarNames[nI], out oCLVars[nI]))
{
MessageBox.Show("Variable \"" + oVarNames[nI] + "\" existiert nicht!");
}
}
return oCLVars;
}
public static bool returnData(string oVarName, ref byte[] bOutput)
{
OpenCLVariable oCLVar;
if (OpenCLRunner.oVarDict.TryGetValue(oVarName, out oCLVar))
{
oCLVar.returnData(ref bOutput);
return true;
}
else
{
MessageBox.Show("Variable \"" + oVarName + "\" existiert nicht!");
return false;
}
}
public static bool returnData(string oVarName, ref float[] fOutput)
{
OpenCLVariable oCLVar;
if (OpenCLRunner.oVarDict.TryGetValue(oVarName, out oCLVar))
{
oCLVar.returnData(ref fOutput);
return true;
}
else
{
MessageBox.Show("Variable \"" + oVarName + "\" existiert nicht!");
return false;
}
}
public static bool returnData(string oVarName, ref double[] dOutput)
{
OpenCLVariable oCLVar;
if (OpenCLRunner.oVarDict.TryGetValue(oVarName, out oCLVar))
{
oCLVar.returnData(ref dOutput);
return true;
}
else
{
MessageBox.Show("Variable \"" + oVarName + "\" existiert nicht!");
return false;
}
}
public static bool returnData(string oVarName, ref int[] nOutput)
{
OpenCLVariable oCLVar;
if (OpenCLRunner.oVarDict.TryGetValue(oVarName, out oCLVar))
{
oCLVar.returnData(ref nOutput);
return true;
}
else
{
MessageBox.Show("Variable \"" + oVarName + "\" existiert nicht!");
return false;
}
}
public static bool returnData(string oVarName, ref long[] lOutput)
{
OpenCLVariable oCLVar;
if (OpenCLRunner.oVarDict.TryGetValue(oVarName, out oCLVar))
{
oCLVar.returnData(ref lOutput);
return true;
}
else
{
MessageBox.Show("Variable \"" + oVarName + "\" existiert nicht!");
return false;
}
}
public static bool returnData(string oVarName, ref char[] cOutput)
{
OpenCLVariable oCLVar;
if (OpenCLRunner.oVarDict.TryGetValue(oVarName, out oCLVar))
{
oCLVar.returnData(ref cOutput);
return true;
}
else
{
MessageBox.Show("Variable \"" + oVarName + "\" existiert nicht!");
return false;
}
}
public static void runFunction(String oCLFunctionName)
{
OpenCLFunction oCLFunction;
if (OpenCLRunner.oFunctionDict.TryGetValue(oCLFunctionName, out oCLFunction))
{
oCLFunction.run();
}
else
{
MessageBox.Show("Funktion \"" + oCLFunctionName + "\" existiert nicht!");
}
}
public static void runFunction(String oCLFunctionName, OpenCLVariable[] aoCLVars)
{
OpenCLFunction oCLFunction;
if (OpenCLRunner.oFunctionDict.TryGetValue(oCLFunctionName, out oCLFunction))
{
System.Diagnostics.Stopwatch oWatch = new System.Diagnostics.Stopwatch();
oWatch.Start();
oCLFunction.run(aoCLVars);
oWatch.Stop();
oElapsedExecutionTime = oWatch.Elapsed;
}
else
{
MessageBox.Show("Funktion \"" + oCLFunctionName + "\" existiert nicht!");
}
}
}
class OpenCLFunction
{
private CLCalc.Program.Kernel oCLFunction;
private bool bArgsSet = false;
private OpenCLVariable[] aoCLVars;
public OpenCLFunction(string oCLFunctionName)
{
try
{
this.oCLFunction = new CLCalc.Program.Kernel(oCLFunctionName);
}
catch (Exception e)
{
MessageBox.Show("CLCalc-Error:\n===================\n\n" + e.ToString());
}
}
public void run()
{
if(bArgsSet) {
this.run(this.aoCLVars);
} else {
MessageBox.Show("Variablen wurden nicht gesetzt!");
}
}
public void setVars(OpenCLVariable[] aoCLVars) {
this.aoCLVars = aoCLVars;
this.bArgsSet = true;
}
public void run(OpenCLVariable[] aoGpuVars)
{
CLCalc.Program.Variable[] aoCLGpuVars = new CLCalc.Program.Variable[aoGpuVars.Length];
for(int nI = 0; nI < aoGpuVars.Length; nI++) {
aoCLGpuVars[nI] = aoGpuVars[nI].getCLVar();
}
//run on GPU
this.oCLFunction.Execute(aoCLGpuVars, OpenCLRunner.getWorkers());
}
}
class OpenCLVariable
{
private CLCalc.Program.Variable oCLVar;
public CLCalc.Program.Variable getCLVar()
{
return this.oCLVar;
}
public OpenCLVariable(byte[] bInput)
{
this.oCLVar = new CLCalc.Program.Variable(bInput);
}
public OpenCLVariable(char[] cInput)
{
this.oCLVar = new CLCalc.Program.Variable(cInput);
}
public OpenCLVariable(double[] dInput)
{
this.oCLVar = new CLCalc.Program.Variable(dInput);
}
public OpenCLVariable(float[] fInput)
{
this.oCLVar = new CLCalc.Program.Variable(fInput);
}
public OpenCLVariable(int[] nInput)
{
this.oCLVar = new CLCalc.Program.Variable(nInput);
}
public OpenCLVariable(long[] lInput)
{
this.oCLVar = new CLCalc.Program.Variable(lInput);
}
public void set(byte[] bInput)
{
this.oCLVar.WriteToDevice(bInput);
}
public void set(char[] cInput)
{
this.oCLVar.WriteToDevice(cInput);
}
public void set(double[] dInput)
{
this.oCLVar.WriteToDevice(dInput);
}
public void set(float[] fInput)
{
this.oCLVar.WriteToDevice(fInput);
}
public void set(int[] nInput)
{
this.oCLVar.WriteToDevice(nInput);
}
public void set(long[] lInput)
{
this.oCLVar.WriteToDevice(lInput);
}
public void returnData(ref byte[] bVar)
{
this.oCLVar.ReadFromDeviceTo(bVar);
}
public void returnData(ref char[] cVar)
{
this.oCLVar.ReadFromDeviceTo(cVar);
}
public void returnData(ref double[] dVar)
{
this.oCLVar.ReadFromDeviceTo(dVar);
}
public void returnData(ref float[] fVar)
{
this.oCLVar.ReadFromDeviceTo(fVar);
}
public void returnData(ref int[] nVar)
{
this.oCLVar.ReadFromDeviceTo(nVar);
}
public void returnData(ref long[] lVar)
{
this.oCLVar.ReadFromDeviceTo(lVar);
}
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace OpenCLImageFilter
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

View File

@ -0,0 +1,36 @@
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("WindowsFormsApplication1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("WindowsFormsApplication1")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[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("e8c53c6f-4a95-467d-98f8-284f6a222ff2")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace OpenCLImageFilter.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// 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() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[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("OpenCLImageFilter.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace OpenCLImageFilter.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.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;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,6 @@
kernel void
sum(global float16 * x, global float16 * y)
{
int i = get_global_id(0);
x[i] = x[i] + y[i];
}

Binary file not shown.

View File

@ -0,0 +1,143 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>OpenCL.NET</name>
</assembly>
<members>
<member name="T:GASS.OpenCL.OpenGL.OpenCLGLDriver">
<summary>
This class provides the driver interface for OpenGL interoperability
with OpenCL standard.
</summary>
</member>
<member name="T:GASS.OpenCL.OpenCLDriver">
<summary>
This class provides the driver interface to OpenCL functions.
</summary>
</member>
<member name="T:GASS.Types.SizeT">
<summary>
Used to represent a platform dependent sized variable.
On 32 bit platforms it is 4 bytes wide (int, uint), on 64 bit it is
8 bytes wide (long, ulong).
This class maps to the C/C++ native size_t data type.
</summary>
</member>
<member name="M:GASS.Types.SizeT.#ctor(System.Int32)">
<summary>
Creates a new instance based on the given value.
</summary>
<param name="value">Integer value to represent.</param>
</member>
<member name="M:GASS.Types.SizeT.#ctor(System.UInt32)">
<summary>
Creates a new instance based on the given value.
</summary>
<param name="value">Integer value to represent.</param>
</member>
<member name="M:GASS.Types.SizeT.#ctor(System.Int64)">
<summary>
Creates a new instance based on the given value.
</summary>
<param name="value">Integer value to represent.</param>
</member>
<member name="M:GASS.Types.SizeT.#ctor(System.UInt64)">
<summary>
Creates a new instance based on the given value.
</summary>
<param name="value">Integer value to represent.</param>
</member>
<member name="M:GASS.Types.SizeT.op_Implicit(GASS.Types.SizeT)~System.Int32">
<summary>
Converts the object to int.
</summary>
<param name="t">Object to convert.</param>
<returns>Integer value represented by the object.</returns>
</member>
<member name="M:GASS.Types.SizeT.op_Implicit(GASS.Types.SizeT)~System.UInt32">
<summary>
Converts the object to uint.
</summary>
<param name="t">Object to convert.</param>
<returns>Integer value represented by the object.</returns>
</member>
<member name="M:GASS.Types.SizeT.op_Implicit(GASS.Types.SizeT)~System.Int64">
<summary>
Converts the object to long.
</summary>
<param name="t">Object to convert.</param>
<returns>Integer value represented by the object.</returns>
</member>
<member name="M:GASS.Types.SizeT.op_Implicit(GASS.Types.SizeT)~System.UInt64">
<summary>
Converts the object to ulong.
</summary>
<param name="t">Object to convert.</param>
<returns>Integer value represented by the object.</returns>
</member>
<member name="M:GASS.Types.SizeT.op_Implicit(System.Int32)~GASS.Types.SizeT">
<summary>
Converts the given integer to an object.
</summary>
<param name="value">Integer value to convert.</param>
<returns>New object representing this value.</returns>
</member>
<member name="M:GASS.Types.SizeT.op_Implicit(System.UInt32)~GASS.Types.SizeT">
<summary>
Converts the given integer to an object.
</summary>
<param name="value">Integer value to convert.</param>
<returns>New object representing this value.</returns>
</member>
<member name="M:GASS.Types.SizeT.op_Implicit(System.Int64)~GASS.Types.SizeT">
<summary>
Converts the given integer to an object.
</summary>
<param name="value">Integer value to convert.</param>
<returns>New object representing this value.</returns>
</member>
<member name="M:GASS.Types.SizeT.op_Implicit(System.UInt64)~GASS.Types.SizeT">
<summary>
Converts the given integer to an object.
</summary>
<param name="value">Integer value to convert.</param>
<returns>New object representing this value.</returns>
</member>
<member name="M:GASS.Types.SizeT.op_Inequality(GASS.Types.SizeT,GASS.Types.SizeT)">
<summary>
Compares two SizeT objects.
</summary>
<param name="val1">First value to compare.</param>
<param name="val2">Second value to compare.</param>
<returns>true or false for the comparison result.</returns>
</member>
<member name="M:GASS.Types.SizeT.op_Equality(GASS.Types.SizeT,GASS.Types.SizeT)">
<summary>
Compares two SizeT objects.
</summary>
<param name="val1">First value to compare.</param>
<param name="val2">Second value to compare.</param>
<returns>true or false for the comparison result.</returns>
</member>
<member name="M:GASS.Types.SizeT.Equals(System.Object)">
<summary>
Returns a value indicating whether this instance is equal to a specified object.
</summary>
<param name="obj">An object to compare with this instance or null.</param>
<returns>true if obj is an instance of System.IntPtr and equals the value of this instance; otherwise, false.</returns>
</member>
<member name="M:GASS.Types.SizeT.ToString">
<summary>
Converts the numeric value of the current object to its equivalent string representation.
</summary>
<returns>The string representation of the value of this instance.</returns>
</member>
<member name="M:GASS.Types.SizeT.GetHashCode">
<summary>
Returns the hash code for this instance.
</summary>
<returns>A 32-bit signed integer hash code.</returns>
</member>
</members>
</doc>

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,64 @@
uchar4 calcPixel(global uchar4*, int, int, global float*, int);
kernel void
filter(global uchar4* ac4PictureIn, global uchar4* ac4PictureOut, global int* nDim, global float* afMask, global int* nMaskSize)
{
int nXpixel = get_global_id(0);
int nYpixel = get_global_id(1);
int nPos = (nYpixel * nDim[0]) + nXpixel;
*(ac4PictureOut+nPos) = calcPixel(ac4PictureIn, nDim[0], nDim[1], afMask, *nMaskSize);
}
uchar4 calcPixel(global uchar4* ac4PictureIn, int nWidth, int nHeight, global float* afMask, int nMaskSize) {
int nXpixel = get_global_id(0);
int nYpixel = get_global_id(1);
int nDx, nDy;
int nX, nY;
int nDelta = (nMaskSize/2);
int nMaskLength = nMaskSize * nMaskSize;
float4 f4Pixel = {0.0f, 0.0f, 0.0f, 0.0f};
float fMaskSum = 0;
for(int nK = 0; nK < nMaskLength; nK++) {
fMaskSum += afMask[nK];
}
//float fFactor;
for(int nK = 0; nK < nMaskLength; nK++) {
nDx = (nK%nMaskSize) - nDelta;
nDy = (nK/nMaskSize) - nDelta;
nX = nXpixel+nDx;
nY = nYpixel+nDy;
if(nX < 0) nX = 0;
if(nX >= nWidth) nX = nWidth-1;
if(nY < 0) nY = 0;
if(nY >= nHeight) nY = nHeight-1;
// if(nX > -1 && nX < nWidth && nY > -1 && nY < nHeight) { //if mask is not outside the image
f4Pixel += (afMask[nK]/fMaskSum) * convert_float4(ac4PictureIn[(nY * nWidth) + nX]);
// }
}
return convert_uchar4(f4Pixel);
}
kernel void
recycle(global uchar4* ac4PictureIn, global uchar4* ac4PictureOut, global int* nDim)
{
int nXpixel = get_global_id(0);
int nYpixel = get_global_id(1);
int nPos = (nYpixel * nDim[0]) + nXpixel;
// uchar4 c4Temp = ac4PictureIn[nPos];
ac4PictureIn[nPos] = ac4PictureOut[nPos];
// ac4PictureOut[nPos] = c4Temp;
}

View File

@ -0,0 +1,4 @@
3
1, 2, 1
2, 4, 2
1, 2, 1

View File

@ -0,0 +1,6 @@
5
1, 2, 4, 2, 1,
2, 4, 8, 4, 2,
4, 8, 16,8, 4,
2, 4, 8, 4, 2,
1, 2, 4, 2, 1,

View File

@ -0,0 +1,13 @@
3
0,0,0
0,1,0
0,0,0
5
0,0,0,0,0
0,0,0,0,0
0,0,1,0,0
0,0,0,0,0
0,0,0,0,0

View File

@ -0,0 +1,6 @@
5
1, 1, 1, 1, 1,
1, 0, 0, 0, 1,
1, 0, 0, 0, 1,
1, 0, 0, 0, 1,
1, 1, 1, 1, 1,