2024年C C++最新图像的种子算法之c++实现(qt + 不调包)_qt 图片算法,2024年最新凭借这份C C++面试题集

img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上C C++开发知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以戳这里获取

3)对栈中的像素进行检查,去除已被填充的像素

4)重复第2、3步,直到栈为空。

2.代码实现(代码是我以前自学图像处理时写的,代码很粗糙没做任何优化,但很好理解)
//种子算法
QImage* MainWindow::FillArea(QImage* image,int* pos, int color,int delta)
{
    int stack[9999];
    int sk = 0;
    int stk = 0;
    int x =pos[0];
    int y =pos[1];
    int x1,y1;
    unsigned char flagBuf[image->width()][image->height()];
    memset(flagBuf,0,sizeof(unsigned char)*image->width()*image->height());
    QImage* newImage = new QImage(image->height(),image->width(),QImage::Format_ARGB32);
    QColor color1;
    QColor color2;
    color1 = QColor(image->pixel(x,y));
    unsigned nowColor[3];
    nowColor[0] = color1.red();
    nowColor[1] = color1.green();
    nowColor[2] = color1.blue();
    stack[sk] = x;
    stack[sk + 1] = y;
    sk+=2;
    while(sk > 0)
    {
        sk-=2;
        int *tempStack = new int [9999];
        int*pos = new int[2];
        pos[0] = stack[sk];
        pos[1] = stack[sk+1];

        x1 = pos[0];
        y1 = pos[1];
        stk = 0;
        newImage->setPixel(x1,y1,qRgb(color,color,color));
        flagBuf[x1][y1] = 1;
        for(int step = -1; step<=1; step+=2)
        {
            x1 = pos[0] + step;
            y1 = pos[1];
            while(x1>=0 && x1 < image->width())
            {
                color2 = QColor(image->pixel(x1,y1));
                if(abs(color2.red() - nowColor[0])<delta && abs(color2.green() - nowColor[1])<delta && abs(color2.blue() - nowColor[2])<delta)
                {
                    image->setPixel(x1,y1,qRgb(color,color,color));
                    flagBuf[x1][y1] = 1;
                    color2 = QColor(image->pixel(x1,y1-1));
                    if(y1>0 && flagBuf[x1][y1 -1] == 0 && abs(color2.red() - nowColor[0])<delta && abs(color2.green() - nowColor[1])<delta && abs(color2.blue() - nowColor[2])<delta)
                    {
                        tempStack[stk]=x1;
                        tempStack[stk +1] = y1-1;
                        stk +=2;
                    }
                    color2 = QColor(image->pixel(x1,y1+1));
                    if(y1<image->height() - 1 && flagBuf[x1][y1+1] == 0 && abs(color2.red() - nowColor[0])<delta && abs(color2.green() - nowColor[1])<delta && abs(color2.blue() - nowColor[2])<delta)
                    {
                        tempStack[stk]=x1;
                        tempStack[stk +1] = y1+1;
                        stk +=2;
                    }
                    x1+=step;
                }
                else
                    break;
            }
         }
        tempStack[stk]=-1;
        int k =0;
        for(int i = 0;i<sk;i+=2)
        {
            x = stack[i];
            y= stack[i+1];
            if(flagBuf[x][y] == 0)


![img](https://img-blog.csdnimg.cn/img_convert/9a4dabc6cba0393cd69043944207a516.png)
![img](https://img-blog.csdnimg.cn/img_convert/a6f5a0b1c61b57a025f51e52e2e344ea.png)

**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上C C++开发知识点,真正体系化!**

**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**

**[如果你需要这些资料,可以戳这里获取](https://bbs.youkuaiyun.com/topics/618668825)**

经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**

**[如果你需要这些资料,可以戳这里获取](https://bbs.youkuaiyun.com/topics/618668825)**

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值