Image Edge Detection Using Edge Function
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
0 votes
Share a link to this question
Accepted Answer
1 vote
9 Comments

- You can see that using thresholding to get the white didn't really perform well because there are white pixels in the bar. This is most likely due to specular reflections of your lamp off the shiny parts of your bar. You can knock these out by using a polarizer in front of your lamp and another one in front of your camrea lens that you rotate until the reflections disappear.
- Also it would be good if you can use a jig so that the bar and "holder" are in the same location in the field of view. then you could use a fixed mask to erase everything known to never be part of the bar object of interest. Make the mask a little bit larger if the bar is bent or has a different size, but the fixed mask would go a long way in getting rid of the clutter around the white holder.
- Also see if you can use a uniform background of a different color. For example if you didn't have that reddish (wood?) background, that would help. It would also help TREMENDOUSLY if you could use a different color background. For example a bright red, green, or some other vivid color. In that case, we could just use rgb2hsv() and threshold on the saturation channel to find the background. It would be SO MUCH easier.
Share a link to this comment
Share a link to this comment
Share a link to this comment
- use polarizers to get rid of the specular reflections, and
- take a picture of a blank gray sheet that fills the field of view so that you can divide the actual images by it to correct for lens shading (which you definitely have even if you don't realize it) and correct for illumination non-uniformity.
Share a link to this comment

Share a link to this comment
More Answers (1)
0 votes
Categories
Find more on Image Segmentation in Help Center and File Exchange
Products
Tags
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)