简体   繁体   English

Matlab imageset方法读取顺序和图像名称?

[英]Matlab imageset method order of read and name of image?

%% Load images from folder

% Use imageSet to manage images stored in multiple folders
imset = imageSet('pet_images','recursive');
% Preallocate arrays with fixed size for prediction
imageSize = cnnModel.net.normalization.imageSize;
trainingImages = zeros([imageSize sum([imset(:).Count])],'single');

% Load and resize images for prediction
for ii = 1:numel(imset)
    for jj = 1:imset(ii).Count
        imshow(read(imset(ii),jj)); 
        trainingImages(:,:,:,jj) = imresize(single(read(imset(ii),jj)),imageSize(1:2));

    end
end

I want to read images from a directory. 我想从目录中读取图像。 But it gives me error some images. 但这给了我一些图像错误。

Assignment has fewer non-singleton rhs dimensions than non-singleton subscripts
  • I use breakpoint to find which image has a problem. 我使用断点来查找哪个图像有问题。 When it gives error, I catch the index of the image and show this image. 当它给出错误时,我捕获图像的索引并显示该图像。

  • I find this image from this directory. 我从该目录中找到该图像。 it's order is 1061 (orders according to name) but value of jj is 1012. 它的顺序为1061(根据名称顺序),但jj的值为1012。

I have three Question. 我有三个问题。

  1. Why it gives this error? 为什么会出现此错误? (The resolution of (error) image : (263x380)) ((错误)图像的分辨率:(263x380))
  2. In order to find the image, I check with the image and same type cats. 为了找到图像,我检查了图像和相同类型的猫。 In for loop, Can I got the name of this image.? 在for循环中,我可以获取此图像的名称吗?
  3. While imageset read the directory, what according to read it (name,type,date, etc...)? imageset读取目录时,根据其读取内容(名称,类型,日期等)的方式是什么? Why the row number (1061) and index(1012) are mismatches? 为什么行号(1061)和索引(1012)不匹配?
  1. if the image is grayscale, it gives error. 如果图像是灰度图像,则会产生错误。
    Because rgb image is expected by trainingImages array. 因为训练图像需要rgb图像。
  2. getting the name of image, you can use code below; 获取图片名称,可以使用下面的代码;

     imshow(read(imset(ii),jj)); a = select(imset(ii),jj); str = cellstr(a(1,1).ImageLocation); title(str); 
  3. Because imageset orders alphabetically but different way(name) For example. 因为imageset按字母顺序排序,但是方式(名称)不同。

    • Directory order : img1, img2, img3,... img9, img10, img11... img20, ... 目录顺序:img1,img2,img3,... img9,img10,img11 ... img20,...
    • imageSet read order: img1, img2, img3,... img9, img10, img20... img21, ... imageSet读取顺序:img1,img2,img3,... img9,img10,img20 ... img21,...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM