image processing area calculation

Hi,
I am new to image processing in matlab and I am trying to get an area measurement out of histology slides. I want to convert the image to binary get a pixel count of the white area and using a known distance (scale bar) in the image calculate the area.
I am using a sample code for medical image processing webinar but I am having trouble getting the right amount of contrast in my images I am not getting them to completely convert to a binary image.
Is there a way for me to first close out the edges that are not complete in the image and fill and then convert to binary or another method that would work?
function [image] = getCA(image)
A = imread (image);
glayer = A(:,:,2);
figure;
imshow(glayer)
agray = rgb2gray (A);
level = graythresh (agray);
abinary = ~im2bw(glayer, level);
figure;
imshow(abinary)
cc = bwconncomp (abinary);
stats = regionprops (cc, 'basic');
B = [stats.Area];
[~,biggest] = max(B);
abinary(labelmatrix(cc)~=biggest) = 0;
imshow(abinary)
abinary = imfill(abinary, 'holes');
Thanks so much for the help!

Answers (2)

Image Analyst
Image Analyst on 18 Jul 2014
image is the name of a built in function. Do not use it as the name of a variable.
I'm not sure what you're calling "white" in the image, and what region(s) you'd like the area of.
I don't see any code there where you are trying to extract the 300 um scale bar.
See my Image Segmentation Tutorial for how to threshold and get areas: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
linson vincent
linson vincent on 26 Jan 2018
how to find area of a image using matlab

1 Comment

Multiply the number of pixels in the image by the spatial calibration factor in real world units per pixel. See attached spatial calibration demo.

Sign in to comment.

Asked:

on 18 Jul 2014

Commented:

on 26 Jan 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!