C# OpenCvSharp DNN Low Light image Enhancement

这篇具有很好参考价值的文章主要介绍了C# OpenCvSharp DNN Low Light image Enhancement。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

目录

介绍

效果

模型信息

项目

代码

下载


C# OpenCvSharp DNN Low Light image Enhancement

介绍

github地址:https://github.com/zhenqifu/PairLIE

C# OpenCvSharp DNN Low Light image Enhancement,C#人工智能实践,dnn,人工智能,神经网络,机器学习,计算机视觉,深度学习,c#  

效果

C# OpenCvSharp DNN Low Light image Enhancement,C#人工智能实践,dnn,人工智能,神经网络,机器学习,计算机视觉,深度学习,c#

C# OpenCvSharp DNN Low Light image Enhancement,C#人工智能实践,dnn,人工智能,神经网络,机器学习,计算机视觉,深度学习,c#

模型信息

 Model Properties
-------------------------
---------------------------------------------------------------

Inputs
-------------------------
name:input
tensor:Float[1, 3, 512, 512]
name:exposure
tensor:Float[1]
---------------------------------------------------------------

Outputs
-------------------------
name:output
tensor:Float[1, 3, 512, 512]
---------------------------------------------------------------
 

项目

C# OpenCvSharp DNN Low Light image Enhancement,C#人工智能实践,dnn,人工智能,神经网络,机器学习,计算机视觉,深度学习,c#

代码

using OpenCvSharp;
using OpenCvSharp.Dnn;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Numerics;
using System.Reflection;
using System.Windows.Forms;

namespace OpenCvSharp_DNN_Demo
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        string fileFilter = "*.*|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";
        string image_path = "";

        DateTime dt1 = DateTime.Now;
        DateTime dt2 = DateTime.Now;

        string modelpath;

        int inpHeight;
        int inpWidth;

        Net opencv_net;
        Mat BN_image;

        Mat image;
        Mat result_image;

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = fileFilter;
            if (ofd.ShowDialog() != DialogResult.OK) return;

            pictureBox1.Image = null;
            pictureBox2.Image = null;
            textBox1.Text = "";

            image_path = ofd.FileName;
            pictureBox1.Image = new Bitmap(image_path);
            image = new Mat(image_path);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            modelpath = "model/pairlie_512x512.onnx";

            inpHeight = 512;
            inpWidth = 512;

            opencv_net = CvDnn.ReadNetFromOnnx(modelpath);

            image_path = "test_img/1.png";
            pictureBox1.Image = new Bitmap(image_path);

        }

        private unsafe void button2_Click(object sender, EventArgs e)
        {
            if (image_path == "")
            {
                return;
            }
            textBox1.Text = "检测中,请稍等……";
            pictureBox2.Image = null;
            Application.DoEvents();

            image = new Mat(image_path);

            int srch = image.Rows;
            int srcw = image.Cols;

            BN_image = CvDnn.BlobFromImage(image, 1 / 255.0, new OpenCvSharp.Size(inpWidth, inpHeight), new Scalar(0, 0, 0), true, false);

            opencv_net.SetInput(BN_image, "input");

            Mat one = new Mat(1,1,MatType.CV_32F,new float[] { 0.5f});
            Mat exposure = CvDnn.BlobFromImage(one);

            opencv_net.SetInput(exposure, "exposure");

            //模型推理,读取推理结果
            Mat[] outs = new Mat[1] { new Mat() };
            string[] outBlobNames = opencv_net.GetUnconnectedOutLayersNames().ToArray();

            dt1 = DateTime.Now;

            opencv_net.Forward(outs, outBlobNames);

            dt2 = DateTime.Now;

            float* pdata = (float*)outs[0].Data;
            int out_h = outs[0].Size(2);
            int out_w = outs[0].Size(3);
            int channel_step = out_h * out_w;
            float[] data = new float[channel_step * 3];
            for (int i = 0; i < data.Length; i++)
            {
                data[i] = pdata[i] * 255;

                if (data[i] < 0)
                {
                    data[i] = 0;
                }
                else if (data[i] > 255)
                {
                    data[i] = 255;
                }
            }

            float[] temp_r = new float[out_h * out_w];
            float[] temp_g = new float[out_h * out_w];
            float[] temp_b = new float[out_h * out_w];

            Array.Copy(data, temp_r, out_h * out_w);
            Array.Copy(data, out_h * out_w, temp_g, 0, out_h * out_w);
            Array.Copy(data, out_h * out_w * 2, temp_b, 0, out_h * out_w);

            Mat rmat = new Mat(out_h, out_w, MatType.CV_32F, temp_r);
            Mat gmat = new Mat(out_h, out_w, MatType.CV_32F, temp_g);
            Mat bmat = new Mat(out_h, out_w, MatType.CV_32F, temp_b);

            result_image = new Mat();
            Cv2.Merge(new Mat[] { bmat, gmat, rmat }, result_image);

            result_image.ConvertTo(result_image, MatType.CV_8UC3);

            Cv2.Resize(result_image, result_image, new OpenCvSharp.Size(srcw, srch));

            pictureBox2.Image = new Bitmap(result_image.ToMemoryStream());
            textBox1.Text = "推理耗时:" + (dt2 - dt1).TotalMilliseconds + "ms";
        }

        private void pictureBox2_DoubleClick(object sender, EventArgs e)
        {
            Common.ShowNormalImg(pictureBox2.Image);
        }

        private void pictureBox1_DoubleClick(object sender, EventArgs e)
        {
            Common.ShowNormalImg(pictureBox1.Image);
        }
    }
}

