I want to use wolfram mathematica functions in C#. I read that this is real. I made C# progect and added references to my progect. Then I write button binarize where I want to use wolfram functions. How Can I do this? I tryed to do this but there is an error IKernelLink kl = MathLinkFactory.CreateKernelLink(); Also I need to write something like this in C#. Can anybody help me? Thank you
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; using Wolfram.NETLink;
namespace ImageBinarization { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
}
List<Image> listImage = new List<Image>();
private void ???????ToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "Image files (*.jpg, *.bmp, *.png)|*.jpg; *.bmp; *.png ";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
openFileDialog1.Multiselect = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
if (( openFileDialog1.OpenFile()) != null)
{
listImage.Clear();
// Insert code to read the stream here.
foreach (string str in openFileDialog1.FileNames)
{
listImage.Add(Image.FromFile(str));
}
if (listImage.Count > 0)
{
pictureOriginal.Image = listImage[0];
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
pictureOriginal.SizeMode = PictureBoxSizeMode.Zoom;//???? ????????? ?????? ??????????
pictureOriginal.SizeMode = PictureBoxSizeMode.StretchImage;//????????(?????) ???????? ?? ???? ??????????
pictureResult.SizeMode = PictureBoxSizeMode.Zoom;//???? ????????? ?????? ??????????
pictureResult.SizeMode = PictureBoxSizeMode.StretchImage;//????????(?????) ???????? ?? ???? ??????????
}
private void buttonBinarisation_Click(object sender, EventArgs e)
{
IKernelLink kl = MathLinkFactory.CreateKernelLink();//ERROR!!!!!
kl.Close();
}
}
}
Attachments: