Effacer les filtres
Effacer les filtres

How to extract the blob of gray image ?

4 vues (au cours des 30 derniers jours)
Jenifer NG
Jenifer NG le 18 Fév 2023
Commenté : Jenifer NG le 23 Fév 2023
Dear All ,
I want to extract blob of this image then measure the maximum major length.
I try some method but is is not work.
here is my code:
clc
clear
X = imread('img.tif')
X = imadjust(X);
% Threshold image - manual threshold
BW = im2gray(X) > 0;
% Open mask with disk
radius = 3;
decomposition = 0;
se = strel('disk', radius, decomposition);
BW = imopen(BW, se);
% Close mask with disk
radius = 5;
decomposition = 0;
se = strel('disk', radius, decomposition);
BW = imclose(BW, se)*255;
% imshow(BW)
props = regionprops(BW,'MajorAxisLength','BoundingBox')
[max_length, idx] = max([props.MajorAxisLength]);
% Get the bounding box of the biggest blob
bbox = props(idx).BoundingBox;
% Plot the rectangle around the biggest blob
figure;
imshow(BW);
hold on;
rectangle('Position', bbox, 'EdgeColor', 'r', 'LineWidth', 2);
Thanks and Regards!
Han

Réponse acceptée

Image Analyst
Image Analyst le 19 Fév 2023
I'd try some denoising first, like medfilt2 or imnlmfilt. Then I'd try adjusting the thresholds with my interactive thresholding app:
Then use bwferet. Don't use MaxAxisLength of regionprops since that gives you the max axis length of an ellipse fitted to the shape rather than the actual caliper distance like bwferet gives you.
  1 commentaire
Jenifer NG
Jenifer NG le 23 Fév 2023
Thanks you for your advice
I use the ImageSementer APP then app imcomplement then i can get the expected output by using bwferet .

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by