I have written an application in Matlab and compiled it into Java code using the JA builder. I'm really stuck from here as to how to integrate it into my application. How do I handle data type conversion, call the functions, etc. The algorithm that I wrote in Matlab is for image processing, how can I pass a java buffered image to that function?

0 |

1/26/2011 2:22:03 PM

"Rebecca" wrote in message <ihpamb$acv$1@fred.mathworks.com>... > I have written an application in Matlab and compiled it into Java code using the JA builder. I'm really stuck from here as to how to integrate it into my application. How do I handle data type conversion, call the functions, etc. > > The algorithm that I wrote in Matlab is for image processing, how can I pass a java buffered image to that function? There are all sorts of direct interfaces possible but the easiest and safest approach is to simply write the BufferedImage to file in some standard format, then read this file in Matlab. For a more direct approach read http://www.mathworks.com/support/solutions/en/data/1-2WPAYR/index.html An equivalent but much faster variant of the above, courtesy of Jan Simon: pixelsData = reshape(typecast(jImage.getData.getDataStorage, 'uint8'), 4, w, h); imgData = cat(3, ... transpose(reshape(pixelsData(3, :, :), w, h)), ... transpose(reshape(pixelsData(2, :, :), w, h)), ... transpose(reshape(pixelsData(1, :, :), w, h))); Yair Altman http://UndocumentedMatlab.com

0 |

1/27/2011 12:56:03 AM