EmguCV调用函数实现图片选择

本文介绍了如何使用EmguCV库来处理图片,特别是针对初学者,通过调用特定函数实现图片的旋转操作,避免了复杂的图片类型转换,简化了学习过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

开学的第一个任务,要学习使用EmguCV来处理图片(大概就是EmguCV从入门到放弃的节奏)。索性之前有OpenCV的经验,EmguCV上手起来也不算太困难。

第一个目标是完成对一张图片的旋转。网上有很多旋转教程,但国内的大多数都是在算法层次进行旋转,用到了各种图片类型的转换(Image<>,BitMap Mlplptr等等)。对于一个刚上手学习的新人来说是极其不友好的。幸好在墙的另一边我找到了答案(文明,民主,富强,爱国)。在EmguCV中有这样的一个函数

public Image<TColor, TDepth> Rotate(double angle, TColor background, bool crop);
public Image<TColor, TDepth> Rotate(double angle, PointF center, INTER interpolationMethod, TColor background, bool crop);
// 参数: 
        //   angle:
        //     The angle of rotation in degrees. Positive means clockwise.
        //
        //   background:
        //     The color with wich to fill the background
        //
        //   crop:
        //     If set to true the image is cropped to its original size, possibly losing
        //     corners information. If set to false the result image has different size
        //     than original and all rotation information is preserved
        //
        //   center:
        //     The center of rotation
        //
        //   interpolationMethod:
        //     The intepolation method
        //
        // 返回结果: 
        //     The rotated image
具体的用法示例

private Image<Bgr, byte> rotate(Image<Bgr, byte> image,double angle)
        {
            if (image != null)
            {
                Image<Bgr, byte> rotateImage = image.Rotate(angle, new Bgr(System.Drawing.Color.White), false);
                return rotateImage;
            }
            return null;
        }

旋转前:


旋转 30度后





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值