首页 > 解决方案 > 看起来 imageLabeler 无法处理转换后的数据存储?

问题描述

Matlab 应用程序imageLabeler应该支持以下格式:

imageLabeler(imgStore)

我有一个imgStore,定义如下:

imds = imageDatastore(cellArrayOfImageFilenames);
imgStore = transform(imds, @(x)demosaic(x,'rggb'));

我必须这样做,因为我的图像存储为拜耳编码图像,这是我想出让 imgStore 将这些图像作为 3 通道 RGB 图像返回的唯一方法。但是,当我尝试初始化 imageLabeler 时,我收到此错误:

>> imageLabeler(imgStore)
Error using imageLabelerInternal
Expected input name to be one of these types:

char

Instead its type was matlab.io.datastore.TransformedDatastore.

Error in vision.internal.imageLabeler.imageLabelerInternal

Error in imageLabeler (line 58)
vision.internal.imageLabeler.imageLabelerInternal(varargin{:});

TLDR:如何让 imageLabeler 处理我的拜耳编码图像?

标签: matlabimage-processing

解决方案


解决此问题的方法是使用 imageDatastore 'ReadFcn' 参数。imageDatastore 的文档明确告诉您不要这样做,因为它会减慢神经网络的速度。这是 Matlab 文档文本:

不建议使用 ReadFcn 转换或预处理 2-D 图像。对于 imformats 识别的文件格式,指定 ReadFcn 会降低 imageDatastore 的性能。有关转换和预处理图像的更有效方法,请参阅 Preprocess Images for Deep Learning(深度学习工具箱)。

所以,说了这么多,这里是解决方法:

imgStore = imageDatastore(cellArrayOfImageFilenames ...
            , 'ReadFcn', @(x)demosaic(imread(x),'rggb')));

推荐阅读