matlab - 看起来 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 处理我的拜耳编码图像?
解决方案
解决此问题的方法是使用 imageDatastore 'ReadFcn' 参数。imageDatastore 的文档明确告诉您不要这样做,因为它会减慢神经网络的速度。这是 Matlab 文档文本:
不建议使用 ReadFcn 转换或预处理 2-D 图像。对于 imformats 识别的文件格式,指定 ReadFcn 会降低 imageDatastore 的性能。有关转换和预处理图像的更有效方法,请参阅 Preprocess Images for Deep Learning(深度学习工具箱)。
所以,说了这么多,这里是解决方法:
imgStore = imageDatastore(cellArrayOfImageFilenames ...
, 'ReadFcn', @(x)demosaic(imread(x),'rggb')));
推荐阅读
- javascript - React 组件道具比我的验证功能落后一步
- python - 提取href链接
- c# - 我们可以控制休假事件吗?
- java - 为什么 foo(double d, Object...) 和 foo(Object...) 在 Java 中不明确,而 foo(Double d, Object...) 和 foo(Object...) 不明确?
- hibernate - 使用 GORM 和 Grails 未保持多对多关系
- php - 未找到 PHPunit 名称空间类
- asp.net-core-2.0 - asp.net core 2 异常未显示问题所在
- angular - 如何延迟启动 Angular 应用程序以显示动画
- build - 如何在 Visual Studio Tem Services 中构建多阶段部署?
- python - Python3如何以一定的精度向上(向下)舍入