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
 open bitmap (.bmp)

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
hydrix Posted - 10/31/2008 : 03:48:30 AM
hello,
how can i open a .bmp file pixel by pixel in an origin matrix?
best would be the color code as an integer or binary.
thanks for your help...
hydrix
10   L A T E S T    R E P L I E S    (Newest First)
hydrix Posted - 11/11/2008 : 11:21:46 AM
Thank you!
Works!
Hydrix
eparent Posted - 11/07/2008 : 3:15:02 PM
quote:
Originally posted by hydrix

hey eric,
all right, "import_image_to_matrix_data"
is now compiling. in the function MyTest that is listed below you have to replace "strImagePath" by "strFileName" else the example is not working.

MyTest then works well with no parameters (it then puts the data of the sample image "Car.bmp" into the matrix "MBook1")
however i have problems to execute

MyTest(MyMatrixName,C:\Data\MyBitmap.bmp)

from the Labtalk window.

where is my mistake?

and: by which additional code in MyTest could i access single matrix entries?

thanks in advance

hydrix



Hello,

Your syntax looks correct. Is your first argument a book name or a sheet name. The MyTest function is expecting a book name for the first argument. Not a sheet name. You can also use the following syntax to call an Origin C function from LabTalk:

MyTest MyMatrixName C:\Data\MyBitmap.bmp

Notice the arguments are separated with a space.

Also, since you are now using 8.0 you can also call X-Functions from LabTalk. The following shows how to call the X-Function for importing an image into a specified sheet of a specified book.

impImage C:\Data\MyBitmap.bmp orng:=[MBook1]MSheet1;


Access to the matrix values can be done using the Origin C Matrix class. This class has a GetCellValue member function. Another way is to assign the Matrix instance to a pointer as shown below:

int index = 0;
Matrix<WORD> mm("MBook1"); // matrix with 16-bit data
if( mm.IsValid() )
{
	WORD* pw = (WORD*)mm;
	printf("%d\n", pw[index]);
}


I hope this helps.

Thanks,
Eric
hydrix Posted - 11/07/2008 : 11:42:35 AM
hey eric,
all right, "import_image_to_matrix_data"
is now compiling. in the function MyTest that is listed below you have to replace "strImagePath" by "strFileName" else the example is not working.

MyTest then works well with no parameters (it then puts the data of the sample image "Car.bmp" into the matrix "MBook1")
however i have problems to execute

MyTest(MyMatrixName,C:\Data\MyBitmap.bmp)

from the Labtalk window.

where is my mistake?

and: by which additional code in MyTest could i access single matrix entries?

thanks in advance

hydrix
eparent Posted - 11/07/2008 : 09:39:36 AM
quote:
Originally posted by hydrix

hi eric,
i have problems finding the oimg_image_info funktion.
could you please specify where i can find it?
thanks!
hydrix



Sorry, I forgot to say that the oimg functions are delcared in import_image.h. I have updated the wiki page.

Add the following to the top of your c/cpp file:
#include <import_image.h>


Thanks,
Eric
hydrix Posted - 11/07/2008 : 02:43:33 AM
hi eric,
i have problems finding the oimg_image_info funktion.
could you please specify where i can find it?
thanks!
hydrix
eparent Posted - 11/06/2008 : 2:11:23 PM
quote:
Originally posted by hydrix
void import_image_matrix(string strMatrixName, string strImagePath)
{
string strCMD;
strCMD.Format("image.fileName$ = %s;", strImagePath);
LT_execute(strCMD);

strCMD.Format("image.import.matrix(%s);", strMatrixName);
LT_execute(strCMD);
Matrix matA;
matA.Attach("Matrix2");
double dMean;
dMean = matA.GetMean(); // Use matrixbase::GetMean function
printf("Mean of Matrix2: %g\n", dMean ); // Print out mean

}
i get the error: "Calling members of unattached wrapper class".
How can i attach the imported matrix to the matrix in the code correctly?
and i have one further question.
how can i display the matrix not as an image but as a matrix of numbers. (the color code as an integer, binary or hex)?
thanks a lot.
by the way: i am using origin 8 now, so i have acces to the x-functions.

hydrix



Hello,

I have created the following wiki page to provide examples of how to import an image into a matrix and access the matrix data afterwards.

http://ocwiki.originlab.com/index.php?title=OriginC:Image_Import#Import_a_BMP_File

Let me know if you have any questions regarding the code on this wiki page.

Thanks,
Eric
hydrix Posted - 11/05/2008 : 01:01:43 AM
hi deanna,
thanks the import works well. however, to the code

void import_image_matrix(string strMatrixName, string strImagePath)
{
string strCMD;
strCMD.Format("image.fileName$ = %s;", strImagePath);
LT_execute(strCMD);

strCMD.Format("image.import.matrix(%s);", strMatrixName);
LT_execute(strCMD);
Matrix matA;
matA.Attach("Matrix2");
double dMean;
dMean = matA.GetMean(); // Use matrixbase::GetMean function
printf("Mean of Matrix2: %g\n", dMean ); // Print out mean

}
i get the error: "Calling members of unattached wrapper class".
How can i attach the imported matrix to the matrix in the code correctly?
and i have one further question.
how can i display the matrix not as an image but as a matrix of numbers. (the color code as an integer, binary or hex)?
thanks a lot.
by the way: i am using origin 8 now, so i have acces to the x-functions.

hydrix
Deanna Posted - 11/03/2008 : 8:56:07 PM
Hi Hydrix,

You can try the following function:


void import_image_into_matrix(string strMatrixName, string strImagePath)
{
	string strCMD;
	strCMD.Format("image.fileName$ = %s;", strImagePath);
	LT_execute(strCMD);
	
	strCMD.Format("image.import.matrix(%s);", strMatrixName);
	LT_execute(strCMD);
	
}


This should work in both Origin 7.5 and Origin 8.0. After compiling the function, you can use it. Suppose you have a matrix named "matrix2" and the file you wished to import is "c:\test\car.bmp". Execute the following LabTalk script in the Script Window:
import_image_into_matrix("Matrix2", "c:\test\car.bmp");



Deanna
OriginLab Technical Services
hydrix Posted - 11/01/2008 : 06:53:51 AM
hi deanna,

at the moment i am using 7.5 but in a few weeks i will have the new version 8.0. as i'd like to start my programming project now i would prefer the code for the older version. however i would be glad if you could send me the code for the 8.0 version too.
thank you very much.

hydrix
Deanna Posted - 10/31/2008 : 9:39:48 PM
Hi, would you please tell us the version of Origin you are using?

If you are using Origin 8, which provides the impImage X-Function, it is easy to import an image file into a matrix because you can call that X-Function in your Origin C code. Of course, the importing can be done in other versions, too. But the code may be different. So please tell us the version of Origin you are using before we can help you.

Deanna
OriginLab Technical Services

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