Calculating area of irreguar border shape
이전 댓글 표시
Hi all, I am developing a system to calculate border irregularity in cell images. For this i need to know the perimeter and area of the cell in the image. I have been able to create a border around the cell by using the following code:
files = uigetfile('*.jpg', 'Please Select Image','multiselect','on');
if (iscell(files))
for count = 1:numel(files)
BorderLocater(files{count});
end
else
BorderLocater(files);
end
-----------------------------------------------
function BorderLocater(image)
I = rgb2gray(imread(image));
figure, imshow(I), title('Original Cell Image');
text(size(I,2),size(I,1)+15, ...
'converted to grayscale', ...
'FontSize',7,'HorizontalAlignment','right');
[junk, threshold] = edge(I, 'sobel');
fFr = .5;
BWs = edge(I,'sobel', threshold * fFr);
figure, imshow(BWs), title('Binary Gradient Mask');
se90 = strel('line', 3, 90);
se0 = strel('line', 3, 0);
BWsdil = imdilate(BWs, [se90 se0]);
figure, imshow(BWsdil), title('Dilated Gradient Mask');
BWdfill = imfill(BWsdil, 'holes');
figure, imshow(BWdfill);
title('binary image with filled holes');
BWnobord = imclearborder(BWdfill, 4);
figure, imshow(BWnobord), title('Partial Images Removed');
seD = strel('diamond',1);
BWfinal = imerode(BWnobord,seD);
BWfinal = imerode(BWfinal,seD);
figure, imshow(BWfinal), title('Segmented Image');
BWoutline = bwperim(BWfinal);
Segout = I;
Segout(BWoutline) = 255;
figure, imshow(Segout), title('Cell with Border Outline');
return
I got my cell images off Google, and so have no idea of the spatial resolution. I was wondering if anyone knew how to calculate a value for the area (doesn't have to be in cm^2)
Thanks in advance
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Thresholding에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!