image processing matlab codes error
Show older comments
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 Comments
Walter Roberson
on 7 Feb 2012
What error message shows up for you ?
Syahrul Niezam
on 8 Feb 2012
Answers (3)
Walter Roberson
on 8 Feb 2012
0 votes
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
on 8 Feb 2012
0 votes
Like it says, bwconncomp() does not use grayscale images. It needs a binary image - this is of class "logical" not "uint8".
2 Comments
Walter Roberson
on 8 Feb 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
on 8 Feb 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.
Image Analyst
on 8 Feb 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.
Categories
Find more on Region and Image Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!