# Methods for analysis of plots in image processing

14 views (last 30 days)
JCH on 29 Jun 2020
Commented: JCH on 30 Jun 2020
Hello everyone.
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.
Thank you.
##### 2 CommentsShowHide 1 older comment
JCH 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
find(data_1D>5,1,'first')
find(data_1D>5,1,'last')
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.
JCH on 30 Jun 2020

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()
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:
inSpray = verticalProfile > 10; % Only find rows with more than 10 white pixels.
topRow = find(inSpray, 1, 'first');
bottomRow = find(inSpray, 1, 'last');
JCH on 30 Jun 2020
Thank you. I get more professional knowledge.

### Categories

Find more on Image Arithmetic in Help Center and File Exchange

R2019b

### Community Treasure Hunt

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

Start Hunting!

Translated by