Methods for analysis of plots in image processing
14 views (last 30 days)
I have difficulty in image processing. I have to figure out a specific length through a plot that counts each pixel value of the image. I try to obtain the length through the x-values of the first y=0, and the x-values of the second y=0. Also, I need to analyze hundreds of images, so I need to repeat code accordingly. I want to save the final x value as an Excel file.
I would like to hear the opinions of various experts.
Constantino Carlos Reyes-Aldasoro on 29 Jun 2020
This seems rather simple. First, project your data to a single dimension, say your image is called data_2D,
data_1D = sum(data_2D,1); % or change the 1 to 2 depending on the orientation of the image
This will sum all the elements of each column/row. Then you want to avoid the noise so threshold above a certain level, say 5 and use find to locate first and last points
Then you can insert that in between a loop that will process all your data sets.
Hope this solves your problem. If it does, please accept the answer, if it does not, let me know.
More Answers (1)
Image Analyst on 29 Jun 2020
Another way. If you want to look at only the largest blob, and ignore the disconnected noise, call bwareafilt() first, then call regionprops()
mask = bwareafilt(mask, 1); % Take largest
props = regionprops(mask, 'BoundingBox'); % Find bounding box location.
boundingBox = props.BoundingBox
topRow = ceil(boundingBox(2))
bottomRow = ceil(boundingBox(2) + boundingBox(4))
Or you can sum the mask sideways and threshold to find rows with a significant number of white pixels:
verticalProfile = sum(mask, 2)
inSpray = verticalProfile > 10; % Only find rows with more than 10 white pixels.
topRow = find(inSpray, 1, 'first');
bottomRow = find(inSpray, 1, 'last');