Android Bitmap详解(下)之图片缓存详解
前言:
之前有出过俩篇关于bitmap相关的讲解,分别是Bitmap详解(上)常用概念和常用API和Bitmap详解(中)之像素级操作,今天主要是来一个系统的总结。
认识Bitmap:
Bitmap是Android系统中的图像处理的最重要类之一。用它可以获取图像文件信息,进行图像剪切、旋转、缩放等操作,并可以指定格式保存图像文件。
常用重要函数如下:
-
public void recycle() // 回收位图占用的内存空间,把位图标记为Dead
-
public final boolean isRecycled() //判断位图内存是否已释放
-
public final int getWidth()//获取位图的宽度
-
public final int getHeight()//获取位图的高度
-
public final boolean isMutable()//图片是否可修改
-
public int getScaledWidth(Canvas canvas)//获取指定密度转换后的图像的宽度
-
public int getScaledHeight(Canvas canvas)//获取指定密度转换后的图像的高度
-
public boolean compress(CompressFormat format, int quality, OutputStream stream)//按指定的图片格式以及画质,将图片转换为输出流。
format:Bitmap.CompressFormat.PNG或Bitmap.CompressFormat.JPEG
quality:画质,0-100.0表示最低画质压缩,100以最高画质压缩。对于PNG等无损格式的图片,会忽略此项设置。 -
public static Bitmap createBitmap(Bitmap src) //以src为原图生成不可变得新图像
-
public static Bitmap createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter)//以src为原图,创建新的图像,指定新图像的高宽以及是否可变。
-
public static Bitmap createBitmap(int width, int height, Config config)——创建指定格式、大小的位图
-
public static Bitmap createBitmap(Bitmap source, int x, int y, int width, int height)以source为原图,创建新的图片,指定起始坐标以及新图像的高宽。
BitmapFactory工厂类:
Option 参数类:
- public boolean inJustDecodeBounds//如果设置为true,不获取图片,不分配内存,但会返回图片的高度宽度信息。
- public int inSampleSize//图片缩放的倍数
- public int outWidth//获取图片的宽度值
- public int outHeight//获取图片的高度值
- public int inDensity//用于位图的像素压缩比
- public int inTargetDensity//用于目标位图的像素压缩比(要生成的位图)
- public byte[] inTempStorage //创建临时文件,将图片存储
- public boolean inScaled//设置为true时进行图片压缩,从inDensity到inTargetDensity
- public boolean inDither //如果为true,解码器尝试抖动解码
- public Bitmap.Config inPreferredConfig //设置解码器
- public String outMimeType //设置解码图像
- public boolean inPurgeable//当存储Pixel的内存空间在系统内存不足时是否可以被回收
- public boolean inInputShareable //inPurgeable为true情况下才生效,是否可以共享一个InputStream
- public boolean inPreferQualityOverSpeed //为true则优先保证Bitmap质量其次是解码速度
- public boolean inMutable //配置Bitmap是否可以更改,比如:在Bitmap上隔几个像素加一条线段
- public int inScreenDensity //当前屏幕的像素密度
工厂方法:
- public static Bitmap decodeByteArray(byte[] data, int offset, int length) //从数组读取图片
- public static Bitmap decodeByteArray(byte[] data, int offset, int length, Options opts)
- public static Bitmap decodeFileDescriptor(FileDescriptor fd)//从文件读取文件 与decodeFile不同的是这个直接调用JNI函数进行读取 效率比较高
- public static Bitmap decodeFileDescriptor(FileDescriptor fd, Rect outPadding, Options opts)
- public static Bitmap decodeFile(String pathName, Options opts) //从文件读取图片
- public static Bitmap decodeFile(String pathName)
- public static Bitmap decodeStream(InputStream is) //从输入流读取图片
- public static Bitmap decodeStream(InputStream is, Rect outPadding, Options opts)
- public static Bitmap decodeResource(Resources res, int id) //从资源文件读取图片
- public static Bitmap decodeResource(Resources res, int id, Options opts)
Bitmap.Config inPreferredConfig :
枚举变量 (位图位数越高代表其可以存储的颜色信息越多,图像越逼真,占用内存越大)
- public static final Bitmap.Config ALPHA_8 //代表8位Alpha位图 每个像素占用1byte内存
- public static final Bitmap.Config ARGB_4444 //代表16位ARGB位图 每个像素占用2byte内存
- public static final Bitmap.Config ARGB_8888 //代表32位ARGB位图 每个像素占用4byte内存
- public static final Bitmap.Config RGB_565 //代表8位RGB位图 每个像素占用2byte内存
Android中一张图片(BitMap)占用的内存主要和以下几个因数有关:图片长度,图片宽度,单位像素占用的字节数。一张图片(BitMap)占用的内存=图片长度图片宽度单位像素占用的字节数。
图片读取实例:
- 从文件读取方式一
/*** 获取缩放后的本地图片** @param filePath 文件路径* @param width 宽* @param height 高* @return*/public static Bitmap readBitmapFromFile(String filePath, int width, int height) {BitmapFactory.Options options = new BitmapFactory.Options();options.inJustDecodeBounds = true;BitmapFactory.decodeFile(filePath, options);float srcWidth = options.outWidth;float srcHeight = options.outHeight;int inSampleSize = 1;if (srcHeight > height || srcWidth > width) {if (srcWidth > srcHeight) {inSampleSize = Math.round(srcHeight / height);} else {inSampleSize = Math.round(srcWidth / width);}}options.inJustDecodeBounds = false;options.inSampleSize = inSampleSize;return BitmapFactory.decodeFile(filePath, options);}
- 从文件读取方式二 效率高于方式一
/*** 获取缩放后的本地图片** @param filePath 文件路径* @param width 宽* @param height 高* @return*/public static Bitmap readBitmapFromFileDescriptor(String filePath, int width, int height) {try {FileInputStream fis = new FileInputStream(filePath);BitmapFactory.Options options = new BitmapFactory.Options();options.inJustDecodeBounds = true;BitmapFactory.decodeFileDescriptor(fis.getFD(), null, options);float srcWidth = options.outWidth;float srcHeight = options.outHeight;int inSampleSize = 1;if (srcHeight > height || srcWidth > width) {if (srcWidth > srcHeight) {inSampleSize = Math.round(srcHeight / height);} else {inSampleSize = Math.round(srcWidth / width);}}options.inJustDecodeBounds = false;options.inSampleSize = inSampleSize;return BitmapFactory.decodeFileDescriptor(fis.getFD(), null, options);} catch (Exception ex) {}return null;}
- 从输入流中读取文件
/*** 获取缩放后的本地图片** @param ins 输入流* @param width 宽* @param height 高* @return*/public static Bitmap readBitmapFromInputStream(InputStream ins, int width, int height) {BitmapFactory.Options options = new BitmapFactory.Options();options.inJustDecodeBounds = true;BitmapFactory.decodeStream(ins, null, options);float srcWidth = options.outWidth;float srcHeight = options.outHeight;int inSampleSize = 1;if (srcHeight > height || srcWidth > width) {if (srcWidth > srcHeight) {inSampleSize = Math.round(srcHeight / height);} else {inSampleSize = Math.round(srcWidth / width);}}options.inJustDecodeBounds = false;options.inSampleSize = inSampleSize;return BitmapFactory.decodeStream(ins, null, options);}
- 从资源文件中读取文件
public static Bitmap readBitmapFromResource(Resources resources, int resourcesId, int width, int height) {BitmapFactory.Options options = new BitmapFactory.Options();options.inJustDecodeBounds = true;BitmapFactory.decodeResource(resources, resourcesId, options);float srcWidth = options.outWidth;float srcHeight = options.outHeight;int inSampleSize = 1;if (srcHeight > height || srcWidth > width) {if (srcWidth > srcHeight) {inSampleSize = Math.round(srcHeight / height);} else {inSampleSize = Math.round(srcWidth / width);}}options.inJustDecodeBounds = false;options.inSampleSize = inSampleSize;return BitmapFactory.decodeResource(resources, resourcesId, options);}
- 从二进制数据读取图片
public static Bitmap readBitmapFromByteArray(byte[] data, int width, int height) {BitmapFactory.Options options = new BitmapFactory.Options();options.inJustDecodeBounds = true;BitmapFactory.decodeByteArray(data, 0, data.length, options);float srcWidth = options.outWidth;float srcHeight = options.outHeight;int inSampleSize = 1;if (srcHeight > height || srcWidth > width) {if (srcWidth > srcHeight) {inSampleSize = Math.round(srcHeight / height);} else {inSampleSize = Math.round(srcWidth / width);}}options.inJustDecodeBounds = false;options.inSampleSize = inSampleSize;return BitmapFactory.decodeByteArray(data, 0, data.length, options);}
- 从assets文件读取图片
/*** 获取缩放后的本地图片** @param filePath 文件路径* @return*/public static Bitmap readBitmapFromAssetsFile(Context context, String filePath) {Bitmap image = null;AssetManager am = context.getResources().getAssets();try {InputStream is = am.open(filePath);image = BitmapFactory.decodeStream(is);is.close();} catch (IOException e) {e.printStackTrace();}return image;}
图片保存文件:
public static void writeBitmapToFile(String filePath, Bitmap b, int quality) {try {File desFile = new File(filePath);FileOutputStream fos = new FileOutputStream(desFile);BufferedOutputStream bos = new BufferedOutputStream(fos);b.compress(Bitmap.CompressFormat.JPEG, quality, bos);bos.flush();bos.close();} catch (IOException e) {e.printStackTrace();}}
图片压缩:
private static Bitmap compressImage(Bitmap image) {if (image == null) {return null;}ByteArrayOutputStream baos = null;try {baos = new ByteArrayOutputStream();image.compress(Bitmap.CompressFormat.JPEG, 100, baos);byte[] bytes = baos.toByteArray();ByteArrayInputStream isBm = new ByteArrayInputStream(bytes);Bitmap bitmap = BitmapFactory.decodeStream(isBm);return bitmap;} catch (OutOfMemoryError e) {} finally {try {if (baos != null) {baos.close();}} catch (IOException e) {}}return null;}
图片缩放:
/*** 根据scale生成一张图片** @param bitmap* @param scale 等比缩放值* @return*/public static Bitmap bitmapScale(Bitmap bitmap, float scale) {Matrix matrix = new Matrix();matrix.postScale(scale, scale); // 长和宽放大缩小的比例Bitmap resizeBmp = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);return resizeBmp;}
获取图片旋转角度:
/*** 读取照片exif信息中的旋转角度** @param path 照片路径* @return角度*/private static int readPictureDegree(String path) {if (TextUtils.isEmpty(path)) {return 0;}int degree = 0;try {ExifInterface exifInterface = new ExifInterface(path);int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);switch (orientation) {case ExifInterface.ORIENTATION_ROTATE_90:degree = 90;break;case ExifInterface.ORIENTATION_ROTATE_180:degree = 180;break;case ExifInterface.ORIENTATION_ROTATE_270:degree = 270;break;}} catch (Exception e) {}return degree;}
图片旋转角度:
private static Bitmap rotateBitmap(Bitmap b, float rotateDegree) {if (b == null) {return null;}Matrix matrix = new Matrix();matrix.postRotate(rotateDegree);Bitmap rotaBitmap = Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), matrix, true);return rotaBitmap;}
图片转二进制:
public byte[] bitmap2Bytes(Bitmap bm) {ByteArrayOutputStream baos = new ByteArrayOutputStream();bm.compress(Bitmap.CompressFormat.PNG, 100, baos);return baos.toByteArray();}
Bitmap转Drawable
public static Drawable bitmapToDrawable(Resources resources, Bitmap bm) {Drawable drawable = new BitmapDrawable(resources, bm);return drawable;}
Drawable转Bitmap
public static Bitmap drawableToBitmap(Drawable drawable) {Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);Canvas canvas = new Canvas(bitmap);drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());drawable.draw(canvas);return bitmap;}
Drawable、Bitmap占用内存比较
之前一直使用过Afinal 和Xutils 熟悉这两框架的都知道,两者出自同一人,Xutils是Afina的升级版,AFinal中的图片内存缓存使用的是Bitmap 而后来为何Xutils将内存缓存的对象改成了Drawable了呢?我们一探究竟。下面写个测试程序做个验证。
List bitmaps = new ArrayList<>();start = System.currentTimeMillis();for (int i = 0; i < testMaxCount; i++) {Bitmap bitmap = BitmapUtils.readBitMap(this, R.mipmap.ic_app_center_banner);bitmaps.add(bitmap);Log.e(TAG, "BitmapFactory Bitmap--num-->" + i);}end = System.currentTimeMillis();Log.e(TAG, "BitmapFactory Bitmap--time-->" + (end - start));List drawables = new ArrayList<>();start = System.currentTimeMillis();for (int i = 0; i < testMaxCount; i++) {Drawable drawable = getResources().getDrawable(R.mipmap.ic_app_center_banner);drawables.add(drawable);Log.e(TAG, "BitmapFactory Drawable--num-->" + i);}end = System.currentTimeMillis();Log.e(TAG, "BitmapFactory Drawable--time-->" + (end - start));
测试结果大家可以自行验证,从我本人测试结果来看,相同的1000张图片,Bitmap 直接70条数据的时候挂掉,而Drawable 轻松1000条数据通过。
从测试说明Drawable 相对Bitmap有很大的内存占用优势。这也是为啥现在主流的图片缓存框架内存缓存那一层采用Drawable作为缓存对象的原因。
总结:
- 了解Bitmap常用api方法可以很好的有助于与我们平时开发过程中对图片做出优化处理,从而满足我们的需求同时保证了app的流畅性
- 测试说明Drawable 相对Bitmap有很大的内存占用优势。这也是为啥现在主流的图片缓存框架内存缓存那一层采用Drawable作为缓存对象的原因。因此我们要合理灵活使用Drawable和Bitmap。
相关文章:
Android Bitmap详解(下)之图片缓存详解
前言: 之前有出过俩篇关于bitmap相关的讲解,分别是Bitmap详解(上)常用概念和常用API和Bitmap详解(中)之像素级操作,今天主要是来一个系统的总结。 认识Bitmap: Bitmap是Android系统中的图像处理的最重要类之一。用它可以获取图像…...
020-从零搭建微服务-认证中心(九)
写在最前 如果这个项目让你有所收获,记得 Star 关注哦,这对我是非常不错的鼓励与支持。 源码地址(后端):https://gitee.com/csps/mingyue 源码地址(前端):https://gitee.com/csps…...
孤注一掷中的黑客技术
最近孤注一掷电影很火,诈骗团伙的骗术实在厉害,就连电影中的黑客潘生都未能幸免。电影中的陆经理说:不是我们坏, 是他们贪。这句话我觉得有一部分是对的,诈骗分子抓住了人的本性贪婪,才使得被骗的人逐步走向…...
机器学习笔记 - PyTorch Image Models图像模型概览 (timm)
一、简述 PyTorch Image Models (timm)是一个用于最先进的图像分类的库,包含图像模型、优化器、调度器、增强等的集合;是比较热门的论文及代码库。 虽然越来越多的低代码和无代码解决方案可以轻松开始将深度学习应用于计算机视觉问题,但我们经常与希望寻求定制解决方案的客户…...
Java 实现证件照底图替换,Java 实现照片头像底图替换
效果图 这里前端用layui实现的案例截图 color底图颜色可以在网页上这样取色 new Color(34, 133, 255) 实现案例下载链接:https://download.csdn.net/download/weixin_43992507/88237432...
周易卦爻解读笔记——未济
第六十四卦未济 火水未济 离上坎下 未济卦由否卦所变,否卦六二与九五换位,象征尚未完成。 天地否 未济卦和既济卦既是错卦又是覆卦,这也是最后一卦,序卦传【物不可穷也,故受之以未济终焉】 未济卦象征尚未完成&…...
AI 绘画Stable Diffusion 研究(十三)SD数字人制作工具SadTlaker使用教程
免责声明: 本案例所用安装包免费提供,无任何盈利目的。 大家好,我是风雨无阻。 想必大家经常看到,无论是在产品营销还是品牌推广时,很多人经常以数字人的方式来为自己创造财富。而市面上的数字人收费都比较昂贵,少则几…...
伦敦金走势图行情值得关注
不知道大家是否了解过伦敦金这个投资品种,或者有否财经网站以及金融终端上看到过它的行情走势图。其实,伦敦金并不是一种实实在在的黄金,而是一种跟踪伦敦现货黄金市场价格走势的黄金保证金交易品种,它每天的行情走势变化…...
机器学习之数据清洗
一、介绍 数据清洗是机器学习中的一个重要步骤,它涉及对原始数据进行预处理和修复,以使数据适用于机器学习算法的训练和分析。数据清洗的目标是处理数据中的噪声、缺失值、异常值和不一致性等问题,以提高数据的质量和准确性。 二、方法 处理…...
T599聚合物电容器:在汽车应用中提供更长的使用寿命的解决方案
自从电子技术被引入汽车工业以来,汽车的技术含量一直在提升。诸多技术被应用在汽车上,使汽车的形象更接近于轮子上的超级计算机。更多传感器、更强大的计算能力和电力被装载到汽车上,汽车应用中的电子产品数量正在迅速增长。随着电动汽车和自…...
学习ts(五)类
定义 是面向对象程序设计(OOP)实现信息封装的基础 类是一种用户定义的引用数据类型,也称类类型 JavaScript的class,虽然本质是构造函数,但是使用起来已经方便了许多,js中没有加入修饰符和抽象类等特性 ts的class支持面…...
EasyImage简单图床 - 快速搭建私人图床云盘同时远程访问【无公网IP内网穿透】
憧憬blog主页 在强者的眼中,没有最好,只有更好。我们是移动开发领域的优质创作者,同时也是阿里云专家博主。 ✨ 关注我们的主页,探索iOS开发的无限可能! 🔥我们与您分享最新的技术洞察和实战经验࿰…...
从SVG到Canvas:选择最适合你的Web图形技术
SVG 和 Canvas 都是可以在 Web 浏览器中绘制图形的技术。 众所周知, icon 通常使用 svg(如 iconfont),而交互式游戏采用 Canvas。二者具体的区别是什么?该如何选择? 声明式还是命令式?绘制的图形…...
基于 Redis 实现分布式限流
基于 Redis 实现分布式限流 一、 简介二、分布式限流1 数据结构1.1 Redis List1.2 Redis Set1.3 Redis Sorted Set 2 实现分布式限流3 实现原理分析 三、分布式限流算法1. 计数器算法2. 漏斗算法3. 令牌桶算法 四、分布式限流实战1. 单机限流实现2. 基于Redis Clusters的分布式…...
前端下载文件方式(Blob)
以下以下载图标svg文件为例,实现点击按钮下载文件,其中icon结构如下: const DownloadSvg (props) > {function download(downfile) {const tmpLink document.createElement("a");const objectUrl URL.createObjectURL(downfi…...
【STM32】FreeRTOS软件定时器学习
软件定时器 FreeRTOS提供了现成的软件定时器功能,可以一定程度上替代硬件定时器,但精度不高。 实验:创建一个任务,两个定时器,按键开启定时器,一个500ms打印一次,一个1000ms打印一次。 实现&…...
【LeetCode】复写零
复写零 题目描述算法描述编程代码 链接: 复写零 题目描述 算法描述 编程代码 class Solution { public:void duplicateZeros(vector<int>& arr) {int n arr.size();int dest -1,cur 0;while(cur < n){if(arr[cur]){dest;}else{dest2;}cur;if(dest > n-1){…...
使用docker-maven-plugin插件构建镜像并推送至私服Harbor
前言 如下所示,建议使用 Dockerfile Maven 插件,但该插件也停止维护更新了。因此先暂时使用docker-maven-plugin插件。 一、开启Docker服务器的远程访问 1.1 开启2375远程访问 默认的dokcer是不支持远程访问的,需要加点配置,开…...
YOLO目标检测——动漫头像数据集下载分享
动漫头像数据集是用于研究和分析动漫头像相关问题的数据集,它包含了大量的动漫风格的头像图像。动漫头像是指以动漫风格绘制的虚构人物的头像图像,常见于动画、漫画、游戏等媒体。 数据集点击下载:YOLO动漫头像数据集50800图片.rar...
学习Vue:Vue3 VS Vue2
Vue 3作为Vue.js的最新版本,带来了一系列令人激动的新特性和改进,让开发者们在构建现代Web应用时体验更加顺畅和高效。本文将全面介绍Vue 3相对于Vue 2的改进,重点解释Composition API的使用,以及新引入的Teleport和Suspense等特性…...
MPNet:旋转机械轻量化故障诊断模型详解python代码复现
目录 一、问题背景与挑战 二、MPNet核心架构 2.1 多分支特征融合模块(MBFM) 2.2 残差注意力金字塔模块(RAPM) 2.2.1 空间金字塔注意力(SPA) 2.2.2 金字塔残差块(PRBlock) 2.3 分类器设计 三、关键技术突破 3.1 多尺度特征融合 3.2 轻量化设计策略 3.3 抗噪声…...
stm32G473的flash模式是单bank还是双bank?
今天突然有人stm32G473的flash模式是单bank还是双bank?由于时间太久,我真忘记了。搜搜发现,还真有人和我一样。见下面的链接:https://shequ.stmicroelectronics.cn/forum.php?modviewthread&tid644563 根据STM32G4系列参考手…...
UE5 学习系列(三)创建和移动物体
这篇博客是该系列的第三篇,是在之前两篇博客的基础上展开,主要介绍如何在操作界面中创建和拖动物体,这篇博客跟随的视频链接如下: B 站视频:s03-创建和移动物体 如果你不打算开之前的博客并且对UE5 比较熟的话按照以…...
python爬虫:Newspaper3k 的详细使用(好用的新闻网站文章抓取和解析的Python库)
更多内容请见: 爬虫和逆向教程-专栏介绍和目录 文章目录 一、Newspaper3k 概述1.1 Newspaper3k 介绍1.2 主要功能1.3 典型应用场景1.4 安装二、基本用法2.2 提取单篇文章的内容2.2 处理多篇文档三、高级选项3.1 自定义配置3.2 分析文章情感四、实战案例4.1 构建新闻摘要聚合器…...
工业自动化时代的精准装配革新:迁移科技3D视觉系统如何重塑机器人定位装配
AI3D视觉的工业赋能者 迁移科技成立于2017年,作为行业领先的3D工业相机及视觉系统供应商,累计完成数亿元融资。其核心技术覆盖硬件设计、算法优化及软件集成,通过稳定、易用、高回报的AI3D视觉系统,为汽车、新能源、金属制造等行…...
【论文阅读28】-CNN-BiLSTM-Attention-(2024)
本文把滑坡位移序列拆开、筛优质因子,再用 CNN-BiLSTM-Attention 来动态预测每个子序列,最后重构出总位移,预测效果超越传统模型。 文章目录 1 引言2 方法2.1 位移时间序列加性模型2.2 变分模态分解 (VMD) 具体步骤2.3.1 样本熵(S…...
Spring Cloud Gateway 中自定义验证码接口返回 404 的排查与解决
Spring Cloud Gateway 中自定义验证码接口返回 404 的排查与解决 问题背景 在一个基于 Spring Cloud Gateway WebFlux 构建的微服务项目中,新增了一个本地验证码接口 /code,使用函数式路由(RouterFunction)和 Hutool 的 Circle…...
让回归模型不再被异常值“带跑偏“,MSE和Cauchy损失函数在噪声数据环境下的实战对比
在机器学习的回归分析中,损失函数的选择对模型性能具有决定性影响。均方误差(MSE)作为经典的损失函数,在处理干净数据时表现优异,但在面对包含异常值的噪声数据时,其对大误差的二次惩罚机制往往导致模型参数…...
深入浅出深度学习基础:从感知机到全连接神经网络的核心原理与应用
文章目录 前言一、感知机 (Perceptron)1.1 基础介绍1.1.1 感知机是什么?1.1.2 感知机的工作原理 1.2 感知机的简单应用:基本逻辑门1.2.1 逻辑与 (Logic AND)1.2.2 逻辑或 (Logic OR)1.2.3 逻辑与非 (Logic NAND) 1.3 感知机的实现1.3.1 简单实现 (基于阈…...
基于IDIG-GAN的小样本电机轴承故障诊断
目录 🔍 核心问题 一、IDIG-GAN模型原理 1. 整体架构 2. 核心创新点 (1) 梯度归一化(Gradient Normalization) (2) 判别器梯度间隙正则化(Discriminator Gradient Gap Regularization) (3) 自注意力机制(Self-Attention) 3. 完整损失函数 二…...
