# 2D interpolation in a specific region in a given image

4 views (last 30 days)
Yuzhen Lu on 8 Jan 2017
Commented: Image Analyst on 8 Jan 2017

I am going to perform two-dimensional (2D) interpolation in a region of interest (ROI) in an image as shown below.

*This image contains two ROIs as enclosed by two colored solid lines. The interpolation is conducted in these regions based on knowledge of the region outside the ROI. In using interp2(x,y,z,xi,yi,'method'), x,y,z are required to be matrices. In either of the two cases, how to construct the matrices?

In the case of the rectangular ROI, e.g., the xi and yi are easy to obtain, but how to form x, y and z, noting that the matrix or grid vectors should be strictly monotonic increasing in coordinate values.

Without the interpolation method, is there any other way to estimated values in the ROI based on values outside the ROI, assuming no abrupt changes?

Image Analyst on 8 Jan 2017
I believe you are asking for what the regionfill() function does. You can get a binary mask from poly2mask() if all you have is coordinates of the colored lines.
##### 2 CommentsShowHide 1 older comment
Image Analyst on 8 Jan 2017
The assumption is that you don't know anything about the interior so the replacement/guessed pixel value is a weighted sum of pixels around the border. Of course it may be wrong if you know what's inside. Let's say you had a picture of a cat or a face or virtually anything else. There is no way you could know what's inside if all you have is what's around the border. If you know what's inside then you can do better. So if you knew for a fact that what was inside is a linear gradient in the column/x direction and a uniform value in the row/x direction, then you could easily develop an algorithm to just extend the top row of the hole's perimeter down to the bottom row of the hole. But since you required "Without the interpolation method, is there any other way to estimated values in the ROI based on values outside the ROI, assuming no abrupt changes?", that meant that we could not assume such a combination linear gradient that we know exists. And since we don't know that, a weighted sum of the boundaries, knowing nothing whatsoever about the interior, is about as good a guess as you can make.

### Categories

Find more on ROI-Based Processing in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!