How to distinguish flat and non flat regions of an image?
15 views (last 30 days)
Show older comments
Hello, I need to distinguish flat (regions having almost same pixel values e.g.sky,grass ) and non-flat regions of an image. I don't have any idea. Kindly suggest some ideas (any algorithm or some commands) how can i do the same in MATLAB.
0 Comments
Accepted Answer
Image Analyst
on 2 May 2015
You can use stdfilt() or entropyfilt(). For example
% Get an image where the value is the std dev of a local neighborhood.
filteredImage = stdfilt(grayImage);
% Find pixels where the local standard deviation is 0
flatRegions = filteredImage == 0;
You can get relatively flat regions by using <= instead of ==
flatRegions = filteredImage <= 4; % Or whatever number you want.
0 Comments
More Answers (1)
harpreet
on 3 May 2015
Edited: harpreet
on 3 May 2015
2 Comments
Image Analyst
on 3 May 2015
Please attach the original image, not a screenshot.
What is the "flat" region? Is it all the white area? Or the red pixels inside the red discs? Or both?
And why did your algorithm give giant black squares around the red discs? I can't figure that out.
See Also
Categories
Find more on Feature Detection and Extraction in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!