<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ejs &#187; MatLAB</title>
	<atom:link href="http://ejs.seniejitrakai.net/category/blogroll/my-little-pleasures/programming/matlab/feed/" rel="self" type="application/rss+xml" />
	<link>http://ejs.seniejitrakai.net</link>
	<description>a snaphot of time</description>
	<lastBuildDate>Mon, 09 Jan 2012 22:10:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>OpenOffice.org, x64 and .NET interface</title>
		<link>http://ejs.seniejitrakai.net/2011/01/23/openoffice-org-x64-and-net-interface/</link>
		<comments>http://ejs.seniejitrakai.net/2011/01/23/openoffice-org-x64-and-net-interface/#comments</comments>
		<pubDate>Sun, 23 Jan 2011 17:28:42 +0000</pubDate>
		<dc:creator>ejs</dc:creator>
				<category><![CDATA[MatLAB]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[LibreOffice]]></category>
		<category><![CDATA[OpenOffice]]></category>

		<guid isPermaLink="false">http://ejs.seniejitrakai.net/?p=194</guid>
		<description><![CDATA[Here,&#8217;s the story short: I need to create a series of graph for highly scientific data sets. The data is calculated in MatLAB, but the export of figures in MatLAB is a pain for me. On the other hand OpenOffice.org seems to be the right tool for the job. The latest MatLAB has the function, [...]]]></description>
			<content:encoded><![CDATA[<p>Here,&#8217;s the story short:</p>
<p>I need to create a series of graph for highly scientific data sets. The data is calculated in MatLAB, but the export of figures in MatLAB is a pain for me.</p>
<p>On the other hand OpenOffice.org seems to be the right tool for the job. The latest MatLAB has the function, called &#8216;xlswrite&#8217;. Happy with the fact, hoping it should write the XLS file I fire it up and&#8230;</p>
<p>Ouch. One must have Excell installed, as the data export goes through the ActiveX. If no Excell is found, the data is exported into CSV file, overwriting the file every time. Not the Right Thing.<span id="more-194"></span></p>
<p>The job was done via ordinary &#8216;csvwrite&#8217;, but adding data, importing the file to OpenOffice.org Calc and producing a series of graph.</p>
<p>And the milestone is creating &#8216;odswrite&#8217;, implementing the same functionality as &#8216;xlswrite&#8217; presents. As MatLAB supports .NET and OpenOffice.org can be controlled via .NET-UNO bridge, .NET implementation of the function seems to be the easiest task.</p>
<p>The first problem found is it&#8217;s impossible to load &#8216;cli_cpputype&#8217; NET assembly on x64 systems. I&#8217;m not sure if it is because &#8216;cli_cpputype&#8217; is compiled for .NET 2.0, but the problem is too seriuos.</p>
<p>A <a href="http://ejs.seniejitrakai.net/njufsams/OpenOfficeTestApp.exe">small .NET program</a>, based on<a href="http://www.suite101.com/content/creating-an-openoffice-writer-document-with-c-a123686">Creating an OpenOffice Writer Document with C#</a> and<a href="http://www.suite101.com/content/creating-an-openoffice-calc-document-with-c-a124112"> Creating an OpenOffice Calc Document with C# </a>was created. In the case of success, it writes 2 files to user&#8217;s desktop:  &#8220;OpenOfficeTestFile.odt&#8221; for Writer and &#8220;OpenOfficeTestFile.ods&#8221; for Calc.</p>
<p>Here&#8217;s the source for C#. Sorry fot the mess, it&#8217;s my first .NET and C# programm ever compiled <img src='http://ejs.seniejitrakai.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<pre>using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

// OOorg assemblies
using unoidl.com.sun.star.lang; 
using unoidl.com.sun.star.uno; 
using unoidl.com.sun.star.bridge; 
using unoidl.com.sun.star.frame;
using unoidl.com.sun.star.text;
using unoidl.com.sun.star.beans;
using unoidl.com.sun.star.sheet;
using unoidl.com.sun.star.container;
using unoidl.com.sun.star.table;

namespace OONETTest
{
 class OpenOfficeTestApp 
 {
 //Define a file name. Change this to an existing path! 
private static string FileName      = @"OpenOfficeTestFile";  

 static void Main(string[] args)
 {
 string fDesktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
 string fFileName = fDesktop + "\\" + FileName;

//Call the bootstrap method to get a new ComponentContext 
 //object. If OpenOffice isn't already started this will 
 //start it and then return the ComponentContext.  

 unoidl.com.sun.star.uno.XComponentContext localContext =  uno.util.Bootstrap.bootstrap(); 

 //Get a new service manager of the MultiServiceFactory type 
 //we need this to get a desktop object and create new CLI 
 //objects.  

 unoidl.com.sun.star.lang.XMultiServiceFactory multiServiceFactory =  (unoidl.com.sun.star.lang.XMultiServiceFactory) localContext.getServiceManager(); 

 //Create a new Desktop instance using our service manager 
 //Notice: We cast our desktop object to XComponent loader 
 //so that we could load or create new documents.  

 XComponentLoader componentLoader = (XComponentLoader) multiServiceFactory.createInstance("com.sun.star.frame.Desktop" ); 

 //Create a new blank writer document using our component 
 //loader object. 
 XComponent oDoc = componentLoader.loadComponentFromURL( "private:factory/swriter",  //a blank writer document 
 "_blank", 0,       //into a blank frame use no searchflag 
 //use no additional arguments. 
 new unoidl.com.sun.star.beans.PropertyValue[0] 
 ); 

 //Cast our component to a the XText interface 
//and write some simple text into document.  

 ((unoidl.com.sun.star.text.XTextDocument)oDoc).getText().setString("Testing OpenOffice.org .NET interface"); 

 //After we insert our text, we cast our component to XStorable 
 //to save it onto the harddisk  

 ((XStorable)oDoc).storeToURL( //Convert the file path into a OpenOffice path 
 PathConverter(fFileName + ".odt"),
 new unoidl.com.sun.star.beans.PropertyValue[0]);            //no additional arguments  

 // close the Writer
 oDoc.dispose();

 // according to
 //http://www.suite101.com/content/creating-an-openoffice-calc-document-with-c-a124112

 //Create a new blank writer document using our component 
 //loader object. 
 XComponent oCalc = componentLoader.loadComponentFromURL("private:factory/scalc",  //a blank Calc document 
 "_blank", 0,       //into a blank frame use no searchflag 
 //use no additional arguments. 
 new unoidl.com.sun.star.beans.PropertyValue[0]
 );

 // get sheets
 XSpreadsheets oSheets = ((XSpreadsheetDocument)oCalc).getSheets();
 XIndexAccess oSheetsIA = (XIndexAccess) oSheets;
 // access sheet by index
 XSpreadsheet oSheet = (XSpreadsheet) oSheetsIA.getByIndex(0).Value;</pre>
<pre>//write some data:
//Each cell in a Calc sheet is indexed by its column and row, so that text (for example) is written to cell A1 by using:

 XCell oCell = oSheet.getCellByPosition( 0, 0 ); //A1
 ((XText)oCell).setString("Testing OpenOffice.org .NET interface");</pre>
<pre>oCell = oSheet.getCellByPosition( 0, 1 ); //A2
 ((XText)oCell).setString("Cost");

 //And a number can be written to B1 by using:
 oCell = oSheet.getCellByPosition( 1, 1 ); //B2
 oCell.setValue(200);

 //And the "setFormula" methods is, of course, used to enter formulae (in this example into B3):

 oCell = oSheet.getCellByPosition( 1, 2 ); //B3
 oCell.setFormula("=B2 * 1.175");

 //After we insert our text, we cast our component to XStorable 
 //to save it onto the harddisk  

 ((XStorable)oCalc).storeToURL( //Convert the file path into a OpenOffice path 
 PathConverter(fFileName + ".ods"),
 new unoidl.com.sun.star.beans.PropertyValue[0]);            //no additional arguments  

 // close Calc
 oCalc.dispose();

 MessageBox.Show("OpenOffice document '" + fFileName + ".odt' saved, \n" + "OpenOffice document '" + fFileName + ".ods' saved", "OpenOffice .NET Test App");

 } 

 /// 
 /// Convert file path  into OO file format 
 /// 
 ///

 private static string PathConverter( string file) 
 {
 try 
 {
 file = file.Replace(@"\", "/");
 return "file:///"+file; 
 }
 catch (System.Exception ex) 
 {
 throw ex; 
 }
 }
 }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://ejs.seniejitrakai.net/2011/01/23/openoffice-org-x64-and-net-interface/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Colorization</title>
		<link>http://ejs.seniejitrakai.net/2005/10/19/colorization/</link>
		<comments>http://ejs.seniejitrakai.net/2005/10/19/colorization/#comments</comments>
		<pubDate>Wed, 19 Oct 2005 18:57:50 +0000</pubDate>
		<dc:creator>ejs</dc:creator>
				<category><![CDATA[MatLAB]]></category>

		<guid isPermaLink="false">http://ejs.seniejitrakai.net/?p=10</guid>
		<description><![CDATA[505510 Quite interesting article on image processing. The MatLAB source, presented on the site, need some minor enhancments. Authors may contact me, if they want . Attention: the program is really slow. I used &#8216;direct solver&#8217;, and it took almost 10 minutes to proceed the image.]]></description>
			<content:encoded><![CDATA[<div class="g2image_float_right"><wpg2id>505</wpg2id><wpg2id>510</wpg2id></div>
<p>Quite interesting <a href="http://www.cs.huji.ac.il/~yweiss/Colorization/">article</a> on image processing. The MatLAB source, presented on the site, need some minor enhancments. Authors may contact me, if they want <img src='http://ejs.seniejitrakai.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .<br />
<strong>Attention:</strong> the program is really slow. I used &#8216;direct solver&#8217;, and it took almost 10 minutes to proceed the image.</p>
]]></content:encoded>
			<wfw:commentRss>http://ejs.seniejitrakai.net/2005/10/19/colorization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JPEG-2000 in MatLAB</title>
		<link>http://ejs.seniejitrakai.net/2005/04/16/jpeg-2000-in-matlab/</link>
		<comments>http://ejs.seniejitrakai.net/2005/04/16/jpeg-2000-in-matlab/#comments</comments>
		<pubDate>Fri, 15 Apr 2005 22:07:45 +0000</pubDate>
		<dc:creator>ejs</dc:creator>
				<category><![CDATA[Hobbies]]></category>
		<category><![CDATA[MatLAB]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ejs.seniejitrakai.net/?p=4</guid>
		<description><![CDATA[Any idea how to produce and read the <a href="http://www.jpeg.org/jpeg2000/">JP2</a> file in MatLAB?]]></description>
			<content:encoded><![CDATA[<p>Any idea how to produce and read the <a href="http://www.jpeg.org/jpeg2000/">JP2</a> file in MatLAB?<br />
The easiest way should be writing middleware in Java to specific library. The things are complicated, as i need to get and modify data from every stage of encoding/decoding, like color space transformations, quantization, EBCOT (including bit-plane decomposition, bit-plane processing, encoding) and rate-encoders.<span id="more-4"></span></p>
<ul>
<li>There is <a href="http://www.ece.uvic.ca/~mdadams/jasper/">JasPer</a>, written in C. Not all functions of Jpeg-2000 basic specification is implemented now;</li>
<li><a href="http://jj2000.epfl.ch/">Jj2000</a>, written in Java; only basic functionality is provided;</li>
<li><a href="http://www.kakadusoftware.com/welcome.html">Kakadu</a>, written in C++ and has JNI bindings. Almost perfect inplementation of the Jpeg2000 image compression standart; data-on-demand, progressive transmision, even video encoding/decoding is supported.</li>
</ul>
<p>As i tried to reproduce kdu_encoder in Java, no image is appearing in the output file, while original C++ file works well.</p>
<p>Need more timeto research.</p>
]]></content:encoded>
			<wfw:commentRss>http://ejs.seniejitrakai.net/2005/04/16/jpeg-2000-in-matlab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

