【问题标题】:Why get_full_filename error happens in matlab?为什么在matlab中发生get_full_filename错误?
【发布时间】:2017-11-19 03:45:48
【问题描述】:

我想读取特定文件夹中的所有图像并将其保存为 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

【问题讨论】:

    标签: image matlab path save


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2017-07-20
      • 2017-02-11
      • 2020-07-17
      • 2015-09-29
      • 1970-01-01
      • 2023-02-06
      • 2016-03-18
      • 2019-02-21
      • 1970-01-01
      相关资源
      最近更新 更多