Clear Filters
Clear Filters

3d plot of an image

51 views (last 30 days)
Mahua Nandy(Pal)
Mahua Nandy(Pal) on 19 Sep 2012
how can i get 3d plot of an image

Answers (4)

Image Analyst
Image Analyst on 24 Sep 2012

Image Analyst
Image Analyst on 19 Sep 2012
Perhaps you mean surf() or waterfall(), or you could mean scatter3(). Did you look up the 3D visualization section in the help?
  1 Comment
Mahua Nandy(Pal)
Mahua Nandy(Pal) on 24 Sep 2012
please give me 3-4 line example piece of code how to see 3d visualization of an image using surf()

Sign in to comment.


Image Analyst
Image Analyst on 24 Sep 2012
surf(double(yourImage));
More complete demo:
clc;
clearvars;
close all;
imtool close all; % Close all imtool figures.
workspace;
format longg;
format compact;
fontSize = 16;
% Read in a standard MATLAB gray scale demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'cameraman.tif';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% File doesn't exist -- 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 in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage = imread(fullFileName);
% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows columns numberOfColorBands] = size(grayImage);
% Display the original gray scale image.
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Give a name to the title bar.
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
subplot(2,2,2);
surf(double(grayImage));
  1 Comment
Mahua Nandy(Pal)
Mahua Nandy(Pal) on 25 Sep 2012
Warning: Matrix dimensions must agree, not rendering mesh Warning: Matrix dimensions must agree, not rendering mesh Warning: Matrix dimensions must agree, not rendering mesh Warning: Matrix dimensions must agree, not rendering mesh
why these are coming with a .jpg gray image? with cameraman.tif it is ok.

Sign in to comment.


Sean de Wolski
Sean de Wolski on 24 Sep 2012

Community Treasure Hunt

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

Start Hunting!