フィルターのクリア

[SOLVED] Save image in cell array ARRAY{i,y} and access them with image(ARRAY{i,y})?

2 ビュー (過去 30 日間)
John Kau
John Kau 2015 年 7 月 5 日
編集済み: John Kau 2015 年 7 月 5 日
Hi there!
My system:
Windows 8.1 and MATLAB2015a
My issue: When I save a JPG image in a structure array, in this case stiAll{i,y}
fileName = strcat('group_',strGr,'_',strVal,'.jpg');
fileNameStr = char(fileName);
stiAll{i,y} = imread(fileNameStr);
and I try to retrieve the saved image with image(stiAll(i,y)) I get the following error message from MATLAB:
Invalid datatype for Image CData. Numeric or logical matrix required for image CData.
If I save the image without the {i,y} suffix, so that the image is saved in a normal variable, not in a structure array, I can retrieve the image. However, for my programme I would need to save images in the respective cells of a structure array or something similar.
Any idea how to get this done successfully?
Thanks J

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 5 日
image(stiAll{1,1})

その他の回答 (1 件)

Image Analyst
Image Analyst 2015 年 7 月 5 日
If you're using braces, you're saying that the variable is a cell array. See http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F
A structure is not a cell and a structure array is not a cell array. So don't use braces.
baseFileName = sprintf('group_%s_%s.jpg', strGr, strVal);
fullFileName = fullfile(pwd, baseFileName);
if exist(fullFileName, 'file)
% File exists. Add to structure.
stiAll(i,y) = imread(fullFileName);
else
% File does not exist
message = sprintf('File does not exist:\n%s', fullFileName);
uiwait(warndlg(message));
end

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by