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

做网站代理需要办什么执照信息流广告投放公司

做网站代理需要办什么执照,信息流广告投放公司,科技医疗网站建设,网站是如何做的(1)创建一个名为SplitImage的窗体的应用程序,将窗体改名为FormSplitImage。 (2)创建一个名为ImageProcessingLibrary的类库程序,为该工程添加名为ImageProcessing的静态类 (3)为Imag…

(1)创建一个名为SplitImage的窗体的应用程序,将窗体改名为FormSplitImage。


(2)创建一个名为ImageProcessingLibrary的类库程序,为该工程添加名为ImageProcessing的静态类

(3)为ImageProcessing类添加统计直方图的静态函数

(4)在ImageProcessing类中添加二值化处理函数BinaryImage

(5)在SplitImage工程中引用ImageProcessingLibrary工程,并添加ImageProcessingLibrary, System.Drawing命名空间。
(6)在窗体中重写OnPaint事件函数,并在函数中添加绘制原始图像、显示直方图和图像分割与提取后的图像

程序框架 :

 被窗体的应用程序引用的类库代码:

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;namespace ImageProcessingLibrary
{public static class ImageProcessing{/// 获取直方图数组,并绘制直方图/// <param name="image">需要处理的图像</param>/// <param name="indexColor">处理的颜色索引值,Blue:0,Green:1,Red:2</param>/// <param name="histogram">直方图统计数组</param>/// <returns>绘制好的直方图</returns>public static Bitmap GetHistogram(Bitmap image, int indexColor, out int[] histogram){histogram = new int[256];                               //直方图统计数组BitmapData data = image.LockBits(new Rectangle(new Point(), image.Size),ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);  //将图像锁定到内存中byte[] datas = new byte[data.Stride * image.Height];   //图像数组Marshal.Copy(data.Scan0, datas, 0, datas.Length);     //将图像在内存中的数据复制到图像数组中for (int y = 0; y < image.Height * data.Stride; y += data.Stride) //data.Stride代表图像一行数据的字节总数/步长为data.Stride{//外层循环是遍历行for (int x = 0; x < image.Width * 3; x += 3)//遍历当前行中的每个像素/每个像素由三个字节(RGB)组成//每个颜色分量(红色、绿色或蓝色)可以有的不同强度级别就是2^8,即256个级别{int index = y + x;                     //颜色在内存中的索引/每个索引偏移量3字节(对应R,G,B)histogram[datas[index + indexColor]]++;//增加直方图中对应颜色分量出现的次数}}image.UnlockBits(data);byte maxValue = 0;                             //直方图中的最大值for (int value = 1; value < 256; value++){if (histogram[value] > histogram[maxValue]) maxValue = (byte)value;}Bitmap imageHistogram = new Bitmap(256, 256);Graphics GHistogram = Graphics.FromImage(imageHistogram);GHistogram.Clear(Color.Blue);for (int value = 1; value< 256; value++){int length = byte.MaxValue * histogram[value] / histogram[maxValue];GHistogram.DrawLine(new Pen(Color.FromArgb(value, value, value), 1f), value,256, value, 256 - length);                            //绘制直方图}Font font = new Font("宋体", 9f);//绘制统计标识for (int value = 32; value < 256; value += 32){int count = histogram[maxValue] / 8 * value / 32;Pen pen = new Pen(Color.Lime);pen.DashStyle = DashStyle.DashDot;SizeF sizeCount = GHistogram.MeasureString(count.ToString(), font);GHistogram.DrawLine(pen, 0, 255 - value, 255, 255 - value);//绘制数量等级线GHistogram.DrawString(count.ToString(), font, Brushes.Red, 5, 255 - value - sizeCount.Height / 2);SizeF sizeValue = GHistogram.MeasureString(value.ToString(), font);GHistogram.DrawLine(Pens.Red, value, 250, value, 255);//绘制颜色值等级线GHistogram.DrawString(value.ToString(), font, Brushes.Red, value - sizeValue.Width / 2, 240);}font.Dispose();return imageHistogram;}/// 将图像进行二值化处理/// <param name="image">需要处理的图像</param>/// <param name="indexColor">处理的颜色索引值,Blue:0,Green:1,Red:2</param>/// <param name="thresholdMin">阈值下限</param>/// <param name="thresholdMax">阈值上限</param>public static void BinaryImage(Bitmap image, int indexColor, int thresholdMin, int thresholdMax){//将图像锁定到内存中BitmapData data = image.LockBits(new Rectangle(new Point(), image.Size), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);byte[] datas = new byte[data.Stride * image.Height];           //图像数组Marshal.Copy(data.Scan0, datas, 0, datas.Length);              //将图像在内存中的数据复制到图像数组中for (int y = 0; y < image.Height * data.Stride; y += data.Stride){for (int x = 0; x < image.Width * 3; x += 3){int index = y + x;//根据阈值将图像分成黑色和白色,其中阈值内的为黑色,阈值外的为白色if (datas[index + indexColor] >= thresholdMin && datas[index + indexColor] <= thresholdMax)datas[index] = datas[index + 1] = datas[index + 2] = 0;elsedatas[index] = datas[index + 1] = datas[index + 2] = 255;}}Marshal.Copy(datas, 0, data.Scan0, datas.Length);      //将图像数组复制到内存中image.UnlockBits(data);                                //将图像从内存中解锁}}}
/*假设颜色分量是8位的,那么每个颜色分量(红色、绿色或蓝色)可以有的不同强度级别就是2^8,即256个级别。* 这是因为8位可以表示从0到255的整数,总共256个不同的数值。在数字图像处理中,8位颜色深度是常见的,* 因为它提供了足够的动态范围来表示大多数自然和人工颜色的细微差别,同时保持数据量相对较小。当你说“直方图大小为256”时,你指的是直方图的横坐标(即颜色强度的可能值)有256个不同的条目,
每个条目对应一个特定的颜色强度值(从0到255)。直方图的纵坐标通常表示该颜色强度值在图像中出现的频率或像素数量。因此,如果我们想为8位颜色分量的图像构建直方图,我们将创建一个大小为256的数组,数组的每个元素初始化为0。
然后,我们遍历图像的每个像素,对于每个像素的特定颜色分量(如红色、绿色或蓝色),我们增加直方图中对应颜色强度值的计数。
这个过程最终会给我们一个表示图像中每个颜色强度出现频率的直方图。*/

窗体的应用程序,重写OnPaint事件函数代码:

using ImageProcessingLibrary;
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;namespace SplitImage
{public partial class FormSplitImage : Form{public FormSplitImage(){InitializeComponent();}protected override void OnPaint(PaintEventArgs e)//重写OnPaint事件函数{Graphics G = e.Graphics;Bitmap image = new Bitmap("123456.jpg");                       //加载图像Rectangle rectImage = new Rectangle(new Point(), image.Size);G.DrawImage(image, rectImage);                                   //绘制原始图像int[] histogram;                                                   //直方图统计数组Rectangle rectHistogram = new Rectangle(rectImage.Width, 0, 256, 256); //获取图像的灰度直方图(起始点X,Y,像素大小x,y)Bitmap imageHistogram = ImageProcessing.GetHistogram(image, 0, out histogram);//这里out返回了直方图数组histogramG.DrawImage(imageHistogram, rectHistogram);                        //绘制直方图rectImage.Offset(0, image.Height);//矩形位置调整指定的量,即往下(y)移一个图片高度,定义了绘制分割后的图像的rectImageImageProcessing.BinaryImage(image, 1, 0, 150);                     //通过二值化将目标分割出来()G.DrawImage(image, rectImage);                                     //绘制分割后的图像image.Dispose();                                                   //释放图像imageHistogram.Dispose();                                          //释放直方图图像}}
}

     在程序路径下准备图片:123456.jpg 

 运行SplitImage窗体的应用程序:

http://www.ysxn.cn/news/1295.html

相关文章:

  • 网站页面构成要素seo推广需要多少钱
  • 动画制作网页企业网站seo案例
  • 怎样做网站设计要交税吗广告策划书
  • 机票酒店 网站建设平台营销策略都有哪些
  • 网站广告的图片怎么做营销策略怎么写
  • wordpress有多大的数据量兰州seo培训
  • 做企业网站支付功能今日关注
  • 图片做网站连接中国突然宣布大消息
  • 关键词做网站标题是什么意思网站seo文章该怎么写
  • 南宁免费建站模板关键词歌词林俊杰
  • 河源网站建设如何做好百度推广
  • 龙岩市住房和城乡建设厅网站头条权重查询
  • 深圳松岗网站建设免费推广软件哪个好
  • 手机能建设网站忙腾讯广告投放推广平台价格
  • 代刷网站怎么做免费公司网址怎么注册
  • 网站开发报价范围百度网盘客服电话24小时
  • 中国建设银行龙卡信用卡网站福州seo推广优化
  • 武汉汉阳做网站的公司什么是互联网推广
  • 兼职制作网站开发网络营销促销方案
  • 企业oa合肥seo关键词排名
  • 网站关于我们页面设计谷歌官方网站注册
  • wordpress server error网站优化推广排名
  • 如何自己做网站百度开户是什么意思
  • 做设计赚钱的网站关键词挖掘工具爱站网
  • html网站可以做访问统计吗百度大搜推广和百度竞价
  • 企业为什么要做网站建设360搜索首页网址是多少
  • 广东网站建设服务供应商最简单的网页制作
  • 惠州做网站开发黄石市seo关键词优化怎么做
  • 网站换服务器怎么做备份关键词汇总
  • 做爰直播网站在线推广网站的方法