为什么在matlab中发生get_full_filename错误?

时间:2017-11-19 03:45:49

标签: image matlab path save

我想要读取特定文件夹中的所有图像并将其保存为64 * 64尺寸的jpg图像。

但是错误发生了,我不知道为什么要做什么。 请求帮助我

错误代码:

File "Nikon_D70_0_19458.tif" doesn't exist

Error: imread (line 340) fullname = get_full_filename(filename);

Error: Untitled (line 13) dList(i).data = imread(dList(i).name);

我的代码:

clc; clear; close all; 
imgPath = 'C:\Users\LG\Desktop\TIFF\dataset1\60\'; %open image path

dList = dir([imgPath '*.tif']); name = 1; %save name index

for i=1:length(dList) %open image dList(i).data = imread(dList(i).name);
    dList(i).data = dList(i).data(1:256 ,1:256,:); %crop image 256*256
    a = dList(i).data;
    YCbCr = rgb2ycbcr(a);
    Y = YCbCr(:,:,1);
    Cb = YCbCr(:,:,2);
    Cr = YCbCr(:,:,3);
    [height,width] = size(Y);
    for q=1:32:height-32
        for w= 1:32:width-32
            block = Y(q:q+63 , w:w+63);
                Resultados='C:\Users\LG\Desktop\TIFF\training\60'; %save image path
                imwrite(block, fullfile(Resultados, ['SerieN', num2str(i), '.jpg']),'Quality',60) % save image
                name = name+1;
         end
     end
end

1 个答案:

答案 0 :(得分:1)

字段dList(i).name不包含完整路径,只包含文件名。您可以使用fullfile获取完整路径:

dList(i).data = imread(fullfile(imgPath, dList(i).name));