Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

an someone explain why I am getting the following error in my code?

1 vue (au cours des 30 derniers jours)
Pritha
Pritha le 19 Avr 2013
Clôturé : MATLAB Answer Bot le 20 Août 2021
I=imread('lena.jpg');
[M,N]=size(I);
p = zeros(256,3);
for ii=1:256 p(ii,1)=ii-1; end;
p(:,2) = imhist(I);
p (p(:,2)==0,:) = []; % remove zero entries in p
% Calling Shannon procedure, return t1 value and its location in p
[T1,Loc]=Shannon(p);
% Calling Tsallis procedure of Part1
pLow= p(1:Loc,:); T2= Tsallis_Sqrt(pLow);
% Calling Tsallis procedure of Part2
pHigh=p(Loc+1:size(p),:); T3=Tsallis_Sqrt(pHigh);
% Cerate binary matrices f
f=zeros(M,N);
for i=1:M;
for j=1:N;
if ((I(i,j)>= T2)&(I(i,j)<T1))|(I(i,j)>= T3)
f(i,j)=1; end;
end;
end
% Calling EdgeDetector procedure, return edge detection image.
[g]= EdgeDetector(f);
figure;
imshow(g);
I use the Shannon Entropy for find the threshold value. For this I create tree functions:Shannon(p),Tsallis_Sqrt(p),EdgeDetector(f). But I am getting this error in main file. Please help me to solve this error.
??? 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{:});
Error in ==> MainProgram at 6
p(:,2) = imhist(I);

Réponses (1)

Walter Roberson
Walter Roberson le 19 Avr 2013
imhist() does not work on RGB images such as lena.jpg .
Usually edge detection is done on the grayscale version of images.

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by