【问题标题】:How to send binary image data to self organizing map如何将二进制图像数据发送到自组织地图
【发布时间】:2013-04-12 09:33:16
【问题描述】:

我拍摄了一张带有字符的扫描图像,裁剪了字符并将它们存储在矩阵中。

X={}; 
Y={};
for cnt = 1:50
    rectangle('position',box(:,cnt),'edgecolor','r');
    X{cnt}=imcrop(I, box(:,cnt));
    Y{cnt}=im2bw(X{cnt});
 end

这里,box 有矩形的坐标。我想使用 Y 作为newsom 的输入来创建一个自组织地图。但我得到了错误:

net=newsom(Y', [10,1])
???使用 ==> 猫时出错
CAT 参数维度不一致。

==> 89 处的 cell2mat 中的错误
m{n} = cat(1,c{:,n});

==>newsom>new_6p0 在 72 时出现错误
如果 isa(p,'cell'), p = cell2mat(p);结束

==> newsom 在 58 时出错
net = new_6p0(varargin{:});

形成的图像具有不同的尺寸(12x6、15x12 等)。 谁能告诉我如何纠正我的方法,以便newsom 获取 50 个二进制图像的数据?

【问题讨论】:

  • 我不熟悉newsom,所以确定这是否会影响算法的输出,但您可以对所有图像进行零填充,使它们与集合。

标签: matlab image-processing neural-network som


【解决方案1】:

为了使用newsom,您需要所有输入具有相同的大小。您可以使用imresize

来实现
n = 50;
sz = [20 20]; this would be the size of ALL inputs
X = cell(1,n); % pre-allocate outputs, this is good practice
Y = cell(1,n);
for cnt = 1:50
    rectangle('position',box(:,cnt),'edgecolor','r');
    X{cnt}=imcrop(I, box(:,cnt));
    newSize = imresize( X{cnt}, sz, 'bicubic' ); % resize to the predefined size
    Y{cnt}=im2bw(newSize); % do binarization AFTER resizing!
end

【讨论】:

  • 谢谢,我试过这个并摆脱了那个问题。但是,有一个新问题:>> net=newsom(Y,[10,1]) ???在 76 处使用 ==> newsom>new_6p0 时出错输入不是矩阵或具有单个矩阵的元胞数组。 ==> newsom 在 58 处出现错误 net = new_6p0(varargin{:});我尝试了 cell2mat,但这也不是解决方案。
  • @YashUpadhyay - 我很抱歉,但我对 SOM 不太熟悉。尝试将您的二进制图像转换为双精度图像(如果它们是合乎逻辑的)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-07-10
  • 2023-04-05
  • 1970-01-01
  • 1970-01-01
  • 2019-12-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多