当前位置: 首页 > news >正文

cms企业网站模板试分析网站推广和优化的原因

cms企业网站模板,试分析网站推广和优化的原因,天津集团网站建设,厦门做网站的公司目录 1 程序框架简介 2 C#图像读取、显示、保存模块 3 C动态库图像算法模块 4 C#调用C动态库 5 演示Demo 5.1 开发环境 5.2 功能介绍 5.3 下载地址 参考 1 程序框架简介 一个图像处理算法研究的常用程序逻辑框架,如下图所示 在该框架中,将图像处…

目录

1 程序框架简介

2 C#图像读取、显示、保存模块

3 C动态库图像算法模块

4 C#调用C动态库

5 演示Demo

5.1 开发环境

5.2 功能介绍

5.3 下载地址

参考


1 程序框架简介

        一个图像处理算法研究的常用程序逻辑框架,如下图所示

        在该框架中,将图像处理算法产品分为上层模块和底层模块两个部分。

        底层模块使用C/C++实现算法API,提供给上层模块调用;上层模块执行调用API和一些界面功能的实现,最后得到不同平台的软件产品。

        本文使用使用C/C++进行图像算法API开发,具有安全、高效和方便多平台移植的优点,目前大多数图像软件都是基于C/C++来开发的;使用C#来做上层调用与界面设计,是因为C#具有优秀的面向对象能力,界面设计方便快捷,而且对于图像读取、保存、显示已经做了良好的封装,避免了图像编解码的问题,相对使用MFC大大简化了开发逻辑,提升了开发效率。

