How can I to do bwlabel for RGB image

clc ; clear all ;
imgs = imread('hand.jpg') ;
img = double (imgs) ;
[ii , jj , kk] = size(img) ;
img1 = zeros(ii,jj);
img2 = zeros(ii,jj);
imghsv = rgb2hsv(img) ;
img1(imghsv(:,:,1)<0.1) = 1 ;
img2(imghsv(:,:,1)>0) = 1 ;
img3 = img1 & img2 ;
imgreo = imerode(img3,ones(3)) ;
imgdil = imdilate(imgreo,ones(5)) ;
leb = bwlabel(imgdil) ;
im1 = (leb==1) ;
im2 = (leb==2) ;
subplot(2,2,1);imshow(imgs);
subplot(2,2,2);imshow(imgdil);
subplot(2,2,3);imshow(im1);
subplot(2,2,4);imshow(im2);
I can do bwlabel for Binarization image,but I don't know how to do RGB image?
I want to do the bwlabel for my top left image(imgs = imread('hand.jpg') ;), how can I do ?

1 Comment

bwlabel() only works on binary images, hence the prefix 'bw'. That aside, what would the results of such an operation look like? bwlabel returns a map of the connected components in a binary image. What is a connected component of an RGB image? Is it a non-white region? Is it a region whose color points lie within a rectangular prism in 3D space? What about an ellipsoid? Is there any answer to that question which does not describe the process of binarization of the image?

Sign in to comment.

Answers (0)

Asked:

on 4 Jun 2021

Commented:

DGM
on 4 Jun 2021

Community Treasure Hunt

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

Start Hunting!