Problem on 'bitand' method
Show older comments
Hi friends,
I have problem on 'bitand' method when create marker image using mask.
I2 = im2bw(I1,0.8); %%Thresholding image(Create a mask)
I2Cmp = ~ I2; %%Invert the mask
marker=bitand(1,I2Cmp); %%Create marker image
There is an error when creating marker.
??? Error using ==> bitand Inputs must be non-negative integers.
How would I apply bitand for creating a maker ????
2 Comments
David Young
on 7 Apr 2011
Could you explain what the marker image should be? It's not clear why you would want to use bitand at all in this context, and I wonder if you need something completely different. I2 and I2Cmp are logical arrays, so there is only one bit of information per pixel anyway.
nayomi ranamuka
on 7 Apr 2011
Accepted Answer
More Answers (3)
Steve Eddins
on 7 Apr 2011
The general answer is to use the elementwise logical operators &, |, and ~ instead of bitand and bitor to do this sort of manipulation with binary images.
To "overlay the inverted image of I2 on I1," as you say, you would do this:
marker = I1 | ~I2;
2 Comments
David Young
on 7 Apr 2011
Steve, I don't think I1 is logical.
Steve Eddins
on 7 Apr 2011
David, you're right, sorry.
nayomi ranamuka
on 7 Apr 2011
0 votes
Steve Eddins
on 7 Apr 2011
Here's a different kind of overlay:
Iresult = I1;
Iresult(ICmp) = 255; % assuming I1 is uint8
This version turns all the marker pixels white and leaves the others alone.
Categories
Find more on Texas Instruments C2000 Processors 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!