2 C#图像读取、显示、保存模块

        代码相对简单,直接给出模块代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.IO;namespace ImageProcessDemo
{public partial class FormMain : Form{public FormMain(){InitializeComponent();}#region  变量名字// 图像文件名称private String curFileName = null;// 当前图像变量private Bitmap curBitmap = null;// 原图private Bitmap srcBitmap = null;#endregion#region  图像打开和保存模块// 图像打开public void OpenFile(){OpenFileDialog ofd = new OpenFileDialog();ofd.Filter = "所有图像文件 | *.bmp; *.pcx; *.png; *.jpg; *.gif;" +"*.tif; *.ico; *.dxf; *.cgm; *.cdr; *.wmf; *.eps; *.emf|" +"位图( *.bmp; *.jpg; *.png;...) | *.bmp; *.pcx; *.png; *.jpg; *.gif; *.tif; *.ico|" +"矢量图( *.wmf; *.eps; *.emf;...) | *.dxf; *.cgm; *.cdr; *.wmf; *.eps; *.emf";ofd.ShowHelp = true;ofd.Title = "打开图像文件";if (ofd.ShowDialog() == DialogResult.OK){curFileName = ofd.FileName;try{curBitmap = (Bitmap)System.Drawing.Image.FromFile(curFileName);srcBitmap = new Bitmap(curBitmap);}catch (Exception exp){ MessageBox.Show(exp.Message); }}}// 图像保存public void SaveFile(){SaveFileDialog sfd = new SaveFileDialog();sfd.Filter = @"Bitmap文件(*.bmp)|*.bmp|Jpeg文件(*.jpg)|*.jpg|PNG文件(*.png)|*.png|所有合适文件(*.bmp,*.jpg,*.png)|*.bmp;*.jpg;*.png";sfd.FilterIndex = 3;sfd.RestoreDirectory = true;if (sfd.ShowDialog() == DialogResult.OK){ImageFormat format = ImageFormat.Jpeg;switch (Path.GetExtension(sfd.FileName).ToLower()){case ".jpg":format = ImageFormat.Jpeg;break;case ".bmp":format = ImageFormat.Bmp;break;case ".png":format = ImageFormat.Png;break;default:MessageBox.Show("Unsupported image format was specified!");return;}pictureBox1.Image.Save(sfd.FileName, format);}}// 鼠标按键按下显示原图private void pictureBox1_MouseDown(object sender, MouseEventArgs e){if (srcBitmap != null)pictureBox1.Image = srcBitmap;}// 鼠标按键抬起显示效果图private void pictureBox1_MouseUp(object sender, MouseEventArgs e){if (curBitmap != null)pictureBox1.Image = curBitmap;}// open按钮事件private void btn_open_Click(object sender, EventArgs e){OpenFile();if (curBitmap != null){pictureBox1.Image = (Image)curBitmap;}}// save按钮事件private void btn_save_Click(object sender, EventArgs e){if (pictureBox1.Image != null)SaveFile();}#endregion}
}

3 C动态库图像算法模块

        构建C实现获取像素RGB值的API代码。

#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdio.h>#include "ImageProcessAPI.h"int getPixel(unsigned char *srcData, int width, int height, int stride, int x, int y, int rgba[4])
{x = x < 0 ? 0 : (x > width - 1 ? width - 1 : x);y = y < 0 ? 0 : (y > height - 1 ? height - 1 : y);int ret = 0;if(srcData == NULL){printf("input image is null!");return -1;}// 图像处理,获取像素RGBAint pos = x * 4 + y * stride;rgba[0] = srcData[pos + 2];rgba[1] = srcData[pos + 1];rgba[2] = srcData[pos + 0];rgba[3] = srcData[pos + 3];return ret;
};

4 C#调用C动态库

        在C#中调用C/C++动态库需要引用 System.Runtime.InteropServices 命名空间,实例代码如下

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;namespace ImageProcessDemo
{unsafe class ImageProcessBitmap{// 引用DLL中的方法,此处ImageProcessDll为DLL的名字[DllImport("ImageProcessDll.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.None, ExactSpelling = true)]// 封装C中的API接口,此处应注意C#和C之间的数据类型转换问题,所有参数的数据类型必须一致// getPixel为C中的接口名称private static extern int getPixel(byte* srcData, int width, int height, int stride, int x, int y, int[] rgba);// C#层接口调用// GetImgPixel为C#中封装的接口名称,该接口调用C中的getPixelpublic Bitmap GetImgPixel(Bitmap src, int x, int y, ref int[] rgba){// 生成图像备份Bitmap a = new Bitmap(src);// 获取图像的宽度和高度int w = a.Width;int h = a.Height;// 获取并锁定图像数据区域// 依据图像格式可选择16/24/32位等格式BitmapData srcData = a.LockBits(new Rectangle(0, 0, a.Width, a.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);// 传递给C接口getPixel((byte*)srcData.Scan0, w, h, srcData.Stride, x, y, rgba);// 解锁图像数据区域a.UnlockBits(srcData);return a;}}
}

        在C#界面中增加代码实现:用鼠标单击图像,界面上就会显示对应位置像素的RGB值。

        #region 图像处理,用鼠标单击图像,界面上就会显示对应位置像素的RGB值// 图像处理类ImageProcessBitmap imageProcess = new ImageProcessBitmap();// 变量private int[] rgba = new int[4];private void pictureBox1_MouseMove(object sender, MouseEventArgs e){if (pictureBox1.Image != null){curBitmap = imageProcess.GetImgPixel(srcBitmap, e.X, e.Y, ref rgba);label_rgba.Text = "RGBA: (" + rgba[0].ToString() + "," + rgba[1].ToString() + "," + rgba[2].ToString() + "," + rgba[3].ToString() + ")";}}#endregion

5 演示Demo

5.1 开发环境

  • Windows 10 Pro x64

  • Visual Studio 2015

5.2 功能介绍

        演示程序主界面如下图所示,具有图像读取、显示、保存以及随着光标的滑动会动态显示光标所在位置对应图像像素的RGB值等功能。

5.3 下载地址

        开发环境:

  • Windows 10 pro x64

  • Visual Studio 2015

        下载地址: 图像处理算法研究的程序框架

参考

        图像视频滤镜与人像美颜美妆算法详解. 胡耀武、谭娟、李云夕. 电子工业出版社、2020-07

http://www.ds6.com.cn/news/44738.html

相关文章:

  • 乐华网络公司介绍广州seo排名收费
  • 新开装修公司取什么名好营销型网站建设优化建站
  • 网站做到赣州第一名要多少钱什么是网站推广策略
  • 网站建设与更新138ip查询网域名解析
  • 行唐县网站建设公司免费的行情网站app软件
  • 电子商务系统 网站建设网络推广网上营销
  • 百度网盘0基础网站开发教程网站建设公司地址在哪
  • 东莞模板建站哪家好博客seo怎么做
  • b站镜像网站是谁做的谈谈你对网络营销的看法
  • 表白网址在线制作平台百度的seo关键词优化怎么弄
  • 包头网站建设兼职如何在百度上开店铺
  • 衡水网站制作报价网站维护一般怎么做
  • 电子商务网官方网站搜狗网址导航
  • 有源码怎么在本地网站搭建陕西网站推广公司
  • 哈尔滨大型网站设计公司成都网站搜索排名优化公司
  • 淘宝网页版登录入口官方上海企业网站seo
  • 怎么提高网站流量重庆百度快照优化排名
  • 网页设计门户网站品牌营销策略论文
  • 网站设计平台老司机们用的关键词有哪些
  • 网站建设能在家工作室seo收费低
  • 做网站美工要学什么免费推广方法
  • 镇江市官网郑州seo技术
  • 怎么做国内网站南京seo收费
  • 义务网站建设收录优美的图片app
  • 做国外购物网站完整企业网站模板
  • 购物网站线下推广方案企业网络推广的方式有哪些
  • 网站建设开票属于什么服务必应搜索引擎怎么样
  • 网站建设需要哪些硬件宁波优化推广找哪家
  • 提升网站建设百度seo收录软件
  • 梅州做网站多少钱营销推广方案范文