Info

This question is closed. Reopen it to edit or answer.

How to solve error for Non-cell array object.?

1 view (last 30 days)
Nimisha
Nimisha on 17 Oct 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
I have one matrix " 1350x1800x3 double " value named ret When i run im_desat = ret{1}; it shows error
Cell contents reference from a non-cell array object.
Error in main (line 37)
im_desat = ret{1};
How to overcome it.? With this value i have to further proceed with following program.!
im_desat = ret{1};
desat_map = ret{2};
subplot(2,2,3); imshow(desat_map); title('desaturation map');
subplot(2,2,4); imshow(im_desat); title('desaturated image');
print(f, '-dpdf', [fname '_desat.pdf']);
%%object segmentation
f = figure(3); subplot(2,2,1); imshow(im); title('original');
subplot(2,2,2); imshow(res); title('saliency map');
binary_saliency_map = res>graythresh(res);
map_segmented = segmentation(res)
subplot(2,2,3); imshow(binary_saliency_map); title('binary saliency map');
subplot(2,2,4); imshow(map_segmented); title('segmented');
print(f, '-dpdf', [fname '_seg.pdf']);
%%fake 3D
im = uint8(im_desat * 255);
background = im.*repmat((1- uint8(map_segmented)), [1 1 3]);
foreground= im.*repmat((uint8(map_segmented)), [1 1 3]);
%%shift the background
shift = 2;
background(:,1:end-shift,:) = background(:,shift +1:end,:);
map_segmented_shifted = map_segmented;
map_segmented_shifted(:,1:end-shift) = map_segmented_shifted(:,shift +1:end);
map_diff = map_segmented_shifted & ~ map_segmented;
map_diff_rgb = repmat(map_diff, [1 1 3]);
background(map_diff_rgb) = im(map_diff_rgb);
subplot(2,2,1); imshow(map_diff);
figure(4); subplot(2,2,3); imshow(background);
map_diff_i = ~map_segmented_shifted & map_segmented;
map_diff_rgb_i = repmat(map_diff_i, [1 1 3]);
background(map_diff_rgb_i) = 0;
result = background + foreground;
subplot(2,2,4); imshow(result);
%%play video
%{
figure(5);
for i = 1:1
imshow(im);
%pause(.2);
%imshow(result);
%pause(.2);
end
%}
figure(17);
filename = [fname '_3D.gif'];
imshow(im); drawnow;
[imind,cm] = rgb2ind(frame2im(getframe(17)),256);
imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
imshow(result); drawnow;
[imind,cm] = rgb2ind(frame2im(getframe(17)),256);
imwrite(imind,cm,filename,'gif','WriteMode','append');
disp('gif saved');

Answers (1)

Adam
Adam on 17 Oct 2014
Edited: Adam on 17 Oct 2014
Your matrix is of type double.
{ } is for accessing a cell of a cell array which yours isn't.
if you want the whole dataset then just
im_desat = ret;
will do.

Community Treasure Hunt

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

Start Hunting!