- iplab_src.zip
- iplab_src
- icons
- about.gif
- clone.gif
- convolution.gif
- copy.gif
- cut.gif
- disk.gif
- fit_to_size.gif
- folder_out.gif
- fourier.gif
- grayscale.gif
- histogram_window.gif
- levels.gif
- morphology.gif
- paste.gif
- pie-chart.gif
- resize.gif
- rotate.gif
- threshold.gif
- view_1_1.gif
- zoom_in.gif
- zoom_out.gif
- iplab
- iplab_demo.zip
- iplab_demo
- AForge.dll
- AForge.Imaging.chm
- AForge.Imaging.dll
- AForge.Math.dll
- DockingToolbar.dll
- iplab.exe
- SourceGrid2.dll
- SourceLibrary.dll
- WeifenLuo.WinFormsUI.dll
|
// Image Processing Lab
//
// Copyright � Andrew Kirillov, 2005
// andrew.kirillov@gmail.com
//
namespace IPLab
{
using System;
using System.IO;
/// <summary>
/// Serialize2DimArray class - 2 dimensional arrays serialization
/// </summary>
internal class Serialize2DimArray
{
// Save array to file
public static void Save( string file, Array array )
{
StreamWriter writer = null;
try
{
int height = array.GetLength( 0 );
int width = array.GetLength( 1 );
// create file
writer = File.CreateText( file );
// write array dimensions
writer.WriteLine( "{0} {1}", height, width );
for ( int i = 0; i < height; i++ )
{
string[] strs = new string[width];
for ( int j = 0; j < width; j++ )
{
strs[j] = array.GetValue( i, j ).ToString( );
}
writer.WriteLine( string.Join( " ", strs ) );
}
}
catch ( Exception )
{
throw new ApplicationException( );
}
finally
{
// close file
if ( writer != null )
writer.Close( );
}
}
// Load array from file
public static Array Load( string file, Type type )
{
StreamReader reader = null;
Array array;
try
{
string[] strs;
int height;
int width;
// open file
reader = File.OpenText( file );
// read dimensions
strs = reader.ReadLine( ).Split( ' ' );
height = int.Parse( strs[0] );
width = int.Parse( strs[1] );
// create array of specified type
array = Array.CreateInstance( type, height, width );
for ( int i = 0; i < height; i++ )
{
// read next line
strs = reader.ReadLine( ).Split( ' ' );
for ( int j = 0; j < width; j++ )
{
array.SetValue( Convert.ChangeType( strs[j], type ), i, j );
}
}
}
catch ( Exception )
{
throw new ApplicationException( );
}
finally
{
// close file
if ( reader != null )
reader.Close( );
}
return array;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Started software development at about 15 years old and it seems like now it lasts most part of my life. Fortunately did not spend too much time with Z80 and BK0010 and switched to 8086 and further. Similar with programming languages – luckily managed to get away from BASIC and Pascal to things like Assembler, C, C++ and then C#. Apart from daily programming for food, do it also for hobby, where mostly enjoy areas like Computer Vision, Robotics and AI. This led to some open source stuff like
AForge.NET,
Computer Vision Sandbox,
cam2web,
ANNT, etc.