calculating area and perimeter for pap-smear image
4 ビュー (過去 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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/276565/image.bmp)
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!