当前位置:网站首页>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 .
边栏推荐
- LeetCode 1774. 最接近目标价格的甜点成本 每日一题
- LeetCode 1986. 完成任务的最少工作时间段 每日一题
- Ray and OBB intersection detection
- LeetCode 1626. 无矛盾的最佳球队 每日一题
- os、sys、random标准库主要功能
- 网关Gateway的介绍与使用
- 预测——灰色预测
- Horizontal and vertical centering method and compatibility
- 【C 语言】 题集 of Ⅹ
- Master this set of refined Android advanced interview questions analysis, oppoandroid interview questions
猜你喜欢
字节跳动Android金三银四解析,android面试题app
Have fun | latest progress of "spacecraft program" activities
spark调优(三):持久化减少二次查询
A tour of gRPC:03 - proto序列化/反序列化
[medical segmentation] attention Unet
Personal notes of graphics (4)
AutoLISP series (3): function function 3
二叉搜索树(基操篇)
Binary search tree (basic operation)
最新阿里P7技术体系,妈妈再也不用担心我找工作了
随机推荐
字节跳动Android金三银四解析,android面试题app
Build an all in one application development platform, light flow, and establish a code free industry benchmark
《产品经理必读:五种经典的创新思维模型》的读后感
一文读懂数仓中的pg_stat
字节跳动Android面试,知识点总结+面试题解析
模块六
LeetCode 1043. 分隔数组以得到最大和 每日一题
LeetCode 300. 最长递增子序列 每日一题
null == undefined
数据中台落地实施之法
【DesignMode】外观模式 (facade patterns)
Binary search tree (basic operation)
在哪个期货公司开期货户最安全?
Inner monologue of accidental promotion
谎牛计数(春季每日一题 53)
HAVE FUN | “飞船计划”活动最新进展
Introduction and use of gateway
字节跳动高工面试,轻松入门flutter
Personal notes of graphics (2)
浅浅理解.net core的路由