MATLAB: How to make the cell circle

blood cellcellscirclecolor segmentationcompareImage Processing Toolboximagesnuclei

Hi i have 2 image which is before segment which is at left and after segment which is right.
As u guys can see, my cell at right is not properly circle as at left. Can u guys help me on how to make my right cell properly circle. Thanks !

Best Answer

Use the Color Thresholder on the Apps tab of the tool ribbon to figure out how to segment out just the purple color. Then you can use bwconvhull() to get totally convex versions of the cells. These values seemed pretty good to me:
function [BW,maskedRGBImage] = createMask(RGB)
%createMask Threshold RGB image using auto-generated code from colorThresholder app.
% [BW,MASKEDRGBIMAGE] = createMask(RGB) thresholds image RGB using
% auto-generated code from the colorThresholder App. The colorspace and
% minimum/maximum values for each channel of the colorspace were set in the
% App and result in a binary mask BW and a composite image maskedRGBImage,
% which shows the original RGB image values under the mask BW.
% Auto-generated by colorThresholder app on 29-Apr-2017
%------------------------------------------------------
% Convert RGB image to chosen color space
I = rgb2hsv(RGB);
% Define thresholds for channel 1 based on histogram settings
channel1Min = 0.598;
channel1Max = 0.051;
% Define thresholds for channel 2 based on histogram settings
channel2Min = 0.338;
channel2Max = 1.000;
% Define thresholds for channel 3 based on histogram settings
channel3Min = 0.000;
channel3Max = 0.887;
% Create mask based on chosen histogram thresholds
sliderBW = ( (I(:,:,1) >= channel1Min) | (I(:,:,1) <= channel1Max) ) & ...
(I(:,:,2) >= channel2Min ) & (I(:,:,2) <= channel2Max) & ...
(I(:,:,3) >= channel3Min ) & (I(:,:,3) <= channel3Max);
BW = sliderBW;
% Initialize output masked image based on input image.
maskedRGBImage = RGB;
% Set background pixels where BW is false to zero.
maskedRGBImage(repmat(~BW,[1 1 3])) = 0;
end
Related Question