Try using imshow() instead of subimage() (whatever that is):
clear
[X1, map1] = imread('C:\Users\SONY\Downloads\abcd.jpg');
[X2, map2] = imread('C:\Users\SONY\Downloads\abcd.jpg');
subplot(1, 2, 1);
imshow(X1, map1)
subplot(1, 2, 2);
imshow(X2, map2)
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
set(gcf, 'Name', 'My Images', 'NumberTitle', 'Off')
You should really make it more robust by checking if the filenames exist first, with the exist(filename, 'file') function, before trying to call imread() and then warn the user if they don't exist:
filename = 'C:\Users\SONY\Downloads\abcd.jpg';
if exist(filename, 'file')
[X1, map1] = imread('C:\Users\SONY\Downloads\abcd.jpg');
subplot(1, 2, 1);
imshow(X1, map1)
else
warningMessage = sprintf('Warning: the image file does not exist:\n%s', filename);
uiwait(warndlg(filename));
end
Best Answer