Uploading picture and creating colormap

1 view (last 30 days)
I've been having problems with uploading a picture and opening it. In trying I=imread('picturename') it gives Error using imread (line 349) File "Picture1Edit" does not exist.Though it does show in the sidebar. I do get a series of numbers when the picture is opened?
Then the next problem is that a colormap is needed. How do I create one?
Thank you for your help.

Accepted Answer

Image Analyst
Image Analyst on 4 Jan 2014
To upload an image, click on the green image icon above the text box here, or click the paperclip icon.
It won't say Picture1Edit does not exist if you say imread('picturename') though it might say picturename does not exist. Create a full filename and use that, for example:
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'peppers.png';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
% Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
What "sidebar" are you talking about? How can you get a series of numbers when the picture is opened when you just said you can not open it? Can you open it or not? Where does that series of numbers appear? In the command window? In the variable editor?
To create a colormap, you can use a built-in one just as jet or winter:
myColorMap = jet(256);
colormap(myColorMap);
colorbar;
or build a custom one with, say, 256 rows and 3 columns in the range 0-1
myColorMap = rand(256, 3); % However you want to design it.
colormap(myColorMap);
colorbar;
  1 Comment
Theo Kooijman
Theo Kooijman on 7 Jan 2014
Thank you for your anwer, it was very helpful! I managed to import the picture into the program and create a colormap . However, I cannot figure out how to get a colormap of the picture, the colormapwindow that popped up was blank. By "sidebar" I meant the "workspace" and "current folder" window right and left of my command window. By the way, what might be important to know, is that I'm using the staff version of Matlab at the moment, I don't know if that makes a difference with the student version? Thank you so much for your help!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!