Q:

Image segmentation based upon optical features

I have an image with some texture in a region shown in the first image. I want to segment the image based upon this texture. For this I have extracted feature as shown with blue squares (second image). I want to extract the region bound to the rectangular distribution of the features (shown by red dotted line).
Image 1:

Image 2:

Can somebody help me by suggesting some methodology to pursue this problem. Thanks

A:

This looks like it might fit the GraphCut image segmentation framework:
You want to find a binary assignment per-pixel (1 - this pixel belongs to the foreground, 0 - the pixel is part of the background). This assignment should include as many "texture locations" as  possible in the foreground, while preserving "smooth boundaries" between foreground and background.
The smoothness requirement prevents your "ideal" assignment to be 1 for the blue dots and zero everywhere else.
Now, how to search for such a binary assignment using Matlab?
Assume you have img of size H-by-W, and you have detected the locations of the texture features and stored these location in a 2-by-n matrix locs.
Setting the per-element cost:
>> bgCost = zeros( H, W );
>> bgCost( [1 H] * (locs-1) + 1 ) = 1000; %// put 1000 penalty for assigning texture dot to foreground
>> fgCost = 10*ones( H, W ); %// assign some positive penalty for assigning non-texture location to FG - prevent an "all foreground" solution.
>> fgCost( [1 H] * (locs-1) + 1 ) = 0;

Optimization:
>> lambda = 5; %// set relative weight between smoothness term and "texture" term
>> gch = GraphCut('open', cat(3, fgCost,bgCost), lambda * [0 1;1 0], 
>> [gch BW] = GraphCut('expand', gch ); %//optimization
>> gch = GraphCut('close', gch ); %//cleanup

You should get a nice binary mask in BW
>> figure;imshow( BW, [] );title('binary mask');

There are three parameters you can play with if you are not satisfied with the result BW:

the cost you assign to texture dots in the background (set to 1000 here).
the cost you assign to non-texture pixels in the foreground (set to 10 here).
the relative strength of the smoothness cost lambda.  

Try and change these values and see how they influence the resulting mask.
I use this matlab wrapper for GraphCut optimization.

