What dose these errors mean? any help.
4 次查看(过去 30 天)
显示 更早的评论
Yesterday, I worked with all these codes and it work immediately, but today all the codes give me same errors.
I tried different images and codes but still the same errors.
Any one can help me PLZ.
My MATLAB:Student R2013a
I = imread('eight.tif');
EDU>> imshow(I);
EDU>> imhist(I);
Error using imhist
Expected input number 1, I or X, to be two-dimensional.
Error in imhist>parse_inputs (line 277)
validateattributes(a,
{'double','uint8','int8','logical','uint16','int16','single','uint32',
'int32'}, ...
Error in imhist (line 59)
[a, n, isScaled, top, map] = parse_inputs(varargin{:});
EDU>> B=imread('eight.tif');
imshow(B);
figure, imcontour(B);
Error using imcontour
Expected input number 1, I, to be two-dimensional.
Error in imcontour>ParseInputs (line 109)
validateattributes(a,{'uint8','int16','uint16','double','logical','single'}, ...
Error in imcontour (line 41)
[x,y,a,extra_args] = ParseInputs(varargin{:});
回答(2 个)
Image Analyst
2014-2-12
Worked for me. Somehow I think your eight.tif got converted to a 3D color image. What does this say:
whos I
size(I)
3 个评论
Image Analyst
2014-2-12
What variable are you using in this:
I = imread('eight.tif');
You must have a typographical error somewhere.
Image Analyst
2016-10-8
Moon, you should definitely have an "I" because your code shows you assigning the output of imread() to it, so if you get the error message
Undefined function or variable 'I'.
then you've changed the code from what you've posted.
Here is some code that I use in demos when the user is expecting to have a gray scale image, but it may not be.
grayImage = imread(fullFileName);
% Get the dimensions of the image.
% numberOfColorBands should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(grayImage);
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.
grayImage = rgb2gray(grayImage);
% 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
After that code, grayImage (which is a much better name than I) will be a grayscale image, either the original image, or the original image converted from RGB into gray scale.
Nikhil Lohia
2016-10-8
The cause of error is because your image is RGB and imhist does not deal with that. To work around this you can either use a single channel:
imhist(YourImage(:,:,Channel));
or convert from RGB to grayscale:
imhist(rgb2gray(YourImage));
That should work fine now.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!