Calculate length of white pixels in binary image
조회 수: 1 (최근 30일)
이전 댓글 표시
![bbbb.PNG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/231965/bbbb.png)
I want to calculate the length in pixels of the white pixels at the bottom of the image assuming it is a line without breaks without manually using imdist tool.
Thanks in advance.
댓글 수: 1
Michael Madelaire
2019년 7월 31일
You should include a data file, such that people willing to help can have a look.
Additionally tou should state some constratints. Is a line only defined if the as being the same row? or can it be diagonally displaced? If so, then how much?
답변 (2개)
Eva-Maria Weiss
2019년 7월 31일
Hi!
Assuming that approximating the lineshape structure in the bottom area of your oicture as a line you could try the following
- Extract the bottom part of your pictur
subFrame = yourPic(rowmiddl:end,:)
2. Now you can find the indices of white pixels by
idx = find(subFrame) %looks for non-zero elements, returns a list
3. Convert linea indexing to subscripts by
[r,c] = ind2sub(size(subFrame),idx)
4. The next step could simply mathematically solved by pythagoras?
qNumbPix = (r(end)-r(1))^2 + (c(end)-c(1))^2
NumbPix = sqrt(qNumbPix
I hope this will help!
Good Luck!
댓글 수: 0
KALYAN ACHARJYA
2019년 7월 31일
편집: KALYAN ACHARJYA
2019년 7월 31일
Lets, image_bw is the binary image.(Please not your enclosed image have white boundary, I ignored that)
se=strel('disk',4);
result=imdilate(image_bw,se);
result=bwareafilt(result,1,'Largest');
result=imerode(result,se);
figure,imshow(result);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/231979/image.png)
Next: Find the maximum distance between two white pixels, number of similar question already answered by @ImageAnalyst and @Walter, please do search see here too.
I hope you can do that, please try if not, let me know.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!