Azzera filtri
Azzera filtri

Image segmentation to segment the large blob into singular objects MATLAB

5 visualizzazioni (ultimi 30 giorni)
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:
clear
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;
end
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), ...
'transparency',1-alpha,'colormap',CT);
imshow(outpict,'border','tight')
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)?

Risposte (1)

Image Analyst
Image Analyst il 5 Apr 2024
What about my answer in your duplicate question:
Why are you asking again?
  1 Commento
Saye Vikram
Saye Vikram il 6 Apr 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)

Accedi per commentare.

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by