当前位置:网站首页>Digital image processing -- popular understanding of corrosion and expansion
Digital image processing -- popular understanding of corrosion and expansion
2022-07-03 15:19:00 【alw_ one hundred and twenty-three】
I have planned to present this series of blog posts in the form of animated interesting popular science , If you're interested Click here .
0. What's the use of corrosion and expansion ?
Corrosion and expansion are two basic operations in digital morphology , Generally used for binary images ( Of course RGB Pictures can also be used ). The effect of corrosion is to make the dark area larger , The role of expansion is to make the bright area larger ( It can be imagined that Cheng Balala's energy and gunara's dark god are fighting in the gods .. If Balala energy wins, it will expand , Gunara, the dark god, wins, which is corrosion ...)
The most typical application scenario is after your binarization , When your goal and background are not very clean, you can try two operations , Sometimes the effect is surprisingly good . For example, if I want to binarize a diagram of verification code, the result will be more accurate , You can try corrosion and expansion ( The second picture is expansion + Effect after corrosion , It can be seen that the interference points and lines have been removed ).
1. corrosion
Corrosive raw materials are : Original picture 、 nucleus ( Corroded soul )、 Result chart ( The goods are copied from the original drawing ). Here are chestnuts to illustrate the workflow of corrosion .
Suppose now we want to corrode such a single channel diagram ( By IG Children's shoes that have cared for their eyesight can certainly see that what is painted in the picture is 1)
Then we need to make a copy of the original drawing as the result drawing , Now the result graph is the same as the original one .
With the original diagram and the result diagram , We need souls ( Design core ). The nucleus is generally square ,X Shaped , Rhombic , Etc., etc. ( Of course, you can do it yourself DIY, For example, I just DIY A cross shaped ). And the effect of corrosion has a lot to do with the core you designed , What kind of nucleus is suitable for what kind of map depends on your own brain hole and experience . Anyway, I like to try more cores , See which one works well . I'm here DIY Its core is 3 That's ok 3 Columns of the matrix , Look like the following :
Now with the soul , We are about to inject soul . How to inject ? It's simple , Throw our core into the upper left corner of the original and result graphs (PS: I don't do it here padding, Because I am lazy ).
After throwing it , We are going to use the values in the core . We have 0 and 1( Nonzero value ),0 It means I don't care,1( Nonzero value ) On behalf of your success, it attracted my attention . When our core is covered on the original picture, it shows that I only care about my core 1( Nonzero value ) The corresponding pixel on the original image , That is, I only care about the cross in the middle of my red frame 5 individual 255, Other 4 I don't care about pixels . After locking the target , We just have to look at me 5 Are there any pixels 0, If so, we will change the pixel value in the center of the red box in the result image to 0, Or I'll do nothing . Let's have a look ,5 individual 255, did not 0 So do nothing .
It took us a long time to find that we didn't do anything , You're not angry , So pinch , Let's move the red box on the original image and the result image one step to the right ( In fact, it's not a matter of being angry , Is corrosion and expansion is to traverse the entire graph , So we have to iterate ). So after moving a step, it became maozi .
New place , A new start , So we need to continue the routine just now , Look at the cross in the red box of the original picture 5 Are there pixels 0, Found to have 0!. So the pixel value of the center point of the red box in our result graph is changed to 0 了 .
Then continue the routine just now , Move right , See if there is any place you care about 0, If you can't move on the right side, move down . Until the whole red frame is soaked with rain and dew , The whole corrosion algorithm is finished .
After we finish, we will find that the result picture turns into maozi .
Um. , Normal , Because corrosion is to make the black area larger , therefore 1 Getting fat , And the original 1 There is a partition in the middle , After corrosion, the partition is also connected .
2. inflation
In fact, after understanding corrosion , Understanding inflation is simply a batch . Corrosion is called corrosion because it only looks at whether there is in the area of interest 0, Yes 0 I will assign the result to 0, So the black area can become larger . Expansion is just the opposite of corrosion , It only depends on whether there is 255, Yes 255 I will assign the result to 255, So the bright area can become larger .
If the original drawing (0 It can be regarded as noise ) It's purple sauce
The result picture was also dark purple at the beginning
Suppose the inflated soul is also the core of the cross
Then the first step of expansion is to put a red box on the original diagram and the result diagram
Then it depends on whether the cross area is 255, When I find it, I will change the pixel of the corresponding position on the result graph to 255( Of course , At this time, the corresponding pixels of the result image are 255, So it's equivalent to doing nothing ). Move the red box on the original image and the result image to the right
At this time, it was found that there was 255, When I find it, I will change the pixel of the corresponding position on the result graph to 255( Of course , At this time, the corresponding pixels of the result image are 255, So it's equivalent to doing nothing ). Move the red box on the original image and the result image to the right .
At this time, there are 255, So change the pixels corresponding to the result image to 255, After modification, the result picture is maozi .
Then continue to move , Move to the lower right corner , The whole algorithm stops . After inflation , The result is dark purple .
You can see that , The original 0 I regard it as noise , After expansion, all the noise is erased .
3. Conclusion
It can be seen that the two algorithm processes of corrosion and expansion are very simple , Nothing more than friction .. Devil like steps .. Rub on the image .. friction .. Although the algorithm is simple , But if the nuclear design is good , Use the right words , It's enough to get a satisfactory effect .
边栏推荐
- redis单线程问题强制梳理门外汉扫盲
- [pytorch learning notes] datasets and dataloaders
- Visual upper system design and development (Halcon WinForm) -1 Process node design
- 【Transform】【NLP】首次提出Transformer,Google Brain团队2017年论文《Attention is all you need》
- 使用Tengine解决负载均衡的Session问题
- 什么是embedding(把物体编码为一个低维稠密向量),pytorch中nn.Embedding原理及使用
- Global and Chinese market of Bus HVAC systems 2022-2028: Research Report on technology, participants, trends, market size and share
- Redis cache penetration, cache breakdown, cache avalanche solution
- Kubernetes will show you from beginning to end
- Jvm-04-runtime data area heap, method area
猜你喜欢
Finally, someone explained the financial risk management clearly
Unity hierarchical bounding box AABB tree
What is embedding (encoding an object into a low dimensional dense vector), NN in pytorch Principle and application of embedding
[pytorch learning notes] datasets and dataloaders
Summary of concurrent full knowledge points
GCC cannot find the library file after specifying the link library path
"Seven weapons" in the "treasure chest" of machine learning: Zhou Zhihua leads the publication of the new book "machine learning theory guide"
el-switch 赋值后状态不变化
北京共有产权房出租新规实施的租赁案例
Concurrency-01-create thread, sleep, yield, wait, join, interrupt, thread state, synchronized, park, reentrantlock
随机推荐
GCC cannot find the library file after specifying the link library path
Global and Chinese market of Bus HVAC systems 2022-2028: Research Report on technology, participants, trends, market size and share
基础SQL教程
视觉上位系统设计开发(halcon-winform)-1.流程节点设计
Relationship between truncated random distribution and original distribution
Global and Chinese markets for ionization equipment 2022-2028: Research Report on technology, participants, trends, market size and share
TPS61170QDRVRQ1
Baidu AI Cloud helps Shizuishan upgrade the smart health care model of "Internet + elderly care services"
运维体系的构建
使用JMeter对WebService进行压力测试
高并发下之redis锁优化实战
socket.io搭建分布式Web推送服务器
Solve the problem that pushgateway data will be overwritten by multiple push
The first character of leetcode sword offer that only appears once (12)
Nppexec get process return code
Leasing cases of the implementation of the new regulations on the rental of jointly owned houses in Beijing
求字符串函数和长度不受限制的字符串函数的详解
[transform] [practice] use pytoch's torch nn. Multiheadattention to realize self attention
第04章_逻辑架构
MySQL reports an error: [error] mysqld: file '/ mysql-bin. 010228‘ not found (Errcode: 2 “No such file or directory“)