MATLAB Answers


Extract color with in region

Asked by Noor us Saba on 19 Apr 2019
Latest activity Commented on by Noor us Saba on 22 Apr 2019
I want to extract the color of tablets from the strips. i segmented the tablets using bwboundaries. kindly help me to extract the color of each region
Here is my code
[TotalSampleObjNo,L] = bwboundaries(Noise_FreeImg,'noholes'); % Search only for object
imshow(label2rgb(L,@jet,[.5 .5 .5]))
hold on
%disp (length (TotalSampleObjNo));
for k = 2:length(TotalSampleObjNo) % Starts with 1 for all boundries
boundary = TotalSampleObjNo{k};


Sign in to comment.


1 Answer

Answer by Image Analyst
on 19 Apr 2019

% Extract your color channels
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Extract mean color in the binary image mask
redMean = redChannel(Noise_FreeImg)
greenMean = greenChannel(Noise_FreeImg)
blueMean = blueChannel(Noise_FreeImg)

  1 Comment

i didnt get how to use these mean value to detect the color of sample tablet.
regionprops give the binary image how we used to extract the color information from the binary image

Sign in to comment.