当前位置:网站首页>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.InteropServices
Write 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
边栏推荐
- 中職組網絡安全—內存取證
- Roles of rollup components
- Signification des lettres du module optique et abréviation des paramètres Daquan
- Zhongke Panyun - data analysis and forensics packet flag
- [matlab] matlab simulation modulation system FM system
- Public inputs in appliedzkp zkevm (13)
- [paper summary] zero shot semantic segmentation
- VB.net 简单的处理图片,黑白(类库——7)
- Just do it with your hands 7 - * project construction details 2 - hook configuration
- Sécurité du réseau dans les écoles professionnelles secondaires - preuve de mémoire
猜你喜欢
Zhongke panyun-d module analysis and scoring standard
Programming example of stm32f1 and stm32subeide -74hc595 drives 4-bit 7-segment nixie tube
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
LM small programmable controller software (based on CoDeSys) note XXI: error 3703
Automated testing selenium foundation -- webdriverapi
Appearance of LabVIEW error dialog box
[interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre
Public inputs in appliedzkp zkevm (13)
Letter meaning and parameter abbreviation of optical module Daquan
Fault analysis | mongodb 5.0 reports an error, and the legal instruction solves it
随机推荐
中職組網絡安全—內存取證
[matlab] general function of communication signal modulation Fourier transform
KMP match string
2022 a special equipment related management (elevator) examination questions simulation examination platform operation
Solar insect killing system based on single chip microcomputer
ping端口神器psping
Li Kou's 300th weekly match
Unity is connected to the weather system
[QT] timer
IP时代来临,电竞酒店如何借好游戏的“东风”?
Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
拓扑排序和关键路径的图形化显示
Simulink and Arduino serial port communication
Evolution of system architecture: differences and connections between SOA and microservice architecture
Flutter ‘/usr/lib/libswiftCore. dylib‘ (no such file)
2022年R2移动式压力容器充装复训题库及答案
Nodejs learning document
[untitled]
光模塊字母含義及參數簡稱大全
Encryption and decryption