【发布时间】:2014-12-08 19:10:15
【问题描述】:
我需要将代码从 Matlab 移植到 C++。但是,我对语法有很多困惑,谷歌搜索对我没有帮助。
以下是读取图像文件的代码sn-p。请解释一下 [height width] 和 VolData(:, :, i) 在 C++ 术语中的用途和方式。
%% read images
clc
clear all
cd ('..\STLBP_Matlab\test\'); % please replace "..." by your images path
a = dir('*.jpg'); % directory of images, ".jpg" can be changed, for example, ".bmp" if you use
for i = 1 : length(a)
ImgName = getfield(a, {i}, 'name');
Imgdat = imread(ImgName);
if size(Imgdat, 3) == 3 % if color images, convert it to gray
Imgdat = rgb2gray(Imgdat);
end
[height width] = size(Imgdat);
if i == 1
VolData = zeros(height, width, length(a));
end
VolData(:, :, i) = Imgdat;
end
cd ..
非常感谢您。
【问题讨论】:
标签: c++ image matlab matrix porting