I want to select the pieces of an image that have these caracteristics: area > 10 and Eccentricity > 0,4.
How can i combine those in one fuction?
Thank you for the attention.
Daniel Carvalho

1 Kommentar

John  Wick
John Wick am 6 Jul. 2023
I = imread('cell.tif'); [~,threshold] = edge(I,'sobel'); fudgeFactor = 0.5; BWs = edge(I,'sobel',threshold * fudgeFactor); se90 = strel('line',3,90); se0 = strel('line',3,0); BWsdil = imdilate(BWs,[se90 se0]); BWdfill = imfill(BWsdil,'holes'); BWnobord = imclearborder(BWdfill,4); seD = strel('diamond',1); BWfinal = imerode(BWnobord,seD); BWfinal = imerode(BWfinal,seD); subplot(3, 3, 1), imshow(I),title('Orginal image'); subplot(3, 3, 2), imshow(BWs),title('Binary Gradient Mask'); subplot(3, 3, 3), imshow(BWsdil),title('Dilated Gradient Mask'); subplot(3, 3, 4), imshow(BWdfill),title('BI with Filled Holes'); subplot(3, 3, 5), imshow(BWnobord),title('Cleared Border Image'); subplot(3, 3, 6), imshow(BWfinal),title('Segmented Image'); subplot(3, 3, 7), imshow(labeloverlay(I,BWfinal)),title('Mask Over Image');

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Sean de Wolski
Sean de Wolski am 17 Jun. 2011

0 Stimmen

I = rand(100)>.75; %sample binary image
CC = bwconncomp(I); %Connected Components Analysis
stats = regionprops(CC,'area','eccentricity'); %regionprops
idx = [stats(:).Area]>10&[stats.Eccentricity]<0.4;
%logical indices corresponding to area > 10 and eccentricity <0.4.
Do what you what you want with CC,idx; all of the information is there.

4 Kommentare

Daniel
Daniel am 17 Jun. 2011
thank you sean.
the image that is obtained is just a line. Do you know how to solve this?
Sean de Wolski
Sean de Wolski am 17 Jun. 2011
What do you mean the image obtained is just a line?
Is that the only object with 10px connected and an eccentricity <0.4?
Show us the code!
Daniel
Daniel am 11 Jul. 2011
sorry about the delay but i wasn't able to come here sooner. it was a noob error that i was doing. thank you very much
John  Wick
John Wick am 6 Jul. 2023
g1 = imread("C:\Users\19b-140-CS\Desktop\lab08\skeleton.png"); img1 = im2gray(img1); lap = fspecial('laplacian'); fltimg = imfilter(img1,lap); enhanced_img = img1 - fltimg; sob = fspecial('sobel'); sobell = imfilter(enhanced_img, sob); filterSize = 5; filter = ones(filterSize) / (filterSize^2); smoothedImage = imfilter(sobell, filter); %sharpen = imsharpen(smoothedImage); image1 = im2double(enhanced_img); image2 = im2double(smoothedImage); lowPassFilter = fspecial('average', filterSize); highFreqImage = enhanced_img - imfilter(enhanced_img, lowPassFilter); lowFreqImage = imfilter(smoothedImage, lowPassFilter); sharpImage = highFreqImage + lowFreqImage; power_img = 1 * im2double(sharpImage(:,:)).^ (0.8); subplot(2, 3, 1), imshow(img1),title('Orginal image'); subplot(2, 3, 2), imshow(fltimg),title('Lap Flt Image'); subplot(2, 3, 3), imshow(enhanced_img),title('Enhanced Image'); subplot(2, 3, 4), imshow(sobell),title('Sobel Flt Image'); subplot(2, 3, 5), imshow(smoothedImage),title('smoothed Image'); subplot(2, 3, 6), imshow(power_img),title('Sharp Imag

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by