calculating area and perimeter for pap-smear image
1 次查看(过去 30 天)
显示 更早的评论
Greetings,
I want to calculate the area and perimeter of the nucleus of image i have attached here. i have tried some of the codes, but i cant get it. please help me with the code for calculating the area and perimeter.
Thank you in advance.
0 个评论
采纳的回答
Turlough Hughes
2020-3-11
编辑:Turlough Hughes
2020-3-11
There are numerous ways you could segment the nucleus, I elected here to threshold based on R,G,B values in the image. To work out appropriate threshold values you can use the color thresholder app (I have already done that in this case). You will have to change the filename and you may also change rgb threshold values as you please. Note the thresholds are set to accept values less than rThresh, gThresh, bThresh.
I suggest you also look at the definitions for the properties obtained using the regionprops function. You will need to have some scale in terms of pixels per mm or pixels per micrometer to determine meaningful perimeter and area quantites.
% Parameters
% RGB threshold values
rThresh = 130;
gThresh = 130;
bThresh = 150;
% filename
filename = 'vidhya.bmp';
% Setup
fontSize = 16;
figure('Units', 'Normalized', 'OuterPosition', [0 0 1 1])
% Load & show image
A = imread(filename);
subplot(2,2,1), imshow(A)
title('Original Image','fontSize',fontSize)
% Implent thresholding
B = A(:,:,1)<rThresh & A(:,:,2)<gThresh & A(:,:,3)<bThresh;
% Display result of threshold
subplot(2,2,2), imshow(B)
title(sprintf('Values less than threshold (R:%d, G:%d, B:%d)', ...
rThresh,gThresh,bThresh),'fontSize',fontSize)
% Filter out all but the largest area & display results
C = bwareafilt(B,1);
subplot(2,2,3), imshow(C)
title('Largest area selected','fontSize',fontSize)
% Fill the area so all pixels inside are true
D = imfill(C,'holes');
% Get Area and Perimeter
props = regionprops(D,'Area','Perimeter');
% Show results
subplot(2,2,4), imshow(D);
title(sprintf('Final region (area filled) \n Area: %dpx Perimeter: %4.2fpx', ...
props.Area,props.Perimeter),'fontSize',fontSize)
7 个评论
Image Analyst
2020-3-14
Then like I said, if img_comp_s is your binary image mask, do:
props = regionprops(img_comp_s, 'Area');
allAreas = [props.Area];
Attach your .fig file if you want more help.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!