plot3d of jpeg file contains a triangle(2D) and data of triangle in z-axis

1 view (last 30 days)
I have a jpeg file contains a triangle in a rectangle and a set of data corresponding to the points of that triangle. How to plot3d of that jpeg on xy plane and data in z-axis?
[Merged from duplicate]
I have a jpeg file contains a triangle in a rectangle and a set of data corresponding to the points of that triangle. How to plot3d of that jpeg on xy plane and data in z-axis? I tried surf() which plot y-axis as z

Answers (1)

Image Analyst
Image Analyst on 24 Mar 2013
Edited: Image Analyst on 25 Mar 2013
Have you tried the surf() function? If it's a color image, then you can only plot one of the color channels as a height. You'd need 3 surfaces to plot the three different color channels each as a surface, like in this demo:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures if you have the Image Processing Toolbox.
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
% Read in a standard MATLAB color demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'onion.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);
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows columns numberOfColorBands] = size(rgbImage);
% Display the original color image.
subplot(2, 2, 1);
imshow(rgbImage);
title('Original Color Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Plot each color channel as a surface:
subplot(2,2,2);
surf(double(redChannel));
title('Red Channel', 'FontSize', fontSize);
subplot(2,2,3);
surf(double(greenChannel));
title('Green Channel', 'FontSize', fontSize);
subplot(2,2,4);
surf(double(blueChannel));
title('Blue Channel', 'FontSize', fontSize);

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!