当前位置:网站首页>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 
边栏推荐
- Just do it with your hands 7 - * project construction details 2 - hook configuration
- Headache delayed double deletion
- [matlab] general function of communication signal modulation inverse Fourier transform
- Letter meaning and parameter abbreviation of optical module Daquan
- Thread pool: use thread pool to optimize query speed
- Exercise bubble sort
- Flink1.13 SQL basic syntax (I) DDL, DML
- 光模块字母含义及参数简称大全
- IP时代来临,电竞酒店如何借好游戏的“东风”?
- LabVIEW错误对话框的出现
猜你喜欢

LM小型可编程控制器软件(基于CoDeSys)笔记二十二:错误4268/4052

VB.net GIF(制作、拆解——优化代码,类库——5)

Public inputs in appliedzkp zkevm (13)

VB.net 简单的处理图片,黑白(类库——7)
![[技术发展-25]:广播电视网、互联网、电信网、电网四网融合技术](/img/87/e0469e280365ed0261e2b551ebd888.png)
[技术发展-25]:广播电视网、互联网、电信网、电网四网融合技术

June 2022 summary
![[interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre](/img/3e/b5df691ca1790469eb1b4e8ea5b4c0.png)
[interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre
![[paper summary] zero shot semantic segmentation](/img/78/ee64118d86a7e43ec4d1cb97191fbe.jpg)
[paper summary] zero shot semantic segmentation

Supplement the JS of a video website to decrypt the video

补某视频网站的js,进行视频解密
随机推荐
Simulated small root pile
Notepad++ -- display related configurations
2022 Guangdong provincial competition - code information acquisition and analysis flag
[matlab] matlab simulates digital bandpass transmission systems - QPSK and OQPSK systems
VB.net GIF(制作、拆解——优化代码,类库——5)
[paper summary] zero shot semantic segmentation
[untitled]
Graduation design of small programs -- small programs of food and recipes
Build an Internet of things infrared temperature measuring punch in machine with esp32 / rush to work after the Spring Festival? Baa, no matter how hard you work, you must take your temperature first
补某视频网站的js,进行视频解密
[matlab] matlab simulates digital baseband transmission system eye diagram of bipolar baseband signal (class I part response waveform)
[high concurrency, high performance and high availability of massive data MySQL practice-7] - memory data drop disk
远程桌面客户端 RDP
Remote desktop client RDP
Enterprise level log analysis system elk (if things backfire, there must be other arrangements)
Encryption and decryption
Exercise bubble sort
Fault analysis | mongodb 5.0 reports an error, and the legal instruction solves it
Roles of rollup components
LM small programmable controller software (based on CoDeSys) note 22: error 4268/4052