跳转至内容
  • 版块
  • 最新
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(不使用皮肤)
  • 不使用皮肤
折叠
品牌标识

真紅の資源討論組

  1. 主页
  2. blog & 技术 & 教程
  3. 基于坐标的立绘合成工具

基于坐标的立绘合成工具

已定时 已固定 已锁定 已移动 blog & 技术 & 教程
立绘合成
1 帖子 1 发布者 152 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
回复
  • 在新帖中回复
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • listderL 离线
    listderL 离线
    listder
    写于 最后由 编辑
    #1

    usage:img-cov.exe backgroundfile foregroundfile outputfile x y
    img-cov.7z
    源代码:

    #include<bits/stdc++.h>
    #include <io.h>
    #include <windows.h>
    #include <direct.h> 
    #include <opencv2/opencv.hpp>
    
    using namespace cv;
    using namespace std;
    
    void overlayImages(const cv::Mat& background, const cv::Mat& foreground, cv::Mat& output, int x, int y) {
    	output = background.clone();
    	cv::Rect roi(x, y, foreground.cols, foreground.rows);
    	roi &= cv::Rect(0, 0, background.cols, background.rows);
    	cv::Mat roi_output = output(roi);
    	cv::Mat roi_foreground = foreground(cv::Rect(0, 0, roi.width, roi.height));
    	for (int i = 0; i < roi.height; ++i) {
    		for (int j = 0; j < roi.width; ++j) {
    			cv::Vec4b pixel_foreground = roi_foreground.at<cv::Vec4b>(i, j);
    			cv::Vec4b& pixel_output = roi_output.at<cv::Vec4b>(i, j);
    
    			double alpha = pixel_foreground[3] / 255.0;
    			double beta = 1.0 - alpha;
    
    			for (int k = 0; k < 3; ++k) {
    				pixel_output[k] = static_cast<uchar>(alpha * pixel_foreground[k] + beta * pixel_output[k]);
    			}
    		}
    	}
    }
    
    void imgset(string path1, string path2,string outpath,int x,int y){
    	Mat img1 = cv::imread(path2, cv::IMREAD_UNCHANGED);
    	Mat img2 = cv::imread(path1, cv::IMREAD_UNCHANGED);
    	Mat mergedImg;
    	overlayImages(img1,img2,mergedImg,x,y);
    	imwrite(outpath, mergedImg);
    	return ;
    }
    
    int main(int argc,char *argv[]){
    	if(argc!=6){
    	    printf("usage:img-cov.exe backgroundfile foregroundfile outputfile x y");
    	    return 0;
    	}
    	else {
    	    imgset(argv[2],argv[1],argv[3],atoi(argv[4]),atoi(argv[5]));
    	    return 0;
    	}
    } 
    

    反正骰子已经掷出去了,而且能够决定骰子点数的并不是自己

    1 条回复 最后回复
    0
    回复
    • 在新帖中回复
    登录后回复
    • 从旧到新
    • 从新到旧
    • 最多赞同


    • 登录

    • 没有帐号? 注册

    • 登录或注册以进行搜索。
    Powered by NodeBB Contributors
    • 第一个帖子
      最后一个帖子
    0
    • 版块
    • 最新
    • 标签
    • 热门
    • 用户
    • 群组