image processing matlab codes error

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 个评论

What error message shows up for you ?
The error shows in line C = bwconncomp(x);
It is stated that:
Undefined function or method 'bwconncomp' for input arguments of type 'uint8'.

请先登录,再进行评论。

回答(3 个)

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 2012-2-8
Like it says, bwconncomp() does not use grayscale images. It needs a binary image - this is of class "logical" not "uint8".

2 个评论

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.
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.

请先登录,再进行评论。

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.

类别

帮助中心File Exchange 中查找有关 Denoising and Compression 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by