Matlab批量处理图像思路

%% Matlab批处理图像框架
%————————————————————————————————–
% 此m文件是批量处理图像的框架
% 2009.10.12 shine
shuchong1987@sina.com
%————————————————————————————————–

%% 命令集

t = cd(‘xxxxx’); % dos命令cd重置当前路径,自行设置,其下包含全部待处理文件

allnames = struct2cell(dir);%dos命令dir列出所有的文件,用struct2cell转换为元胞数组

[m,n] = size(allnames);

for i= 3:n

name = allnames{1,i} %逐次取出文件名

filename = [t,’\’,name]%组成文件名

I = imread(filename);%本人测试了一下,imread要比importdata效率高一些

//Do your own work

end

Posted in Others | Leave a comment

vb.net access数据库,常用的连接数据库和记录集操作的方法

vb.net中是不是一般都不用adodb连接和操作记录集了呀?

那现在最好的方法是什么呢?有方便效率又高的方法是什么呢?

我看到很多都用 OleDbConnection连接数据库,然后用 OleDbDataAdapter把记录集

把数据复付到dataset里,还有更好的方法吗?最常用,效率最高的是什么呢?

是的,用oledb

毕竟ADO.NET和ADO在设计的思路上存在本质的差异,适应了就好用了.

单从效率和速度考虑,应该使用OleDbDataReader

通过 OleDbCommand.ExecuteReader() 方法获得 DataReader 对象。

因为DataReader对象是ReadOnly,ForwardOnly的。

一次只从数据库取一条记录,对于数据量比较大的操作可以考虑使用DataReader

但是DataReader操作不如DataTable方便。

oledb对access数据库进行操作:

Dim objConn As New OleDb.OleDbConnection

Dim objComm As New OleDb.OleDbCommand

Dim objda As New OleDb.OleDbDataAdapter

Dim objds As New DataSet

objConn.ConnectionString = “provider=microsoft.jet.oledb.4.0;user;password=;data source=d:\1.mdb”

字串4

objComm.CommandText = “select * from 产品”

objComm.Connection = objConn

objda.SelectCommand = objComm

objConn.Open()

objda.Fill(objds)

objConn.Close()

DataGridView1.DataSource = objds.Tables(0)

ComboBox1.DataSource = objds.Tables(0)

ComboBox1.DisplayMember = objds.Tables(0).Columns(1).ToString

Label1.Text = objds.Tables(0).Columns(1).ColumnName

可以考虑将楼上提供的方法封装到一个类里面, 另外对combobox也可以用datareader读取数据到一个arraylist中并将该arraylist设为其数据源

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

VB.Net链接Access的方法2007-10-26 15:47′——————VB.Net链接Access方法—————————————-

‘      Dim objConn As New OleDbConnection()

‘      objConn.ConnectionString = “Provider=Microsoft.Jet.OLEDB.4.0; Data source=” + Application.StartupPath() + “\PDDAWEB.mdb”

‘      objConn.Open()

‘      Dim objCmd As New OleDbDataAdapter(“select * from pddawebtest”, objConn.ConnectionString)

‘      Dim ds As New DataSet()

‘      objCmd.Fill(ds, “pddaweb”)

‘      objConn.Close()

‘      Dim myTable As DataTable = ds.Tables(“pddaweb”)

‘      myTable.Rows(0)(“name”) = “gantian”

‘      Dim myRow As DataRow = myTable.NewRow()

‘      myRow(“name”) = “yitahutu”

‘      myRow(“age”) = “30”

‘      myTable.Rows.Add(myRow)

‘      Dim objCB As OleDbCommandBuilder = New OleDbCommandBuilder(objCmd)

‘      objCmd.Update(ds, “pddaweb”)

‘      Console.WriteLine(“that is ok.”)

‘      Console.ReadLine()

Application.StartupPath()是指当前程序的目录,这个是System.Windows.Form里有的一个变量。

\PDDAWEB.mdb是具体的Access文件名称,还有前面需要一个”\”

select * from pddawebtestSQL语句,这里用的是导出表信息。

pddaweb指的是填充用的表名,

蓝色部分起到的作用是回滚,只有回滚了,数据表才能更新。

Posted in Others | Leave a comment

Read individual variables in CFX

If need to read the such individual variables in CFX as current timestep, current loop and so on, the subroutines  ‘USER_GET_TRANS_INF’ and ‘PEEKI/PEEKR’ are used. (Not ‘USER_GETVAR’).

When use PEEKI/PEEKR/PEEKL/PEEKD to get the variables, user should note that which function is used depends on the type of variable. Also user should make sure to claim the correct type of variable in CFX subroutine.

There is an example in CFX help and user can refer to it for using it in correct way.

Posted in Others | Leave a comment

利用matlab求图片的灰度并利用灰度值绘图

一、求图片的灰度值:

I=imread(‘sample.jpg’); !读取图片的RGB值

J=rgb2gray(I);!转换为灰度值

二、利用灰度值绘制图片:

imshow(J)

三、绘制等高线

contour(J)

contourf(J) 颜色填充

Posted in Others | Leave a comment