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 次查看(过去 30 天)
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.

采纳的回答

Image Analyst
Image Analyst 2021-9-7
编辑:Image Analyst 2021-9-7
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'

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by