Image analysis of irregular shape of binary image
3 views (last 30 days)
I am very new to matlab and data analysis. My question might have some related answers but not all applicable to my questions. I have video of stretching transparent membrane with cross polarizers. Basically, If membrane is being stretched, there is stress inside membrane so light can penetrate through it. I extract image from video and use threshold to turn it into binary image. Figure 1 shows the comparison of image directly extracted from video and image after im2bw.
However, because the edge will reflect some light and the edge of the membrane is irreguular, it is difficult for me to know the height and area of the region where membrane is being stretched. I would like to know the length and area of the center region where there is light penetration. Following figures are my goal.
Also, it is a continuous process with around 1000 images so I want to export it continuously.
Thank you for your reading and I am looking forward to your advice.
Image Analyst on 30 Dec 2020
Is the width (left and right) always the same? If so you can just look between certain columns of the image and get the average or max extent in the vertical direction.
[rows, columns] = size(mask);
topRows = zeros(1, columns);
bottomRows = zeros(1, columns);
for col = column1 : column2
row = find(mask(:, col), 1, 'first');
topRows(col) = row;
row = find(mask(:, col), 1, 'last');
bottomRows(col) = row;
% Get rid of zeros
topRows(topRows == 0) = ;
bottomRows = bottomRows(bottomRows > 0); % just a different way
% Draw lines across and compute means.
meanTopRow = mean(topRows);
yline(meanTopRow, 'Color', 'r', 'LineWidth', 2)
meanBottomRow = mean(bottomRows);
yline(meanBottomRow, 'Color', 'r', 'LineWidth', 2)
meanHeight = mean(bottomRows - topRows)
message = sprintf('The mean height is %f pixels', meanHeight)