当前位置:网站首页>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 
边栏推荐
- National vocational college skills competition (secondary vocational group) network security competition questions - Analysis
- Simulink与Arduino串口通信
- Flask
- 力扣 第 300 场周赛
- 光模塊字母含義及參數簡稱大全
- Simulink and Arduino serial port communication
- [paper summary] zero shot semantic segmentation
- 空洞卷积、可变形卷积、可变形ROI Pooling
- Secondary vocational group network security - memory Forensics
- Capturing and sorting out external Fiddler -- Conversation bar and filter
猜你喜欢

C语言简易学生管理系统(含源码)

Sécurité du réseau dans les écoles professionnelles secondaires - preuve de mémoire

Detailed comparison of Hynix emmc5.0 and 5.1 series

Flask

Public inputs in appliedzkp zkevm (13)

19.Frambuffer应用编程

中科磐云—D模块解析以及评分标准

Appearance of LabVIEW error dialog box

RSA加密应用常见缺陷的原理与实践

Flutter ‘/usr/lib/libswiftCore. dylib‘ (no such file)
随机推荐
Flask
[matlab] matlab simulates digital bandpass transmission systems - QPSK and OQPSK systems
【雕爷学编程】Arduino动手做(105)---压电陶瓷振动模块
[matlab] general function of communication signal modulation bandpass filter
Several smart watch related chips Bluetooth chip low power consumption
Just do it with your hands 7 - * project construction details 2 - hook configuration
空洞卷积、可变形卷积、可变形ROI Pooling
flink1.13 sql基础语法(二)join操作
2022 Guangdong provincial competition - code information acquisition and analysis flag
Download kicad on Alibaba cloud image station
Daily question brushing record (12)
[wechat applet] template and configuration (wxml, wxss, global and page configuration, network data request)
Error response from daemon: You cannot remove a running container 8d6f0d2850250627cd6c2acb2497002fc3
A summary of the 8544 problem that SolidWorks Standard cannot obtain a license
总线的基本概念
724. 寻找数组的中心下标
远程桌面客户端 RDP
2022广东省赛——编码信息获取 解析flag
Flask
Unity2D--人物移动并转身