calculating area and perimeter for pap-smear image
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Turlough Hughes
on 11 Mar 2020
Edited: Turlough Hughes
on 11 Mar 2020
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 Comments
Image Analyst
on 14 Mar 2020
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.
More Answers (0)
See Also
Categories
Find more on Image Segmentation and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!