matlab - Restrict interpolation to specific mask region -
i have region of image interpolate. it's surrounded zeroes, means if attempt interpolate using matlab's built-in interp2
function, boundaries of region interpolated garbage data , compromised. there known way to, example, interpolate specific set of data points (or non-rectangular matrix) , embed them matrix of correct dimensions? have logical mask can used, if helps.
images, reference:
that's simple do. use interp2
command use it. after, interpolated result, use mask 0 out garbage locations. assuming out
returned after interp2
, , mask
stores locations want restrict interpolation, do:
maskmatch = cast(mask, class(out)); %// ensures out , mask same type finalout = out .* maskmatch;
this should 0 out garbage locations while ensuring values want interpolated remain.
the above assumes output of same dimensions input. if intending expand or shrink image, can interpolate mask well, use same procedure talked about. such, run interp2
mask dimensions match out
, point-by-point multiplication talked above.
Comments
Post a Comment