![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/731749/image.png)
Want to plot the surf where x-y axis represent pixel coordinate and z axis its intensity. Separate plot for both the bowls and then compare the two plot or find corelation.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Apra Gupta
le 7 Sep 2021
Modifié(e) : Image Analyst
le 7 Sep 2021
To the above image I applied foreground and background masking and got the second image. To this masked image I want apply above mentioned steps.
0 commentaires
Réponse acceptée
Image Analyst
le 7 Sep 2021
Modifié(e) : Image Analyst
le 7 Sep 2021
I don't know what good this will do but here is how to make a surf plot with the RGB image as coloring and the height of the surface proportional to the gray level:
% Demo to create a surface from a gray scale image and have the coloration of the surface taken from a different RGB image.
clc; % Clear the command window.
clear all;
close all;
workspace; % Make sure the workspace panel is showing.
format short g;
format compact;
fontSize = 15;
fprintf('Beginning to run %s.m ...\n', mfilename);
%===============================================================================
% Get the name of the demo image the user wants to use.
% Get the base filename.
baseFileName = 'Image @ 27min masked.png';
% Get the full filename, with path prepended.
fullFileName = fullfile(pwd, baseFileName);
% img = imread('pears.png');
rgbImage = imread(fullFileName);
[rows, colummns, numberOfColorChannels] = size(rgbImage)
subplot(2, 2, 1);
imshow(rgbImage);
axis('on', 'image');
impixelinfo; % Let user mouse around and get RGB or gray levels.
caption = sprintf('Original Image : %s', baseFileName);
title(caption, 'FontSize', fontSize);
% Crop image.
rgbImage = rgbImage(72:200, 75:300, :);
% Make gray scale value image.
grayImage = rgb2gray(rgbImage);
subplot(2, 2, 3);
imshow(grayImage, []);
axis('on', 'image');
impixelinfo; % Let user mouse around and get RGB or gray levels.
title('Gray Scale Image', 'FontSize', fontSize);
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
% Apply the RGB image as a texture to the surface.
subplot(2, 2, [2,4]);
surf(grayImage, ...
'FaceColor', 'texturemap',...
'EdgeColor', 'none',...
'Cdata', rgbImage);
view(3);
axis ij;
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
zlabel('Z', 'FontSize', fontSize);
if numberOfColorChannels == 1
colorbar;
end
title('Image with "Original" Image Applied as a "texturemap"', 'FontSize', fontSize);
g = gcf;
g.WindowState = 'maximized'
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/731749/image.png)
0 commentaires
Plus de réponses (0)
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!