基于对象中心线和边界之间的距离重新标记像素 [英] relabeling pixels based on distance between object's centerline and boundary

查看:332
本文介绍了基于对象中心线和边界之间的距离重新标记像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含对象的二进制图像,如下图所示。该对象的中心线红色表示。对于属于该对象的每个像素,我想用颜色重新标记它。例如,与中心线的正交距离是距中心线到物体边界距离的一半的像素应标记为 blue ,否则 green 。下面给出了一个例子。有任何想法吗?
另外,我怎样才能在对象中心线高斯 >正交到它?









全分辨率图像可在以下位置找到::

  Din = bwdist(BWin); 
Dout = bwdist(BWout);

现在有两个像素强度的图像,表示距离最近的非0像素的欧氏距离。



现在减去两者,差值的一方在等距离的一边为正,在另一边为负:

  blueMask = Din-Dout> 0; 
greenMask = ~BWout& blueMask;

然后您可以使用蒙版填充RGB图层:

 结果=零(大小(II)); 
结果(:,:,1)= BWin;
结果(:,:,2)= greenMask;
结果(:,:,3)= ~blueMask& 〜Bwin的;
imshow(结果);


I've a binary image containing an object as illustrated in the figure below. The centerline of the object is depicted in red. For each pixel belonging to the object, I would like to relabel it with a color. For instance, pixels whose orthogonal distance to the centerline are half of the distance to the object boundary from the centerline, should be labeled blue, otherwise green. An illustration is given below. Any ideas? Also, how could I fit a 1D gaussian centered in the object centerline and orthogonal to it?

The image in full resolution can be found under: http://imgur.com/AUK9Hs9

解决方案

Here is what comes to mind (providing you have the Image Processing Toolbox):

Create two binary images, one BWin with 1 (true) pixels at the location of your red line, and one BWout that is the opposite of your white region (1 outisde the region and 0 (false) inside).

Like this:

BWin:

BWout:

Then apply the euclidean transform to both using bwdist:

Din = bwdist(BWin);
Dout = bwdist(BWout);

You now have two images with pixel intensities that represent the euclidean distance to the closest non-0 pixel.

Now subtract both, the values of the difference will be positive on one side of the equidistance and negative on the other side:

blueMask=Din-Dout>0;
greenMask=~BWout & blueMask;

You can then populate the RGB layer using the masks:

Result=zeros(size(II));
Result(:,:,1)=BWin;
Result(:,:,2)=greenMask;
Result(:,:,3)=~blueMask & ~BWin;
imshow(Result);

这篇关于基于对象中心线和边界之间的距离重新标记像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