How to detect first 50 white pixels from right side of a binary image?
1 次查看(过去 30 天)
显示 更早的评论
i have a binary image and for extracting the REGIIN OF INTEREST we need to detect the first 50 white pixels from right side of the image. can anyone suggest me how to do it?
0 个评论
采纳的回答
Rik
2019-2-24
编辑:Rik
2019-2-24
You can use find to get the indices from the left, so the only thing you need to do is flipping the image and convert the col indices:
A=[1 0 0;0 1 0;1 1 1];
N_pixels=3;
A=fliplr(A);%flip since find looks from the upper left corner
[r,c]=find(A,N_pixels);
c=size(A,2)-c+1;%flip indices back
%prove this is indeed correct:
B=accumarray([r,c],ones(size(r)),size(A))
%this may be faster depending on the size of your matrix and number of points:
%B=zeros(size(A));ind=sub2ind(size(B),r,c);B(ind)=1
4 个评论
Image Analyst
2019-2-24
The code Rik gave you won't work to extract that red region.
This is a classic case of someone saying "How do I do X" and then someone tells them how to do X. Then they say "That doesn't work". Then you ask what they REALLY want to do (the larger picture) and they say "What I really want to do is Y". Then the answerer says "Well if you really want to do Y then you don't want to do X at all, you want to do Z."
So now we need to know exactly what pixels should be in the red region. It appears to be a circle fitted to the right edge of a blob that is required to touch the left edge (or maybe not touch - I don't know). But the question is where is the left edge of the red circle? If you fit a circle to the pixels on the right of the blob, or a convex hull of it, then where the right part of the red circle will be depends on how far to the left you take pixels to do the circule fit.
Perhaps if you saw your gray scale, pre-segmentation image, it might give us another clue. Otherwise give us some idea of how we can determine what boundary pixels to fit to a circle.
更多回答(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!