using OpenCvSharp;
using OpenCvSharp.Dnn;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Numerics;
using System.Reflection;
using System.Windows.Forms;

namespace OpenCvSharp_DNN_Demo
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        string fileFilter = "*.*|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";
        string image_path = "";

        DateTime dt1 = DateTime.Now;
        DateTime dt2 = DateTime.Now;

        string modelpath;

        int inpHeight;
        int inpWidth;

        Net opencv_net;
        Mat BN_image;

        Mat image;
        Mat result_image;

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = fileFilter;
            if (ofd.ShowDialog() != DialogResult.OK) return;

            pictureBox1.Image = null;
            pictureBox2.Image = null;
            textBox1.Text = "";

            image_path = ofd.FileName;
            pictureBox1.Image = new Bitmap(image_path);
            image = new Mat(image_path);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            modelpath = "model/pairlie_512x512.onnx";

            inpHeight = 512;
            inpWidth = 512;

            opencv_net = CvDnn.ReadNetFromOnnx(modelpath);

            image_path = "test_img/1.png";
            pictureBox1.Image = new Bitmap(image_path);

        }

        private unsafe void button2_Click(object sender, EventArgs e)
        {
            if (image_path == "")
            {
                return;
            }
            textBox1.Text = "检测中,请稍等……";
            pictureBox2.Image = null;
            Application.DoEvents();

            image = new Mat(image_path);

            int srch = image.Rows;
            int srcw = image.Cols;

            BN_image = CvDnn.BlobFromImage(image, 1 / 255.0, new OpenCvSharp.Size(inpWidth, inpHeight), new Scalar(0, 0, 0), true, false);

            opencv_net.SetInput(BN_image, "input");

            Mat one = new Mat(1,1,MatType.CV_32F,new float[] { 0.5f});
            Mat exposure = CvDnn.BlobFromImage(one);

            opencv_net.SetInput(exposure, "exposure");

            //模型推理,读取推理结果
            Mat[] outs = new Mat[1] { new Mat() };
            string[] outBlobNames = opencv_net.GetUnconnectedOutLayersNames().ToArray();

            dt1 = DateTime.Now;

            opencv_net.Forward(outs, outBlobNames);

            dt2 = DateTime.Now;

            float* pdata = (float*)outs[0].Data;
            int out_h = outs[0].Size(2);
            int out_w = outs[0].Size(3);
            int channel_step = out_h * out_w;
            float[] data = new float[channel_step * 3];
            for (int i = 0; i < data.Length; i++)
            {
                data[i] = pdata[i] * 255;

                if (data[i] < 0)
                {
                    data[i] = 0;
                }
                else if (data[i] > 255)
                {
                    data[i] = 255;
                }
            }

            float[] temp_r = new float[out_h * out_w];
            float[] temp_g = new float[out_h * out_w];
            float[] temp_b = new float[out_h * out_w];

            Array.Copy(data, temp_r, out_h * out_w);
            Array.Copy(data, out_h * out_w, temp_g, 0, out_h * out_w);
            Array.Copy(data, out_h * out_w * 2, temp_b, 0, out_h * out_w);

            Mat rmat = new Mat(out_h, out_w, MatType.CV_32F, temp_r);
            Mat gmat = new Mat(out_h, out_w, MatType.CV_32F, temp_g);
            Mat bmat = new Mat(out_h, out_w, MatType.CV_32F, temp_b);

            result_image = new Mat();
            Cv2.Merge(new Mat[] { bmat, gmat, rmat }, result_image);

            result_image.ConvertTo(result_image, MatType.CV_8UC3);

            Cv2.Resize(result_image, result_image, new OpenCvSharp.Size(srcw, srch));

            pictureBox2.Image = new Bitmap(result_image.ToMemoryStream());
            textBox1.Text = "推理耗时:" + (dt2 - dt1).TotalMilliseconds + "ms";
        }

        private void pictureBox2_DoubleClick(object sender, EventArgs e)
        {
            Common.ShowNormalImg(pictureBox2.Image);
        }

        private void pictureBox1_DoubleClick(object sender, EventArgs e)
        {
            Common.ShowNormalImg(pictureBox1.Image);
        }
    }
}

下载

源码下载

 文章来源地址https://www.toymoban.com/news/detail-832255.html

