Search code examples
arraysimagemultidimensional-arrayimread

MATLAB - save image in structure array array{i,y} and retrieve with (image(i,y))?


My system:

Windows 8.1
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


Solution

  • stiAll{i,y} = imread(fileNameStr); looks like a cellArray. And you try to plot it image(stiAll(i,y)) now as Matrix. Try image(stiAll{i,y})