why this code is not working?

1 次查看(过去 30 天)
i have code which is perfectly working fine with cameraman.tif but with other images its not ..what is wrong in the code?
[X,Y,Z] = peaks(200);
I = double(imread('cameraman.tif'));
figure;
mesh(X, Y, Z, I);
colormap jet;
above one is working fine
but this one not .i have to generate surf and mesh images kindly suggest what is wrong
clc
close all
clear all
% a=VideoReader('C:\Users\tce21\Downloads\test.mp4'); % Read a video
% b = read(a,1); % Read 1st frame
% c=rgb2gray(b);
% [X,Y,Z] = peaks(200); % surface
I = double(c);
figure;
mesh(X, Y, Z, I); % overlay image as texture
colormap jet;
image s attached
i want same output as cameraman but with mesh grid lines with the figure attached
as 1st images.
help is really appreciated
  4 个评论
Image Analyst
Image Analyst 2018-4-19
This:
[X,Y,Z] = peaks(200);
I = double(imread('cameraman.tif'));
figure;
mesh(X, Y, Z, I);
colormap jet;
does not work fine. It generates error
Warning: Error creating or updating Surface
Error in value of property CData
Array is wrong shape or size
At that point, I quit working on this question.
KSSV
KSSV 2018-4-19
Yes....true Image Analyst. There were two or three questions on how to mesh a image by the user which were not closed by the user so far.

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2018-4-19

Try this:

rgbImage = imread('1st images.bmp');
subplot(1, 2, 1);
imshow(rgbImage);
% Get the dimensions of the image.  
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(rgbImage);
if numberOfColorChannels > 1
	% It's not really gray scale like we expected - it's color.
	% Use weighted sum of ALL channels to create a gray scale image.
	rgbImage = rgb2gray(rgbImage); 
	% ALTERNATE METHOD: Convert it to gray scale by taking only the green channel,
	% which in a typical snapshot will be the least noisy channel.
	% grayImage = grayImage(:, :, 2); % Take green channel.
end
% Make white surround black.
rgbImage(rgbImage == 255) = 0;
[X, Y] = meshgrid(1:columns, 1:rows);
dblImage = double(rgbImage); 
Z = dblImage;
subplot(1, 2, 2);
mesh(X, Y, Z, dblImage); % overlay image as texture
colormap jet;
fontSize = 20;
xlabel('X, column', 'FontSize', fontSize);
ylabel('Y, Row', 'FontSize', fontSize);
zlabel('Intensity', 'FontSize', fontSize);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by