The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Change matrix internal data type
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

seamus.holden

UK
Posts

Posted - 08/07/2006 :  07:29:11 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.0
Operating System: XP Pro

I have been writing programs to automate some image analysis I need to do. This is just a minor problem but it it a bit annoying.

When I import an image for analysis, the matrix defaults to integer data type and the only way I can find to convert it to double (as required for the analysis programs) is manually, rather than using my C routine or a LabTalk script.

I cant seem to get the "matrix.CastToDouble(matrix1)" command to work in C, and if I use LabTalk (off topic sorry) "set %c -it 0" it deletes the data from the matrix.

Any ideas?

Thanks
Seamus Holden

Mike Buess

USA
3037 Posts

Posted - 08/07/2006 :  08:31:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Seamus,

This works...

MatrixLayer mlay = Project.ActiveLayer();
if( mlay )
mlay.SetInternalData(FSI_DOUBLE);

Mike Buess
Origin WebRing Member
Go to Top of Page

seamus.holden

UK
Posts

Posted - 08/07/2006 :  08:47:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks, that worked like a charm.

Seamus Holden
Go to Top of Page

seamus.holden

UK
Posts

Posted - 08/07/2006 :  08:56:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Actually, I may have been a bit hasty. It looked as if it ran on first go but now it appears that this is not the case. I get a unknown runtime error after the .SetInternalData command executes :(
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 08/07/2006 :  09:05:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I get no error in 7.0 SR4. Perhaps you should apply the SR4 patch.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 08/07/2006 09:51:37 AM
Go to Top of Page

seamus.holden

UK
Posts

Posted - 08/07/2006 :  10:13:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
just checked im actually on 7.5 SR6, not 7.0, apologies.

The input matrix is a 1024x1024 matrix, data is unsigned ints approimately 10E4.8.

This is the relevant bit of code, after which the program terminates with "unknown" runtime error:

// Assumes Matrix1 is active window in Origin
int ii, jj;
double value;
Matrix<double> image; // Declare Matrix object
MatrixLayer ml; // Declare MatrixLayer object
ml = (MatrixLayer) Project.ActiveLayer(); // Get active MatrixLayer from Project object
if ( ml )
ml.SetInternalData(FSI_DOUBLE);

image.Attach(ml); // Attach object to Matrix1

Thanks
Seamus Holden
Go to Top of Page

easwar

USA
1965 Posts

Posted - 08/07/2006 :  10:41:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Seamus,

Tried with a 2000x2000 matrix in 7.5SR6 and could not reproduce the problem - with your code could switch fine to double and manipulate the data.

Is there a system resources problem at your end? Can you try with a much smaller image, or just make a matrix say 100x100 and set it to int(4) and then try your code?

Easwar
OriginLab

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 08/07/2006 :  10:45:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I still get no runtime error with that snippet of code. This is how I tested in 7.5 SR6...

1. Create matrix with New Matrix button.
2. Matrix > Set Dimensions: 1024 cols x 1024 rows.
3. Matrix > Set Values: Cell(i,j) = i*j.
4. Matrix > Set Properties: int(4), unsigned.
5. Run this function from script window...

void run_mtest()
{
int ii, jj;
double value;
Matrix<double> image; // Declare Matrix object
MatrixLayer ml; // Declare MatrixLayer object
ml = (MatrixLayer) Project.ActiveLayer(); // Get active MatrixLayer from Project object
if ( ml )
ml.SetInternalData(FSI_DOUBLE);
image.Attach(ml); // Attach object to Matrix1
}

Result: internal data type changed to double with no runtime error.

Mike Buess
Origin WebRing Member
Go to Top of Page

seamus.holden

UK
Posts

Posted - 08/07/2006 :  11:22:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Very strange.

When I first implemented the code, I got "unknown runtime error".
After restarting Origin (which I should have tried, to be honest), my code also now runs ok. Not sure the cause of the difference, but it works now.

Thanks for the help

Seamus Holden
Go to Top of Page

seamus.holden

UK
Posts

Posted - 08/07/2006 :  11:43:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Very strange.

When I first implemented the code, I got "unknown runtime error".
After restarting Origin (which I should have tried, to be honest), my code also now runs ok. Not sure the cause of the difference, but it works now.

Thanks for the help

Seamus Holden
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000