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 个评论

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');

请先登录,再进行评论。

 采纳的回答

Sean de Wolski
Sean de Wolski 2011-6-17
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 个评论

Daniel
Daniel 2011-6-17
thank you sean.
the image that is obtained is just a line. Do you know how to solve this?
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 2011-7-11
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
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

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by