matlab程序转java,将MATLAB代码转换为Java代码

I need to call this MATLAB code from Java code. The code clusters an image according to the specified number of clusters and the specified initial cluster centers (i.e. [176;137] in this code).

nrows = size(a_image,1);

ncols = size(a_image,2);

double_a_2_image = double(reshape(a_image,nrows*ncols,1));

nColors = 2;

[cluster_idx_2_a cluster_center] =

kmeans(double_a_2_image,nColors,'distance','sqEuclidean','start',repmat([176;137],

[1,1,3]));

a_pixel_labels_2 = reshape(cluster_idx_2_a,nrows,ncols);

figure('Name','a* image labeled by cluster index: 2 colors'),imshow(a_pixel_labels_2,

[]);

What is the best tool to convert this code into jar file (or maybe .class file)? Another point: I need to run the resulted jar file on a machine that do not have matlab installed. Is that possible or should I install MATLAB Compiler Runtime (MCR) on this machine?

解决方案

A simple search on google gives you this link : MATLAB Builder JA, which generate a Java wrapper around your MATLAB code. And for your second question, you won't need it, as the wrapper is taking care of the MATLAB code itself.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值