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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Change matrix internal data type

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
seamus.holden Posted - 08/07/2006 : 07:29:11 AM
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
9   L A T E S T    R E P L I E S    (Newest First)
seamus.holden Posted - 08/07/2006 : 11:43:42 AM
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
seamus.holden Posted - 08/07/2006 : 11:22:57 AM
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
Mike Buess Posted - 08/07/2006 : 10:45:20 AM
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
easwar Posted - 08/07/2006 : 10:41:29 AM
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

seamus.holden Posted - 08/07/2006 : 10:13:07 AM
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
Mike Buess Posted - 08/07/2006 : 09:05:26 AM
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
seamus.holden Posted - 08/07/2006 : 08:56:30 AM
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 :(
seamus.holden Posted - 08/07/2006 : 08:47:20 AM
Thanks, that worked like a charm.

Seamus Holden
Mike Buess Posted - 08/07/2006 : 08:31:30 AM
Hi Seamus,

This works...

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

Mike Buess
Origin WebRing Member

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000