Error using imhist expected input number 1 i or x to be two dimensional

Hello! I want to see the histogram of my image, but I don't know why, it doesn't show. Here's my code: I=imread('D7.jpg'); imshow(I); imhist(I); The error is :" Error using imhist Expecte...

It does work. In fact here is the code:

clc; % Clear the command window.

close all; % Close all figures (except those of imtool.)

workspace; % Make sure the workspace panel is showing.

format long g;

format compact;

fontSize = 16;

%===============================================================================

% Get the name of the image the user wants to use.

baseFileName = ‘index.jpg’;

folder = pwd;

fullFileName = fullfile(folder, baseFileName);

% Check if file exists.

if ~exist(fullFileName, ‘file’)

% The file doesn’t exist — didn’t find it there in that folder.

% Check the entire search path (other folders) for the file by stripping off the folder.

fullFileNameOnSearchPath = baseFileName; % No path this time.

if ~exist(fullFileNameOnSearchPath, ‘file’)

% Still didn’t find it. Alert user.

errorMessage = sprintf(‘Error: %s does not exist in the search path folders.’, fullFileName);

uiwait(warndlg(errorMessage));

return;

end

end

%=======================================================================================

% Read in demo image.

rgbImage = imread(fullFileName);

% Get the dimensions of the image.

[rows, columns, numberOfColorChannels] = size(rgbImage)

% Display image.

subplot(2, 4, 1);

imshow(rgbImage, []);

impixelinfo;

axis on;

caption = sprintf(‘Original Color Imagen%s’, baseFileName);

title(caption, ‘FontSize’, fontSize, ‘Interpreter’, ‘None’);

hp = impixelinfo(); % Set up status line to see values when you mouse over the image.

% Set up figure properties:

% Enlarge figure to full screen.

set(gcf, ‘Units’, ‘Normalized’, ‘OuterPosition’, [0 0.05 1 0.95]);

% Get rid of tool bar and pulldown menus that are along top of figure.

% set(gcf, ‘Toolbar’, ‘none’, ‘Menu’, ‘none’);

% Give a name to the title bar.

set(gcf, ‘Name’, ‘Demo by ImageAnalyst’, ‘NumberTitle’, ‘Off’)

drawnow;

% Extract the individual red, green, and blue color channels.

redChannel = rgbImage(:, :, 1);

greenChannel = rgbImage(:, :, 2);

blueChannel = rgbImage(:, :, 3);

% Display the color channel images.

subplot(2, 4, 2);

imshow(redChannel);

caption = sprintf(‘Red Channel Image’);

title(caption, ‘FontSize’, fontSize, ‘Interpreter’, ‘None’);

impixelinfo;

axis on;

subplot(2, 4, 3);

imshow(greenChannel);

caption = sprintf(‘Green Channel Image’);

title(caption, ‘FontSize’, fontSize, ‘Interpreter’, ‘None’);

impixelinfo;

axis on;

subplot(2, 4, 4);

imshow(blueChannel);

caption = sprintf(‘Blue Channel Image’);

title(caption, ‘FontSize’, fontSize, ‘Interpreter’, ‘None’);

impixelinfo;

axis on;

drawnow;

% See if all three channels are identical.

% If so, it’s a gray scale image in a color image format.

subplot(2, 4, 5:8);

if isequal(redChannel, greenChannel) && isequal(redChannel, blueChannel)

% It’s gray scale.

imhist(redChannel); % Just take any one of them

else

redCounts = imhist(redChannel);

greenCounts = imhist(greenChannel);

blueCounts = imhist(blueChannel);

gls = 0 : 255;

plot(gls, redCounts, ‘r-‘, ‘LineWidth’, 2);

hold on;

plot(gls, greenCounts, ‘g-‘, ‘LineWidth’, 2);

plot(gls, blueCounts, ‘b-‘, ‘LineWidth’, 2);

xlabel(‘Gray Levels’, ‘FontSize’, 16);

ylabel(‘Counts’, ‘FontSize’, 16);

title(‘All 3 color histograms’, ‘FontSize’, 16);

end

grid on;

The reason that the color histograms are different, is because you unwisely chose to save the image in JPEG format. I believe the image should really be grayscale. Don’t use JPG format when doing image analysis.

From: Yang on 10 Oct 2009 09:44


Hi,
I am reading in a tif image file, and get the histogram of the image. However, getting the following error messages:
Can anyone help me here?

thanks
song