到了这里,关于C# OpenCvSharp DNN Low Light image Enhancement的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Low-Light Image Enhancement via Stage-Transformer-Guided Network 论文阅读笔记

    这是TCSVT 2023年的一篇暗图增强的论文 文章的核心思想是,暗图有多种降质因素,单一stage的model难以实现多降质因素的去除,因此需要一个multi-stage的model,文章中设置了4个stage。同时提出了用预设query向量来代表不同的降质因素,对原图提取的key 和value进行注意力的方法。

    2024年02月16日
    浏览(29)
  • Progressive Dual-Branch Network for Low-Light Image Enhancement 论文阅读笔记

    这是22年中科院2区期刊的一篇有监督暗图增强的论文 网络结构如下图所示: ARM模块如下图所示: CAB模块如下图所示: LKA模块其实就是放进去了一些大卷积核: AFB模块如下图所示: 这些网络结构没什么特别的,连来连去搞那么复杂没什么意思,最终预测的结果是两个支路的

    2024年02月16日
    浏览(39)
  • Low-Light Image Enhancement via Self-Reinforced Retinex Projection Model 论文阅读笔记

    这是马龙博士2022年在TMM期刊发表的基于改进的retinex方法去做暗图增强(非深度学习)的一篇论文 文章用一张图展示了其动机,第一行是估计的亮度层,第二列是通常的retinex方法会对估计的亮度层进行RTV约束优化,从而产生平滑的亮度层,然后原图除以亮度层产生照度层作为

    2024年02月16日
    浏览(34)
  • 论文阅读——《Retinexformer: One-stage Retinex-based Transformer for Low-light Image Enhancement》

    本文试图从原理和代码简单介绍低照度增强领域中比较新的一篇论文——Retinexformer,其效果不错,刷新了十三大暗光增强效果榜单。 ❗ 论文名称 :Retinexformer: One-stage Retinex-based Transformer for Low-light Image Enhancement 👀 论文信息 :由清华大学联合维尔兹堡大学和苏黎世联邦理工

    2024年01月18日
    浏览(35)
  • C# OpenCvSharp DNN Image Retouching

    目录 介绍 模型 项目 效果 代码 下载 C# OpenCvSharp DNN Image Retouching github地址:https://github.com/hejingwenhejingwen/CSRNet (ECCV 2020) Conditional Sequential Modulation for Efficient Global Image Retouching Model Properties ------------------------- --------------------------------------------------------------- Inputs -----------------

    2024年02月21日
    浏览(27)
  • 论文详读:Beyond Brightening Low-light Images (Kind++)

    文章地址:Beyond Brightening Low-light Images (tju.edu.cn) github:GitHub - zhangyhuaee/KinD_plus: Beyond Brightening Low-light Images 目录 一、简介 二、方法 网络整体结构: 分解网络 网络结构 损失函数: 总损失 反射网络 网络结构 损失函数 反射图的调整 光照网络 网络结构和损失函数 与伽马变化

    2024年02月04日
    浏览(29)
  • Kindling the Darkness: A Practical Low-light Image Enhancer论文阅读笔记

    这是ACMMM2019的一篇有监督暗图增强的论文,KinD 其网络结构如下图所示: 首先是一个分解网络分解出R和L分量,然后有Restoration-Net和Adjustment-Net分别去对R分量和L分量进一步处理,最终将处理好的R分量和L分量融合回去。这倒是很常规的流程。其中有些novel的细节,一个是分解网

    2024年02月14日
    浏览(31)
  • 论文阅读之《Kindling the Darkness: A Practical Low-light Image Enhancer》

    目录 摘要 介绍 已有方法回顾 普通方法 基于亮度的方法 基于深度学习的方法 基于图像去噪的方法 提出的方法 2.1 Layer Decomposition Net 2.2 Reflectance Restoration Net 2.3 Illumination Adjustment Net 实验结果 总结 Kindling the Darkness: A Practical Low-light Image Enhancer(KinD) ACM MM 2019 Yonghua Zhang, Jiaw

    2024年02月05日
    浏览(31)
  • Empowering Low-Light Image Enhancer through Customized Learnable Priors 论文阅读笔记

    中科大、西安交大、南开大学发表在ICCV2023的论文,作者里有李重仪老师和中科大的Jie Huang(ECCV2022的FEC CVPR2022的ENC和CVPR2023的ERL的一作)喔,看来可能是和Jie Huang同一个课题组的,而且同样代码是开源的,我很喜欢。 文章利用了MAE的encoder来做一些事情,提出了一个叫customi

    2024年02月02日
    浏览(32)
  • C# OpenCvSharp DNN 部署yoloX

    目录 效果 模型信息 项目 代码 下载 C# OpenCvSharp DNN 部署yoloX Inputs ------------------------- name:images tensor:Float[1, 3, 640, 640] --------------------------------------------------------------- Outputs ------------------------- name:output tensor:Float[1, 8400, 85] ---------------------------------------------------------------

    2024年02月01日
    浏览(27)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包