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!