Methods for analysis of plots in image processing
조회 수: 4 (최근 30일)
이전 댓글 표시
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.
채택된 답변
Constantino Carlos Reyes-Aldasoro
2020년 6월 29일
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.
추가 답변 (1개)
Image Analyst
2020년 6월 29일
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');
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!