MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   如何在MATLAB中反转二进制图像? (https://www.labfans.com/bbs/showthread.php?t=26575)

poster 2019-12-14 20:13

如何在MATLAB中反转二进制图像?
 
我有一个二进制图像,需要将所有黑色像素转换为白色像素,反之亦然。然后,我需要将新图像保存到文件中。有没有一种方法,而不必简单地遍历每个像素并翻转其值?



[B]回答:[/B]

如果您的二进制图像binImage只有零和一,则有许多简单的方法可以将其反转:

binImage = ~binImage; binImage = 1-binImage; binImage = (binImage == 0); 然后只需使用功能[URL="http://www.mathworks.com/help/techdoc/ref/imwrite.html"]IMWRITE[/URL]保存反转的图像。



[url=https://stackoverflow.com/questions/5277005]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 09:01

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.