python - 在 Python 中运行 MATLAB 脚本
问题描述
我正在寻找一种在不使用 MATLAB 的情况下在 python 文件中执行 MATLAB 代码的方法。这是我的 MATLAB 代码:
count = 0
for image_name in os.listdir(directory_segmentation):
if count < n_displays:
segmented_image = cv2.imread(directory_segmentation + "/" + image_name)
segmented = Image.open(directory_segmentation + "/" + image_name)
original = Image.open(directory_originals + "/" + image_name)
font = ImageFont.truetype(font_path, font_size)
d1 = ImageDraw.Draw(segmented)
masked = self.create_mask_plaque(segmented_image, color_plaque)
maxlevel = 3
**v = self.waveletdescr(masked, maxlevel)**
print(v)
count += 1
它在 ** ** 之间的函数是在 MATLAB 中编码的。所以我需要给它一些参数并取回一个向量。可能吗?谢谢!!PD。MATLAB 脚本的结构如下所示:
function v = waveletdescr(im,maxlevel) ;
im = rgb2gray(im)
im = double(im);
[m,n] = size(im);
npix = m*n;
....
v = zeros( 3*maxlevel+1, 1 ); % the descriptors
end
v(end) = sum(sum( im.^2 )) / npix;
function imf = filterh(im,l)
d = size(im(end-1:-1:end-l,:))
imf = 0.5*[im; im(end-1:-1:end-l,:)];
imf = imf(1:end-l,:) + imf(l+1:end,:);
function imf = filterg(im,l)
imf = 0.5*[im; im(end-1:-1:end-l,:)];
imf = imf(l+1:end,:) - imf(1:end-l,:);
解决方案
推荐阅读
- cytoscape - 将 javascript JSON 字符串传递给本地安装的 Cytoscape 软件
- ansible - 清单文件的 Ansible Host_vars 和组
- sql - 跳过 SQL Server 中当前日期的月份
- c# - 将数据从 DB 添加到 DataGridViewComboBoxColumn,每行具有不同的值
- c# - 修改组合框以返回 NULL 值
- vba - 将草稿保存到特定的“草稿”子文件夹
- html - 对多个类使用相同的 CSS :not() 语句
- java - 是否可以在不使用文件/Blob 存储服务的情况下在 Azure 中部署具有文件上传功能的 Web 应用程序?文件将保存在哪里
- node.js - Node.js 使用与分配不同的侦听端口
- angular - 如何将子组件的 formGroup 传递给父组件