image processing matlab codes error

1 visualización (últimos 30 días)
Syahrul Niezam
Syahrul Niezam el 7 de Feb. de 2012
I'm really need help. I want to know what error at bwconncomp line. I had tried in other codes also but with the same mistake-mistake at bwconncomp line.
This is the codes for reference:
a = imread('image1_118.jpg');
binmap = uint8([0 180 200 255]);
[counts, binidx] = histc(a(:), [0 111 151 256]);
b = reshape( binmap(binidx), size(a) );
subplot(221);figure(1);imshow(b);
y=bwlabel(b);
x=uint8(y);
C = bwconncomp(x);
CC = labelmatrix(C);
subplot(222);figure(1);imshow(y);
subplot(223);figure(1);imshow(C);
subplot(224);figure(1);imshow(CC);
Thanks in advance.
  2 comentarios
Walter Roberson
Walter Roberson el 7 de Feb. de 2012
What error message shows up for you ?
Syahrul Niezam
Syahrul Niezam el 8 de Feb. de 2012
The error shows in line C = bwconncomp(x);
It is stated that:
Undefined function or method 'bwconncomp' for input arguments of type 'uint8'.

Iniciar sesión para comentar.

Respuestas (3)

Walter Roberson
Walter Roberson el 8 de Feb. de 2012
Which MATLAB release are you using? bwconncomp() is a newer routine, only a few releases old. You might need to use bwlabel() instead if that is what your release has.

Image Analyst
Image Analyst el 8 de Feb. de 2012
Like it says, bwconncomp() does not use grayscale images. It needs a binary image - this is of class "logical" not "uint8".
  2 comentarios
Walter Roberson
Walter Roberson el 8 de Feb. de 2012
http://www.mathworks.com/help/toolbox/images/ref/bwconncomp.html
"BW can be a logical or numeric array of any dimension, and it must be real and nonsparse."
The first example shows an input matrix that is double precision.
I do not have a sufficiently new MATLAB to check the details myself, so I would get exactly the error message that is being reported.
Image Analyst
Image Analyst el 8 de Feb. de 2012
OK you're right - I just read the first line where it said it wanted a binary image. So in that case, I don't know why bwconncomp would say that, unless it's the old problem of having his own m-file of that same name, which I doubt, or if unless he's not passing a binary image (which is probable). I still have a question in to his duplicate question asking what labelmatrix() is.

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 8 de Feb. de 2012
Are you sure "b" is really binary. Do this:
max(b(:))
min(b(:))
and tell us what it says. It should say 1 and 0.

Community Treasure Hunt

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

Start Hunting!

Translated by