Effacer les filtres
Effacer les filtres

How to detect first 50 white pixels from right side of a binary image?

1 vue (au cours des 30 derniers jours)
anshumala rakesh
anshumala rakesh le 24 Fév 2019
Commenté : Image Analyst le 24 Fév 2019
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?

Réponse acceptée

Rik
Rik le 24 Fév 2019
Modifié(e) : Rik le 24 Fév 2019
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 commentaires
anshumala rakesh
anshumala rakesh le 24 Fév 2019
Modifié(e) : Image Analyst le 24 Fév 2019
Actually I have this binary image as my input and I wanted to extract only the region marked in red as output.
untitled.bmp
So I thought of detecting the first few white pixels from right side which fits that region. here 50 is just a random guess . l just wanted to know about the function.
Image Analyst
Image Analyst le 24 Fév 2019
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by