interpolation of a binary map

5 ビュー (過去 30 日間)
scaramanga
scaramanga 2012 年 9 月 27 日
Hi All,
After performing a level set contour detection on an image I create a binary Map (1 on a contour, 0 otherwise). For computation efficiency, I process a downsampled image (factor 4). After Upsampling my map I no longer have a closed contour. I would like to interpolate points, what function should I use.
Let's say that my map is X and [m,n]=size(X).
Thank you

回答 (1 件)

Sean de Wolski
Sean de Wolski 2012 年 9 月 27 日
編集済み: Sean de Wolski 2012 年 9 月 27 日
You have yourself what is not necessarily an easy problem. If the contour was guaranteed to be convex it would be greatly simplified, but level-sets don't obey this.
Here is one possibility:
%%Sample image:
I = imread('cameraman.tif');
sz = size(I);
M = I<50; %map
E = bwperim(M); %edges
E = bwareaopen(E,100); %edges of big things (for example)
amp = 4; %amplification factor
bounds = bwboundaries(E); %get the boundaries
szAmp = sz*amp; %amplification size
E2 = false(szAmp); %preallocate
for ii = 1:numel(bounds)
E2 = E2 | poly2mask(bounds{ii}(:,2)*amp,bounds{ii}(:,1)*amp,szAmp(1),szAmp(2));
%Make mask out of each bounded polygon
end
E2 = bwperim(E2); %get the edge again
imtool(E2) %inspect it

Community Treasure Hunt

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

Start Hunting!

Translated by