养生 装修 购物 美食 感冒 便秘 营销 加盟 小吃 火锅 管理 创业 搭配 减肥 培训 旅游

【Mathematica入门】图像填充变换

时间:2024-09-20 11:50:54

本文,用填充变换命令来处理图像。如下图,白色背景里面有几个几何图形。

【Mathematica入门】图像填充变换

工具/原料

电脑

Mathematica

方法/步骤

1、用FillingTransform命令作用于原图,得到的是一张白板:FillingTransform[img]

【Mathematica入门】图像填充变换

2、上面的效果,是白色填充踮碚牢邗了整个画面。图像配准之后,效果是:FillingTransform[img]//ImageAdjust

【Mathematica入门】图像填充变换

3、这样,可以去掉图片的白色背景:FillingTransform[img]-img

【Mathematica入门】图像填充变换

4、对上图进行填充:FillingTransform[FillingTransform[img]-img]

【Mathematica入门】图像填充变换

5、对反色图片进行填充变换:FillingTransform[1-img]

【Mathematica入门】图像填充变换

6、你会看到,上面两幅图的效果是一样的佼沣族昀:FillingTransform[1-img]-FillingTransform[FillingTransfo鸡堕樱陨rm[img]-img]Union[Flatten[ImageData[FillingTransform[1-img]-FillingTransform[FillingTransform[img]-img]]]][[1]]

【Mathematica入门】图像填充变换

© 一点知识