How to distinguish flat and non flat regions of an image?

15 views (last 30 days)
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.

Accepted Answer

Image Analyst
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.

More Answers (1)

harpreet
harpreet on 3 May 2015
Edited: harpreet on 3 May 2015
Sir the above mntioned commands didn't gave me the desired image output. I need to detect the flat region of an image, and then work upon that. For this, I have the following layout:-
FLM generation algorithm
Step 1 Initializing: FLM(i,j)=255 (denote as white) for all pixels in image. Step 2 For the n key points, pi, draw the black square taking the key point as the center and length a. An example is shown in Figure where the key points are shown in red. Step 3 Erosion and Open operators in mathematical morphology are then used to fill small holes in the image. As a result, we get the image shown in Figure (c). Step 4 Finally, we fill the closed regions with area less than A, and then get Figure (d).
Kindly suggest how to proceed for it.
  2 Comments
Image Analyst
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.
harpreet
harpreet on 3 May 2015
Edited: harpreet on 3 May 2015
An image consist of two parts, non flat and flat region. Smooth background also called flat regions which is defined as such kind of region with low frequency and/or smooth gradient. In flat regions, pixel values are similar with each other and varying smoothly over relatively large area. Examples of flat regions inan image are:- sky,grass,snow etc. An image is attached in which grass depicts the flat region
Explaination of figure 2, (posted previouslly) Figure a) Shows key-points (in red) detected using SIFT descriptor ( White portion shown here is actually the rest of the image, where key-points cannot be detected because key-points are high entropy regions so key-points can only be detected in non-flat regions and there is no key-point in flat region. This property can be used to detect flat regions )
The black squares around the key-points are drawn so that, all these squares collectively make up the non-flat region
So, in the resultant d) image we have the following:- We are left with the flat region of the image like sky or grass (which is shown white in the image just for simplicity, actually it'll be rest of the image except non-flat regions. Non-flat region is black now or in other words has been removed from the image
Now we can process upon only flat portion of the image. Sir i want to implement this idea on matlab. How should i proceed.?
P.S.-@imageAnalyst, sir i donot have that image. But i do have the research paper from which i have taken this idea. You can have a look on the attached paper.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!