当前位置:网站首页>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 .
边栏推荐
- [designmode] template method pattern
- The difference and working principle between compiler and interpreter
- OpenGL personal notes
- Lie cow count (spring daily question 53)
- C语言进阶——函数指针
- 蓝桥杯 决赛 异或变换 100分
- 正在准备面试,分享面经
- LeetCode 1155. 掷骰子的N种方法 每日一题
- Ray and OBB intersection detection
- Pycharm terminal enables virtual environment
猜你喜欢

应用在温度检测仪中的温度传感芯片

无法将“pip”项识别为 cmdlet、函数、脚本文件或可运行程序的名称

掌握这套精编Android高级面试题解析,oppoAndroid面试题

Imitate the choice of enterprise wechat conference room
![[vulnhub range] thales:1](/img/fb/721d08697afe9b26c94fede628c4d1.png)
[vulnhub range] thales:1

Have fun | latest progress of "spacecraft program" activities

skimage学习(3)——Gamma 和 log对比度调整、直方图均衡、为灰度图像着色
As an Android Developer programmer, Android advanced interview

模块六

浅浅理解.net core的路由
随机推荐
Personal notes of graphics (1)
Master this promotion path and share interview materials
[Android -- data storage] use SQLite to store data
LeetCode 1981. 最小化目标值与所选元素的差 每日一题
Localstorage and sessionstorage
记录Servlet学习时的一次乱码
值得一看,面试考点与面试技巧
QT中自定义控件的创建到封装到工具栏过程(二):自定义控件封装到工具栏
模块六
ByteDance Android gold, silver and four analysis, Android interview question app
掌握这个提升路径,面试资料分享
[medical segmentation] attention Unet
Sort out several important Android knowledge and advanced Android development interview questions
[PHP] PHP interface inheritance and interface multi inheritance principle and implementation method
最新高频Android面试题目分享,带你一起探究Android事件分发机制
使用JSON.stringify()去实现深拷贝,要小心哦,可能有巨坑
23. 合并K个升序链表-c语言
【C 语言】 题集 of Ⅹ
1亿单身男女“在线相亲”,撑起130亿IPO
LocalStorage和SessionStorage