How to detect bright thick fibers around boundary?

1 Ansicht (letzte 30 Tage)
Zeynab Mousavikhamene
Zeynab Mousavikhamene am 4 Feb. 2020
Kommentiert: Mahesh Taparia am 10 Feb. 2020
I need to extract bright thick fibers that are surrounding the cell. In this image:
1 - Copy.jpg
The bright thick fiber that I am talking is:
Inked1 - Copy_LI.jpg
I need to find if that exists, and if yes what is the length of that structure or what proportion of perimeter is that structure and how thick it is. This structure in biology is called cell lamellopodia.
I need to do it automated in the macro as I have many images.

Antworten (2)

Mahesh Taparia
Mahesh Taparia am 7 Feb. 2020
Hi Zeynab
By looking at the image and size of fibers, a possible approach could be the threshold-based approach to segment the fiber. It can be done using ‘a’ component of ‘lab’ color space and select some threshold to discriminate the fiber. Consider the code below:
I=imread('image.jpeg');
Lab=rgb2lab(I);
a=Lab(:,:,2);
figure;imagesc(a)
c=a<-47; %selection of threshold, can try with other value / method
figure;imshow(I.*(uint8(c)))
Although c contains fiber and some small components of image, by using regionprops command we can find the area of each component which is the pixel count of each component. The fiber will have the maximum area, so selecting the max area component will give the fiber’s pixel count.
stats = regionprops('table',c,'Centroid','Area')
fiber_part=max(stats.Area);
fractional_area= fiber_part/(size(I,1)*size(I,2));
For more information, you can refer to the documentation page of regionprops.
  2 Kommentare
Zeynab Mousavikhamene
Zeynab Mousavikhamene am 10 Feb. 2020
Thanks. What you mean by "component of image"?
Mahesh Taparia
Mahesh Taparia am 10 Feb. 2020
Hi
By component, I mean the independent, non touching part/ area of image which remained after doing thresholding, i.e after the following line
c=a<-47; %selection of threshold, can try with other value / method
figure;imshow(I.*(uint8(c)))
You can take threshold of some other channel/ color space also. For this, you can try with 'Color Thresholder' app of MATLAB to decide.

Melden Sie sich an, um zu kommentieren.


Image Analyst
Image Analyst am 10 Feb. 2020
Zeynab, you need to segment out the lamellopodia. You can do this simply by thresholding the green channel. Then, get the area of the blob. Assuming it's roughly rectangular, you can say that the area is the length times average width. To get the average width, you can use the bwdist() function, which will give you the radius at every point. Take the average radius along the centerline and multiply by 2 to get the average width. Then the length is just area/width.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clearvars;
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 16;
folder = pwd;
baseFileName = '1 - Copy.jpeg';
% baseFileName = 'IMG_Segment_Success.JPEG';
fullFileName = fullfile(folder, baseFileName);
rgbImage = imread(fullFileName);
% Display the original image.
subplot(2, 3, 1);
imshow(rgbImage, []);
axis('on', 'image');
caption = sprintf('Original Color Image\n"%s"', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo(); % Set up status line to see values when you mouse over the image.
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0.05 1 0.95]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by Image Analyst', 'NumberTitle', 'Off')
% Get the green image.
grayImage = rgbImage(:, :, 2);
% Display the image.
subplot(2, 3, 2);
imshow(grayImage, []);
axis('on', 'image');
caption = sprintf('Green Channel of \n"%s"', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo(); % Set up status line to see values when you mouse over the image.
subplot(2, 3, 3);
imhist(grayImage);
grid on;
title('Histogram of Green Channel', 'FontSize', fontSize, 'Interpreter', 'None');
% Get a binary image.
mask = grayImage > 110;
% Take only the largest blob. Use 4-connectivity.
mask = bwareafilt(mask, 1, 4);
% Display the original image.
subplot(2, 3, 4);
imshow(mask, []);
axis('on', 'image');
caption = sprintf('Binary Image\n"%s"', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
% To find the average length and width we need to get the Euclidean distance transform and the skeleton of it.
edtImage = bwdist(~mask);
% Display the image.
subplot(2, 3, 5);
imshow(edtImage, []);
axis('on', 'image');
caption = sprintf('Distance Transform');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo(); % Set up status line to see values when you mouse over the image.
skeletonImage = bwmorph(mask, 'skel', inf);
% Display the image.
subplot(2, 3, 6);
imshow(skeletonImage, []);
axis('on', 'image');
caption = sprintf('Skeleton');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
% Extract the distance along the skeleton to get the radius at every point along the centerline.
% Multiply the radius by two to get the width.
meanWidth = 2 * mean(edtImage(skeletonImage)) % In pixels
% Now get the area
area = sum(mask(:)) % Or bwarea(mask) if you want - they use different algorithms.
% Get the mean length. Assume the blob is a rectangle so the length
% is the area divided by the mean width.
blobLength = area / meanWidth
% Put up a title on subplot #4 with the length and width/
subplot(2, 3, 4);
caption = sprintf('Mask. Average width = %.2f, length = %.2f', meanWidth, blobLength);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
0001 Screenshot.png
You can see that the average width is 4.74 pixels and the length is 295.58 pixels.

Kategorien

Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by