永发信息网

关于MATLAB的翻译求助

答案:2  悬赏:50  手机版
解决时间 2021-02-07 22:50
  • 提问者网友:兔牙战士
  • 2021-02-07 06:30
Copyright 1993-2002 The MathWorks, Inc.
% $Revision: 1.10 $ $Date: 2002/03/15 15:27:47 $

% Algorithm reference: P. Soille, Morphological Image Analysis:
% Principles and Applications, Springer, 1999, pp. 164-165.

% Input-output specs
% ------------------
% IM: N-D, real, full matrix
% any numeric or logical nonsparse type
% if islogical(IM), treated as binary
% empty ok
% Infs ok
% if logical, NaNs are ok and treated as 0s, otherwise
% not allowed.
%
% CONN: connectivity
%
% IM2: Same class and size as IM

[im,conn] = parse_inputs(varargin{:});
conn = conn2array(conn);

marker = im;

% Now figure out which elements of the marker image are connected to the
% outside, according to the connectivity definition.
im2 = true(size(marker));
im2 = padarray(im2, ones(1,ndims(im2)), 0, 'both');
im2 = imerode(im2,conn);
idx = cell(1,ndims(im2));
for k = 1:ndims(im2)
idx{k} = 2:(size(im2,k) - 1);
end
im2 = im2(idx{:});

% Set all elements of the marker image that are not connected to the
% outside to the lowest possible value.
if islogical(marker)
marker(im2) = false;
else
marker(im2) = -Inf;
end

im2 = imreconstruct(marker, im, conn);
if islogical(im2)
im2 = im & ~im2;
else
im2 = imsubtract(im,im2);
end

%%%
%%% parse_inputs
%%%
function [im,conn] = parse_inputs(varargin)

checknargin(1,2,nargin,mfilename);

im = varargin{1};
checkinput(im, {'numeric' 'logical'}, {'nonsparse' 'real'}, ...
mfilename, 'IM', 1);

if nargin < 2
conn = conndef(ndims(im),'maximal');
else
conn = varargin{2};
checkconn(conn,mfilename,'CONN',2);
end

% Skip NaN check here; it will be done by imreconstruct if input
% is double.

今天中午就要交的试卷,交不了,就悲剧了啊·
麻烦大大们帮帮忙啊!
最佳答案
  • 五星知识达人网友:十年萤火照君眠
  • 2021-02-07 06:49
Copyright 1993-2002 The MathWorks, Inc.
美国迈斯沃克公司 1993-2002 版权所有。
% $Revision: 1.10 $ $Date: 2002/03/15 15:27:47 $
版本 1.10 日期:2002/03/15 15:27:47
% Algorithm reference: P. Soille, Morphological Image Analysis:
算法参考:P. Soille 形态学图像分析
% Principles and Applications, Springer, 1999, pp. 164-165.
原理与应用原书名 Springer, 1999, pp. 164-165.
% Input-output specs
输入输出 规则
% ------------------
% IM: N-D, real, full matrix
N-D实数全矩阵
% any numeric or logical nonsparse type
任何数字的 或者逻辑非系数 类型
% if islogical(IM), treated as binary
若是逻辑数则为真,以二进制对待。
% empty ok
空集 确定
% Infs ok
Infs确定
% if logical, NaNs are ok and treated as 0s, otherwise
如果合乎逻辑的,通知书是确定并视为0 ,否则
% not allowed.
% ,不允许。
%
% CONN: connectivity
连接器 连通
%
% IM2: Same class and size as IM
IM2 :同一等级,与IM相同的规模
[im,conn] = parse_inputs(varargin{:});
赋值
conn = conn2array(conn); 赋值
marker = im;
标记:im;
% Now figure out which elements of the marker image are connected to the

% outside, according to the connectivity definition.
现在,根据连接定义,指出标记图像的哪个单元 连接外部,
im2 = true(size(marker)); 赋值
im2 = padarray(im2, ones(1,ndims(im2)), 0, 'both'); 赋值
im2 = imerode(im2,conn); 赋值
idx = cell(1,ndims(im2)); 赋值
for k = 1:ndims(im2) 循环
idx{k} = 2:(size(im2,k) - 1);
end
im2 = im2(idx{:});

% Set all elements of the marker image that are not connected to the
% outside to the lowest possible value.
将标记图像 中所有 未连接到外部的 单元 设置为 可行的最小值

if islogical(marker) 如果为真
marker(im2) = false;
else
marker(im2) = -Inf;
end

im2 = imreconstruct(marker, im, conn);
if islogical(im2)
im2 = im & ~im2;
else
im2 = imsubtract(im,im2);
end

%%%
%%% parse_inputs
%%%
function [im,conn] = parse_inputs(varargin)

checknargin(1,2,nargin,mfilename);

im = varargin{1};
checkinput(im, {'numeric' 'logical'}, {'nonsparse' 'real'}, ...
mfilename, 'IM', 1);

if nargin < 2
conn = conndef(ndims(im),'maximal');
else
conn = varargin{2};
checkconn(conn,mfilename,'CONN',2);
end

% Skip NaN check here; it will be done by imreconstruct if input
这里跳过NaN检查 如果是双输入,则imreconstruct 函数可以解决。
% is double.
全部回答
  • 1楼网友:深街酒徒
  • 2021-02-07 07:02
其实你就是想在vc++环境里用y这个变量,在前边声明一个变量,比如double a 在最后赋值a=y.r(1,1),就是把y数组的第一行第一列的数赋值给a,同理也可以定义一个数组变量 float b[]=; 在最后加入 for(int i = 0; i< 3; i++) { b[i] = y.r(1,i); cout<
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