【问题标题】:save sequence of images in a folder using matlab使用matlab将图像序列保存在文件夹中
【发布时间】:2015-07-10 16:42:13
【问题描述】:

我想将图像保存到文件夹中。我尝试了下面给出的代码

      [Ilabel num] = bwlabel(If);
disp(num);
Iprops = regionprops(Ilabel);
Ibox = [Iprops.BoundingBox];
Ibox = reshape(Ibox,[4 83]);
 figure,imshow(Ibox);

 for n=1:num
        [r,c] = find(Ilabel==n);
        % Extract letter
        n1=Iout(min(r):max(r),min(c):max(c));  
        % Resize letter (same size of template)
        img_r=imresize(n1,[42 24]);
        %figure,imshow(n1);
        %Uncomment line below to see letters one by one
         %imshow(img_r);pause(0.5)
 imwrite(img_r,['H:\\mainproject\\codes\\images\\test0.jpg' ]);
 end   

但只有最后一个字母保存在文件夹中。我不知道它在哪里出错。我尝试了很多但我没有得到它。请帮助我并提前感谢

【问题讨论】:

    标签: matlab


    【解决方案1】:

    我认为您可能正在覆盖图像,因为您使用的是相同的名称test0.jpg。试试:

    [Ilabel num] = bwlabel(If);
    disp(num);
    Iprops = regionprops(Ilabel);
    Ibox = [Iprops.BoundingBox];
    Ibox = reshape(Ibox,[4 83]);
    figure,imshow(Ibox);
    
     for n=1:num
            [r,c] = find(Ilabel==n);
            % Extract letter
            n1=Iout(min(r):max(r),min(c):max(c));  
            % Resize letter (same size of template)
            img_r=imresize(n1,[42 24]);
            %figure,imshow(n1);
            %Uncomment line below to see letters one by one
            %imshow(img_r);pause(0.5)
            image_name = strcat('H:\\mainproject\\codes\\images\\test', num2str(n), '.jpg');
            imwrite(img_r,[image_name]);
     end
    

    我现在实际上无法测试,也无法发表评论(低于 50 分)。希望对你有帮助,

    【讨论】:

      猜你喜欢
      • 2013-06-23
      • 2015-12-21
      • 1970-01-01
      • 1970-01-01
      • 2021-08-12
      • 2019-09-21
      • 1970-01-01
      • 2016-01-20
      • 1970-01-01
      相关资源
      最近更新 更多