How to segment an image of an object from it body with the presence of shadow with same or lower intensity value?

1 visualización (últimos 30 días)
clear all; close all; clc;
img = imread("enhancedimage.jpg");
I1 = rgb2gray(img);
figure, imshow(I1);
% imageSegmenter(I1);
% function [BW,maskedImage] = segmentImage(I1)
% %segmentImage Segment image using auto-generated code from imageSegmenter app
% % [BW,MASKEDIMAGE] = segmentImage(X) segments image X using auto-generated
% % code from the imageSegmenter app. The final segmentation is returned in
% % BW, and a masked image is returned in MASKEDIMAGE.
% % Auto-generated by imageSegmenter app on 06-Nov-2023
% ----------------------------------------------------
% Adjust data to span data range.
X1 = imadjust(I1);
% Threshold image - manual threshold
BW = X1 > 10;
% Active contour
iterations = 10;
BW = activecontour(X1, BW, iterations, 'Chan-Vese');
% Create masked image.
maskedImage = X1;
maskedImage(~BW) = 0;
% end
figure, imshow(maskedImage);
figure, imshow(C);
As you can see from the figure attached, I am trying to segment a nucleus (rounded-like shape) from a cell with a presence of shadow on the cell. I have try thresholding, Otsu thresholding and circular hough Transform. The result gave the same which are including the shadow and dark background as an object. Is there a way to segment the nucleus only? I have try to control the threshold value but it did not meet the expectation.
A comparison of the grayscale image and it segmentation

Respuesta aceptada

Image Analyst
Image Analyst el 29 de Nov. de 2023
First you can ask bwareafilt to give you only blobs that fall into a certain size range (range of area in pixels).
mask = bwareafilt(mask, [minArea, maxArea]); % Get just acceptable areas.
Then you can ask regionprops to give you the circularities. From those you can distinguish roundish objects from oblong or stick-like objects. Something like
labeledImage = bwlabel(mask); % Give each blob an ID number.
props = regionprops(labeledImage, 'Circularity');
allCircs = [props.Circularity]
goodCircs = allCircs > 0.6; % Or whatever. This is a logical vector of true or false.
goodIndexes = find(goodCircs); % Convert logical vector to actual index numbers.
% Extract only the good blobs.
mask = ismember(labeledImage, goodIndexes);
For a full tutorial, see my Image Segmentation Tutorial in my File Exchange:
It's a generic, general purpose demo of how to threshold an image to find blobs, and then measure things about the blobs, and extract certain blobs based on their areas or diameters.

Más respuestas (0)




Community Treasure Hunt

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

Start Hunting!

Translated by