Effacer les filtres
Effacer les filtres

Image segmentation to segment the large blob into singular objects MATLAB

3 vues (au cours des 30 derniers jours)
Saye Vikram
Saye Vikram le 5 Avr 2024
Commenté : Saye Vikram le 6 Avr 2024
I have a task which needs me to perform image segmentation for every pellet for this image (pellet being defined as every "flat-ish" pellet that is visible from the side of the screen, no pellets that I cannot see the whole side-view of):
I performed image segmentation for this image, using a mask and segmenting images on the basis of the pellets, as below:
function [BW,maskedRGBImage] = mymask(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
% range for each channel of the colorspace were set within the app. The
% segmentation mask is returned in BW, and a composite of the mask and
% original RGB images is returned in maskedRGBImage.
% Auto-generated by colorThresholder app on 01-Apr-2024
% Convert RGB image to chosen color space
I = rgb2hsv(RGB);
% Define thresholds for channel 1 based on histogram settings
channel1Min = 0.009;
channel1Max = 0.112;
% Define thresholds for channel 2 based on histogram settings
channel2Min = 0.103;
channel2Max = 0.275;
% Define thresholds for channel 3 based on histogram settings
channel3Min = 0.347;
channel3Max = 0.687;
% 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;
inpict = imread('test.png');
mk = mymask(inpict); % create a mask using global thresholds
mk = bwareaopen(mk,100); % get rid of a thousand tiny specks
S = regionprops(mk,'area');
CT = hsv(numel(S));
CT(2:2:end,:) = flipud(CT(2:2:end,:));
% the result is one giant conglomerate blob
% and several smaller conglomerate blobs
alpha = 0.8;
outpict = labeloverlay(inpict,bwlabel(mk), ...
Using the mask, I generated this image, consisting of some smaller pellets and one huge mass:
My question is, how could the pellets be further segmented in the red-portion? Is there any way to separate them on the basis of their looks (if they are flat-ish making them a distinct pellet instead of being homogenized with the rest)?

Réponses (1)

Image Analyst
Image Analyst le 5 Avr 2024
What about my answer in your duplicate question:
Why are you asking again?
  1 commentaire
Saye Vikram
Saye Vikram le 6 Avr 2024
Sorry caught up with stuff, could not get to your response. What I REALLY need is either the center position and orientation (angle relative to the horizontal) of each pellet across a whole video in order to form a Langrangian description of flow. I either need that OR I need the average of Xi (Position of a pellet i) or Thetai in a small spatial region at time T in order to form a Eulerian description of flow. Ultimately I am trying to find the governing equations for X(x, y, t) and Theta(x, y, t)

Connectez-vous pour commenter.


En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by