制作圆形头像

import android.content.Context;


import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ImageView;


/**
 * Created by qiangsheng on 2016/4/16.
 */
public class ImageViewDemo extends ImageView {
    public ImageViewDemo(Context context) {
        super(context);
    }
    public ImageViewDemo(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    public ImageViewDemo(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }


    @Override
    protected void onDraw(Canvas canvas) {


        Drawable drawable = getDrawable();


        if (drawable == null) {
            return;
        }


        if (getWidth() == 0 || getHeight() == 0) {
            return;
        }


        Bitmap b =  ((BitmapDrawable)drawable).getBitmap();


        if(null == b)
        {
            return;
        }


        Bitmap bitmap = b.copy(Bitmap.Config.ARGB_8888, true);


        int w = getWidth(), h = getHeight();




        Bitmap roundBitmap =  getCroppedBitmap(bitmap, w);
        canvas.drawBitmap(roundBitmap, 0,0, null);


    }


    public static Bitmap getCroppedBitmap(Bitmap bmp, int radius) {
        Bitmap sbmp;
        if(bmp.getWidth() != radius || bmp.getHeight() != radius)
            sbmp = Bitmap.createScaledBitmap(bmp, radius, radius, false);
        else
            sbmp = bmp;
        Bitmap output = Bitmap.createBitmap(sbmp.getWidth(),
                sbmp.getHeight(), Config.ARGB_8888);
        Canvas canvas = new Canvas(output);


        final int color = 0xffa19774;
        final Paint paint = new Paint();
        final Rect rect = new Rect(0, 0, sbmp.getWidth(), sbmp.getHeight());


        paint.setAntiAlias(true);
        paint.setFilterBitmap(true);
        paint.setDither(true);
        canvas.drawARGB(0, 0, 0, 0);
        paint.setColor(Color.parseColor("#BAB399"));
        canvas.drawCircle(sbmp.getWidth() / 2+0.7f, sbmp.getHeight() / 2+0.7f,
                sbmp.getWidth() / 2+0.1f, paint);
        paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
        canvas.drawBitmap(sbmp, rect, rect, paint);




        return output;

    }

}

内容概要:本文档详细介绍了如何在MATLAB环境下实现CNN-GRU(卷积门控循环单元)混合模型的多输入单输出回归预测。项目旨在通过融合CNN的局部特征提取能力和GRU的时序依赖捕捉能力,解决传统序列模型在处理非线性、高维、多输入特征数据时的局限性。文档涵盖了项目背景、目标、挑战及其解决方案,强调了模型的轻量化、高效性和可视化全流程追踪等特点。此外,还提供了具体的应用领域,如智能电网负荷预测、金融时间序列建模等,并附有详细的代码示例,包括数据加载与预处理、网络结构定义、训练选项设置、模型训练与预测以及结果可视化等步骤。; 适合人群:对深度学习有一定了解,特别是对时间序列预测感兴趣的科研人员或工程师。; 使用场景及目标:①需要处理多输入单输出的非线性回归预测任务;②希望在MATLAB平台上快速实现并优化深度学习模型;③寻求一种高效、轻量且具有良好泛化能力的预测模型应用于实际场景中,如智能电网、金融分析、交通流量预测等领域。; 阅读建议:由于文档内容涉及较多的技术细节和代码实现,建议读者先熟悉CNN和GRU的基本概念,同时掌握MATLAB的基础操作。在阅读过程中,可以结合提供的代码示例进行实践操作,以便更好地理解和掌握CNN-GRU混合模型的构建与应用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值