如何在图片中的形状周围绘制轮廓?

How to draw a contour around a shape in a picture?

如图所示,我想把我用箭头显示的部分展开,画一个等高线,有什么办法吗?

我真正想做的是把后面的矩阵展开,在上面画出正常的图

所以使用这个自定义视图作为示例

public class ViewHighLight extends View{
    final Bitmap bms; //source
    final Bitmap bmm; //mask
    final Paint paint;
    final int width = 4;
    final int color_highlight = 0xff00ff00;
    final int step = 15; // 1...45

    public ViewHighLight( Context context ){
        super( context );
        bms = BitmapFactory.decodeResource( getResources(), R.drawable.b );
        bmm = Bitmap.createBitmap( bms.getWidth(), bms.getHeight(), Bitmap.Config.ALPHA_8 );
        Canvas canvas = new Canvas( bmm );
        canvas.drawBitmap( bms,0,0, null );
        paint = new Paint( Paint.ANTI_ALIAS_FLAG );
        paint.setColor( color_highlight );
    }

    @Override
    protected void onDraw( Canvas canvas ){
        super.onDraw( canvas );

        // draw blur shadow
        for( int i = 0; i < 360; i+=step ){
            float x = width * (float)Math.cos( Math.toRadians( i ) );
            float y = width * (float)Math.sin( Math.toRadians( i ) );
            canvas.drawBitmap( bmm, x,y, paint );
        }
        //draw source bitmap on the top
        canvas.drawBitmap( bms, 0,0, null );

        //draw bitmap on the right for compare
        canvas.drawBitmap( bms, bms.getWidth(),0, null );
    }
}