>> a = imread(‘song.tif’);
>> figure, imhist(a);
??? Error using ==> iptcheckinput
Function IMHIST expected its first input, I or X, to be two-dimensional.

Error in ==> imhist>parse_inputs at 270
iptcheckinput(a, {‘double’,’uint8′,’logical’,’uint16′,’int16′,’single’}, …

Error in ==> imhist at 57
[a, n, isScaled, top, map] = parse_inputs(varargin{:});

From: ImageAnalyst on 10 Oct 2009 09:57


On Oct 10, 9:44 am, «Yang » <songyang_2…(a)hotmail.com> wrote:
> Hi,
> I am reading in a tif image file, and get the histogram of the image. However, getting the following error messages:
> Can anyone help me here?
>
> thanks
> song
>
> >> a = imread(‘song.tif’);
> >> figure, imhist(a);
>
> ??? Error using ==> iptcheckinput
> Function IMHIST expected its first input, I or X, to be two-dimensional.
>
> Error in ==> imhist>parse_inputs at 270
> iptcheckinput(a, {‘double’,’uint8′,’logical’,’uint16′,’int16′,’single’}, ….
>
> Error in ==> imhist at 57
> [a, n, isScaled, top, map] = parse_inputs(varargin{:});
—————————————————————————————-
You need to supply a 2D image. Put this line before the imhist line:
size(a) % No semicolon
What does it print out to the command window?

From: Sufiah Ahmad on 14 Oct 2009 02:01


ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <d1188ec2-6505-443d-bbbd-224c30554d31(a)k33g2000yqa.googlegroups.com>…
> On Oct 10, 9:44?am, «Yang » <songyang_2…(a)hotmail.com> wrote:
> > Hi,
> > I am reading in a tif image file, and get the histogram of the image. However, getting the following error messages:
> > Can anyone help me here?
> >
> > thanks
> > song
> >
> > >> a = imread(‘song.tif’);
> > >> figure, imhist(a);
> >
> > ??? Error using ==> iptcheckinput
> > Function IMHIST expected its first input, I or X, to be two-dimensional.
> >
> > Error in ==> imhist>parse_inputs at 270
> > iptcheckinput(a, {‘double’,’uint8′,’logical’,’uint16′,’int16′,’single’}, …
> >
> > Error in ==> imhist at 57
> > [a, n, isScaled, top, map] = parse_inputs(varargin{:});
> —————————————————————————————-
> You need to supply a 2D image. Put this line before the imhist line:
> size(a) % No semicolon
> What does it print out to the command window?
__________________________________________

I tried..still got error.

the error are:

??? Error using ==> iptcheckinput
Function IMHIST expected its first input, I or X, to be two-dimensional.

Error in ==> imhist>parse_inputs at 270
iptcheckinput(a, {‘double’,’uint8′,’logical’,’uint16′,’int16′,’single’},
….

Error in ==> imhist at 57
[a, n, isScaled, top, map] = parse_inputs(varargin{:});

From: Steven Lord on 14 Oct 2009 09:25


«Sufiah Ahmad» <princesssufiah(a)gmail.com> wrote in message
news:hb3pfg$d8u$1(a)fred.mathworks.com…
> ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message
> <d1188ec2-6505-443d-bbbd-224c30554d31(a)k33g2000yqa.googlegroups.com>…
>> On Oct 10, 9:44?am, «Yang » <songyang_2…(a)hotmail.com> wrote:
>> > Hi,
>> > I am reading in a tif image file, and get the histogram of the image.
>> > However, getting the following error messages:
>> > Can anyone help me here?
>> >
>> > thanks
>> > song
>> >
>> > >> a = imread(‘song.tif’);
>> > >> figure, imhist(a);
>> >
>> > ??? Error using ==> iptcheckinput
>> > Function IMHIST expected its first input, I or X, to be
>> > two-dimensional.
>> >
>> > Error in ==> imhist>parse_inputs at 270
>> > iptcheckinput(a,
>> > {‘double’,’uint8′,’logical’,’uint16′,’int16′,’single’}, …
>> >
>> > Error in ==> imhist at 57
>> > [a, n, isScaled, top, map] = parse_inputs(varargin{:});
>> —————————————————————————————-
>> You need to supply a 2D image. Put this line before the imhist line:
>> size(a) % No semicolon
>> What does it print out to the command window?
> __________________________________________
>
> I tried..still got error.
>
> the error are:
>
> ??? Error using ==> iptcheckinput
> Function IMHIST expected its first input, I or X, to be two-dimensional.

That’s correct. Execute this code:

a = imread(‘song.tif’);
numberOfDimensions = ndims(a)

If numberOfDimensions contains a value other than 2, you CANNOT use IMHIST
on this image directly; you will need to convert it to a 2D image, perhaps
by using RGB2IND if a is an m-by-n-by-3 array.


Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

From: Sufiah Ahmad on 14 Oct 2009 22:21


Thanks Steve , I tried your suggestion. there’s no error but the output is not the one that I want. …Threre’s no histogram ..it produce axis x & y with gray color only..no histogram bar

«Yang » <songyang_2005(a)hotmail.com> wrote in message <haq331$5aj$1(a)fred.mathworks.com>…
> Hi,
> I am reading in a tif image file, and get the histogram of the image. However, getting the following error messages:
> Can anyone help me here?
>
>
> thanks
> song
>
> >> a = imread(‘song.tif’);
> >> figure, imhist(a);
> ??? Error using ==> iptcheckinput
> Function IMHIST expected its first input, I or X, to be two-dimensional.
>
> Error in ==> imhist>parse_inputs at 270
> iptcheckinput(a, {‘double’,’uint8′,’logical’,’uint16′,’int16′,’single’}, …
>
> Error in ==> imhist at 57
> [a, n, isScaled, top, map] = parse_inputs(varargin{:});

image processing — imhist return error with bmp data in matlab —

i have image , want calculate historgram of it,but code return error ,

 i=imread('image number one.bmp');  imhist(i); 

and error

??? error using ==> iptcheckinput function imhist expected first input, or x, two-dimensional.  error in ==> imhist>parse_inputs @ 281 iptcheckinput(a, {'double','uint8','int8','logical','uint16','int16','single','uint32', 'int32'}, ...  error in ==> imhist @ 59 [a, n, isscaled, top, map] = parse_inputs(varargin{:}); 

appreciate

i found solution, picture rgb , imhist work in 2-d input, need convert grascale with

 i=rgb2gray(i); 

Popular posts from this blog

html — Border-Radius is not Aligning Properly —

i trying create div rounded corners. inside div contains additional content fill height of div. i’ve noticed there visual corruption @ each corner of rounded div. looks me corner of outer div lightly larger inner div. according code, border-radius of both divs should identical. example of issue: http://jsfiddle.net/mrzaf/4/ image of issue: http://imgur.com/ph6ihlc <div class=»a-a»> <div class=»a-b»>content in here</div> </div> <br><br> <div class=»b-a»> <div class=»b-b»>content in here</div> </div> div.a-a { background:red; border-radius:10px; width:400px; } div.a-b { background:aqua; border-radius:10px; height:200px; } div.b-a { background:red; border-radius:10px; width:400px; overflow:hidden; } div.b-b { background:aqua; width:400px; height:200px; } there couple of option this. first option : increase border-radius of parent container div.a-a { b

jquery — How can I dynamically add a browser tab? —

since using iframes house external pages are, accounts «not preferred method» , disallowed sites (flickr, one), want dynamically generate browser tabs. e.g., when user submits form, want dynamically generate tab on browser in response submitted. e.g., might want add new tab url like: http://www.bigsurgarrapata.com/contact how in jquery? you want form target attribute action attribute. http://www.w3schools.com/tags/att_form_target.asp browsers have ultimate control on result of target attribute open new tab value of _blank. <form action=»contact_submit.php» target=»_blank» method=»post»>

javascript — google.elements.newsShow display Time not working —

i trying use google newsshow api display news in html app. here code <html xmlns=»http://www.w3.org/1999/xhtml»> <head> <meta http-equiv=»content-type» content=»text/html; charset=utf-8″/> <title>google ajax search api sample</title> <script src=»http://www.google.com/jsapi?key=aizasya5m1nc8ws2bbmprwku5gfradvd_hgq6g0″ type=»text/javascript»></script> <script type=»text/javascript»> google.load(«elements», «1», {packages : [«newsshow»]}); function onload() { // set display time 2 seconds, , transition time 100 ms var options = { «querylist» : [ { «title» : «indian news», «topic» : «n», «ned» : «in» } ], «displaytime» : 1000, «transitiontime» : 50 } var content = document.getelem

Понравилась статья? Поделить с друзьями:
  • Error using horzcat dimensions of matrices being concatenated are not consistent матлаб
  • Error username is already in use please choose another one
  • Error user with this e mail already exist
  • Error user with such email already exists
  • Error user not found перевод