开发者

Image from Java GUI to MATLAB

I have a problem with transferring the image (RGB data) I get from Java GUI (for which I have the source code) to a MATLAB array. Can this be done?

I don't know where to start since I'm not very familiar with Java programming. Any help would be appreciated. I'm a Ph.D. student and I n开发者_运维知识库eed to solve this for my future research.


Since you are in Java there are a few things that can happen here.

1) Use the MATLAB Builder JA. This will allow you to create a Java layer that allows you to marshal data from within Java into the MATLAB runtime. Note that this option has other requirements that I talk about here

2) You can write out the image in Java into one of the image formats that MATLAB understands and then load it using the aforementioned imread

3) And this is a dubious solution, but will work. Write out the image as a matrix in CSV format. You can then load that into MATLAB and it will convert the CSV into a multidimensional matrix which is more or less the representation of the image

Basically it breaks down into writing out the image data in some format that MATLAB understands or write an interop layer.


Well, if you haven't got any better ideas, use a screen grabber (Alt+PrntScreen on Windows, whatever on Linux) and paste the grab into MS Paint or GIMP. Then save in your favourite image file format and bob's your uncle.

Or, am I as usual, missing some incredible complication ?

If that's too simple, modify the Java to write the image to a file -- you say you have the source. You could even have Matlab call the Java to do that, then retrieve the image directly.


One of the outstanding capabilities of MATLAB is its Java scripting capability. As you can download CmuCam2 sources, you just instantiate the Java classes you need and call the required methods as they were MATLAB built-in functions.

Have a look at "Bringing Java Classes and Methods into MATLAB Workspace" of The MathWorks documentation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