当前位置:网站首页>VB. Net simple processing pictures, black and white (class library - 7)
VB. Net simple processing pictures, black and white (class library - 7)
2022-07-04 05:25:00 【Xiaoyu 163】
Let's see , This picture makes us take pictures with mobile phones , Without treatment , Printed out is gray
stay Photoshop You can adjust the color scale , Choose black and then white , It can be clarified

Pay attention to flattening when taking photos , This is the color mode of scanning , As a test
see VB.net How to deal with it
Referenced in this article csdn Big guy's article ,vb.net course 5-15 Memory processing of image processing 6 Just change a parameter
import:
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Runtime.InteropServicesWrite function :value You can adjust yourself , Not necessarily just 180
''' <summary>
''' Black and white processing of pictures , Remember to use multithreading to call functions
''' </summary>
''' <param name="value"> Black and white numerical constants , Recommend from 128 Start adjusting , The scope is 0~255(byte)</param>
''' <param name="bmp"> The image to be processed </param>
''' <returns> Processed pictures </returns>
Public Function BlackWhite(value As Byte, bmp As Bitmap)
Dim destImg As New Bitmap(bmp.Width, bmp.Height)
Dim sourceData As BitmapData = bmp.LockBits(New Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb)
Dim destData As BitmapData = destImg.LockBits(New Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb)
Dim pSource As IntPtr = sourceData.Scan0
Dim allBytes As Integer = sourceData.Stride * sourceData.Height
Dim rgbvalues() As Byte
ReDim rgbvalues(allBytes - 1)
Marshal.Copy(pSource, rgbvalues, 0, allBytes)
Dim pos As Integer = 0
Dim R, G, B As Integer
Dim avgValue As Integer
For j As Integer = 0 To sourceData.Height - 1
For i As Integer = 0 To sourceData.Width - 1
B = rgbvalues(pos)
G = rgbvalues(pos + 1)
R = rgbvalues(pos + 2)
avgValue = (B + G + R) / 3
If avgValue >= value Then avgValue = 255 Else avgValue = 0
rgbvalues(pos) = avgValue
rgbvalues(pos + 1) = avgValue
rgbvalues(pos + 2) = avgValue
pos += 3
Next
pos = pos + sourceData.Stride - sourceData.Width * 3
Next
Dim pDest As IntPtr = destData.Scan0
Marshal.Copy(rgbvalues, 0, pDest, allBytes)
bmp.UnlockBits(sourceData)
destImg.UnlockBits(destData)
Return destImg
End Function
call :
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Pic.Image = GDI.BlackWhite(180, New Bitmap("C:\Users\Administrator\Desktop\example.jpg"))
End Sub The effect is very good , Some wrinkles can be removed , Redundant background 
边栏推荐
- [技术发展-25]:广播电视网、互联网、电信网、电网四网融合技术
- 补某视频网站的js,进行视频解密
- 中科磐云—2022广西逆向解析思路
- [matlab] matlab simulates digital bandpass transmission systems - QPSK and OQPSK systems
- With the advent of the IP era, how can E-sports hotels take advantage of the "east wind" of games?
- [QT] timer
- 1480. 一维数组的动态和
- Graduation design of small programs -- small programs of food and recipes
- cmake
- 【QT】制作MyComboBox点击事件
猜你喜欢

空洞卷积、可变形卷积、可变形ROI Pooling

NTFS security permissions

Public inputs in appliedzkp zkevm (13)

2022 question bank and answers for safety management personnel of hazardous chemical business units

Simulink and Arduino serial port communication

数据标注是一块肥肉,盯上这块肉的不止中国丨曼孚科技

Unity is connected to the weather system

ETCD数据库源码分析——初始化总览

Write a complete answer applet (including single choice questions, judgment questions and multiple topics) (III) single choice questions, judgment questions, and the first question display

2022广东省赛——编码信息获取 解析flag
随机推荐
[QT] create mycombobox click event
Fault analysis | mongodb 5.0 reports an error, and the legal instruction solves it
TCP state transition diagram
Capturing and sorting out external Fiddler -- Conversation bar and filter
Detailed comparison of Hynix emmc5.0 and 5.1 series
中職組網絡安全—內存取證
补某视频网站的js,进行视频解密
简易零钱通
[matlab] matlab simulation of modulation system - power spectrum and coherent demodulation of AM modulated signal
2022年A特种设备相关管理(电梯)考试题模拟考试平台操作
[matlab] matlab simulation - simulate the AM modulation process of the modulation system
Zhongke panyun-d module analysis and scoring standard
[matlab] communication signal modulation general function - low pass filter
c语言经典指针和数组笔试题解析
Simulated small root pile
企业级日志分析系统ELK(如果事与愿违那一定另有安排)
[matlab] matlab simulation modulation system - DSB system
[matlab] general function of communication signal modulation inverse Fourier transform
力扣 第 300 场周赛
How to build your own knowledge engine? Community open application