Uploading picture and creating colormap
1 view (last 30 days)
Show older comments
Theo Kooijman
on 4 Jan 2014
Commented: Theo Kooijman
on 7 Jan 2014
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.
0 Comments
Accepted Answer
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;
More Answers (0)
See Also
Categories
Find more on Red in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!