image processing matlab codes error

조회 수: 15 (최근 30일)
Syahrul Niezam
Syahrul Niezam 2012년 2월 7일
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
Walter Roberson
Walter Roberson 2012년 2월 7일
What error message shows up for you ?
Syahrul Niezam
Syahrul Niezam 2012년 2월 8일
The error shows in line C = bwconncomp(x);
It is stated that:
Undefined function or method 'bwconncomp' for input arguments of type 'uint8'.

댓글을 달려면 로그인하십시오.

답변 (3개)

Walter Roberson
Walter Roberson 2012년 2월 8일
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
Walter Roberson
Walter Roberson 2012년 2월 8일
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 2012년 2월 8일
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.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2012년 2월 8일
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