当前位置:网站首页>QT picture background color pixel processing method
QT picture background color pixel processing method
2022-07-07 16:58:00 【God port】
Preface
stay qt In development , We often deal with background pictures , For example, I just want to get a part of the picture , Next, we use the most original image processing method to achieve the effect .
step
Let's put an original picture first 
Then we want to change the white part into the background color
Ideas :
Get all the pixels of this picture , For each pixel rgb Color judgment , If it's the color you want to change , Then we will change this pixel into a transparent color ( Or the color you want to change )
Code
QImage image(":/CustomAddControl/1.bmp");// Load the original image
int w, h;
// Get the width and height of the picture
w = image.width();
h = image.height();
// Traverse every pixel
for (int i = 0; i < h; i++)
{
for (int j = 0; j < w; j++)
{
QRgb rgb = image.pixel(j, i);
if (rgb == 0xFFFFFFFF) // If it matches the background color
{
image.setPixel(j, i, 0x00000000);// This pixel is set to transparent
}
}
}
QPixmap tempPixmap = QPixmap::fromImage(image);// Processed pictures
And then we use label Show contrast effect :
obviously , We found that the white and other areas of the original image became transparent and were covered by the background color , In this way, we can achieve a simple image embedding effect .
summary
This treatment is relatively primitive , We can filter pictures based on this object 、 To strengthen 、 A series of image processing technologies such as sawtooth , Just multiply the pixels by an image processing matrix , The specific algorithm can search by itself , This article will not explain too much .
边栏推荐
- As an Android Developer programmer, Android advanced interview
- AutoLISP series (3): function function 3
- 【Vulnhub靶场】THALES:1
- Read PG in data warehouse in one article_ stat
- Master this set of refined Android advanced interview questions analysis, oppoandroid interview questions
- Prediction - Grey Prediction
- 两类更新丢失及解决办法
- Cesium (4): the reason why gltf model is very dark after loading
- 模拟Servlet的本质
- AutoLISP series (2): function function 2
猜你喜欢
随机推荐
Three. JS series (1): API structure diagram-1
Binary search tree (features)
网关Gateway的介绍与使用
Imitate the choice of enterprise wechat conference room
Module VI
LeetCode 1049. 最后一块石头的重量 II 每日一题
LeetCode 152. 乘积最大子数组 每日一题
第九届 蓝桥杯 决赛 交换次数
正在准备面试,分享面经
打造All-in-One应用开发平台,轻流树立无代码行业标杆
Cesium(3):ThirdParty/zip. js
LeetCode 1043. 分隔数组以得到最大和 每日一题
【DesignMode】模板方法模式(Template method pattern)
一文读懂数仓中的pg_stat
LeetCode 1774. 最接近目标价格的甜点成本 每日一题
LeetCode 300. 最长递增子序列 每日一题
LeetCode 1981. 最小化目标值与所选元素的差 每日一题
LeetCode 1654. 到家的最少跳跃次数 每日一题
QT中自定义控件的创建到封装到工具栏过程(一):自定义控件的创建
Deep listening array deep listening watch

![[medical segmentation] attention Unet](/img/f4/cf5b8fe543a19a5554897a09b26e68.png)






