How can i convert this binary image to black background image?

 Réponse acceptée

Image Analyst
Image Analyst le 17 Jan 2015
vinith, this must be a class project or something from a text or else you're on the same project as Abdur Rahmaan, because I gave him complete code in this Answer http://www.mathworks.com/matlabcentral/answers/168170#answer_163355.
The way you're approaching it, with edge detection, is not the way I'd do it. I'd use color segmentation.

12 commentaires

Yes sir, the code you gave was about identifying the black spots. but the problem with the piece i am now attaching in the comment is you can see that the edge is with some airvent at the ends different from the original piece(also present in image). i dont know how to use color segmentation for detection for presence of such distorted ends. it would be kind of you if you can help us sort it out
If this is homework, you should tag it as homework. Otherwise you can use the code I already gave Abdur to do this here: http://www.mathworks.com/matlabcentral/answers/169564#answer_164589 In short, calculate the area and flag any orange part that is not within an acceptable range of areas as "defective". Will that work for you? Again, you don't need to do edge detection for that.
Sir,But still we need to work on other kind of defects where the edges are distorted in the end. its a different kind.we thought of using edge functions for these actually.I am attaching a image of distorted piece with original piece in same image for your comparison. i have attached image taken in other view too.Here the ends are distorted in different way. we cannot used the range of areas as you suggested here. it would be kind of you if u suggest me if there is a different way present or if it is only possible with edge functions please suggest us some tutorials to work on it
Image Analyst
Image Analyst le 17 Jan 2015
Modifié(e) : Image Analyst le 17 Jan 2015
You have a big problem with your photography. The images are not at all in standard locations and that makes it hard to do any quality assurance measurements on the part. You should really make a jig to hold these parts in the correct orientation. If you're just going to toss them on a wrinkled fabric randomly then you must be willing to accept poor results. If you want accurate results, take care to set up a proper photographic system. This would include stable lighting, a ColorChecker Passport for color standardization, and a jig to hold the part. The jig might even have a rotating axle so that you can spin it to measure all sides of the part.
Ok sir, i will post my questions with better photos
OK, good.
And anyway, what do you and Abdur want to measure? Is he your colleague/co-worker or classmate? Do you want to measure area and presence of black spots to find defective parts, like he does?
vinith
vinith le 18 Jan 2015
Modifié(e) : vinith le 18 Jan 2015
Yes sir, he is my coworker and a frnd, we are working on a industry project, Those orange pieces i have attached in images have different kind of defects. It includes presence of black spots, those with lesser area than normal, greater area than normal. Now the most toughest thing bothering us is the edges in the end of those pieces which is distorted or have some hair like projections. I am unable to provide you the best images but for now u can clearly view what is the problem ( i have also attached some images in which they are two components present one without any distortion at ends for your comparison). U can suggest us ways and codes to solve them
Numbers 7 and 8 aren't too bad but you would still be better off if you could put them on a little jig that has a pin sticking out that you can slip the part over. And have the background be black velvet.
img1 is lousy. If you want to view the part "end-on" then you should put the part in like a black collar so that you are looking right down the axis of the part.
I'm not sure what the hair like things are. Is that the feathery fringe on the end of the parts?
Anyway, the code I gave will find the area of the parts and the presence of black interior spots. You can use the area to determine if there is any feathery fringe on the end of the part.
Sir but using the area would force us to have very accurate threshold value which may cause unexpected errors even in correct pieces as the change in area due to that feathery fringe is very very small
If you have a high contrast image, such as using a black velvet background, the threshold does not have to be very accurate. I don't see how a textured wrinkly light blue background will avoid the threshold problem, perhaps you can explain it to me.
i will try the way you suggested sir and post my results
Do you have the images yet? If you're having trouble finding black velvet where you live, then just use black construction paper.

Connectez-vous pour commenter.

Plus de réponses (1)

Matt J
Matt J le 17 Jan 2015
Modifié(e) : Matt J le 17 Jan 2015
A=imread('http://www.mathworks.com/matlabcentral/answers/uploaded_files/24029/untitled%201.jpg');
A=rgb2gray(A);
BW=A<10;
result = imfill(BW,'holes')&~BW;

Catégories

En savoir plus sur Convert Image Type dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by