interpolation of a binary map

7 次查看(过去 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

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by