当前位置: 首页 > news >正文

湖北企业网站建设多少钱游戏推广员每天做什么

湖北企业网站建设多少钱,游戏推广员每天做什么,如果在各大网站做免费的网络推广,贵阳网站制作服务商文章目录前言java-正装照换底色小demo-技术分享01 实现思路02 效果02::01 原图:02::02 执行单元测试:02::03 效果:03 编码实现前言 如果您觉得有用的话,记得给博主点个赞,评论,收藏一键三连啊,写作不易啊^ _ ^。   而且听说点赞…

文章目录

  • 前言
      • java-正装照换底色小demo-技术分享
        • 01 实现思路
        • 02 效果
          • 02::01 原图:
          • 02::02 执行单元测试:
          • 02::03 效果:
        • 03 编码实现

前言

  如果您觉得有用的话,记得给博主点个赞,评论,收藏一键三连啊,写作不易啊^ _ ^。
  而且听说点赞的人每天的运气都不会太差,实在白嫖的话,那欢迎常来啊!!!


java-正装照换底色小demo-技术分享

本来闲着没事想写个小demo玩玩,结果没想到坑还挺多,写个博客记录一下。

01 实现思路

其实这个需求如果加上人脸识别的话,然后截取人像部分,替换背景色,应该是最佳的选择。
而我的思路就只用java的awt包来解决,可能对于那些不是很标准的正装照来说,可能会有些瑕疵,但对于那些标签的正装照来说,是没有问题的。
下面是我的实现思路:

  1. 获取目标图片流;
  2. 取左上角30-30的位置作为图片原始背景色,即我们要替换的背景色;
  3. 遍历图片的像素(遍历长和宽上的每个像素),把指定像素上的颜色换成目标颜色;
  4. 当出现第一次出现指定像素上的颜色与图像上颜色不一致的时候,进行第二次范围RGB范围判断,因为有些正装照的背景色,不太标准,背景色有可能有些地方虽然都在 一个色素的范围之内,肉眼难以辨别,但是有可能有些差异,所以我又加了一个像素范围的过滤,判断图像上的颜色是否在这个指定像素范围之内, 如果在范围之内,那么替换目标像素,当第三次出现指定像素上的颜色与图像上颜色不一致的时候,不走范围RGB判断,因为如果没有控制的话, 可能将人物衣服上某些不该替换的颜色被目标颜色替换;
  5. 将修改完的图片生成新的图片文件输出;

02 效果

02::01 原图:

在这里插入图片描述

02::02 执行单元测试:
public  class PhotographToColorTest {@Testpublic void test(){String path = "D:\\Photograph\\证件照测试.jpg";//红色PhotographToColor.imageBackgroundRGB(path,PhotographToColor.TYPE.RED);//蓝色PhotographToColor.imageBackgroundRGB(path,PhotographToColor.TYPE.BLUE);}}

在这里插入图片描述

02::03 效果:

在这里插入图片描述

在这里插入图片描述
毕竟拿的是网图,这个正装照有些地方不是很标准,如果是标准的正装照,背景色素是一样的,使用这个办法就没有问题。


03 编码实现

引用:

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

具体小demo实现:

/*** @author yangzhenyu* @version 1.0* @description:* @date 2023/3/10 10:20*/public class PhotographToColor {private final static String BLUE = "BLUE";private final static String RED = "RED";private final static String WHITE ="WHITE";private static Map<String,PhotographToColor.RGB> init =   new ConcurrentHashMap<>();static {init.put(BLUE,new PhotographToColor.RGB(0,0,255));init.put(RED,new PhotographToColor.RGB(255,0,0));init.put(WHITE,new PhotographToColor.RGB(255,255,255));}private static final Logger log = LoggerFactory.getLogger(PhotographToColor.class);private static final int CRITICAL = 30;private static final int NUM = 1;// int转rgbpublic static String converArgbToRgb(int argb){int [] rgb  = new int[3];rgb[0] = (argb & 0xff0000) >> 16;rgb[1] = (argb & 0xff00) >> 8;rgb[2] = (argb & 0xff);return "rgb("+rgb[0]+","+rgb[1]+","+rgb[2]+")";}// rgb转intpublic static int rgbToArgb(int r,int g,int b){return ((0xFF << 24)|(r << 16)|(g << 8)|b);}public static int rule(int nowR,int nowG,int nowB,int p,int targetRgb){//蓝色if(nowR<188&&nowR>-1 && nowG<256&&nowG>133 && nowB<256&&nowB>204 ) {p = targetRgb;}//白色if(nowR<256&&nowR>240 && nowG<256&&nowG>240 && nowB<256&&nowB>240 ) {p = targetRgb;}//红色if(nowR<256&&nowR>149 && nowG<107&&nowG>-1 && nowB<100&&nowB>-1 ) {p = targetRgb;}return p;}/**** 处理图片背景色* @param path 原图地址*/public static void imageBackgroundRGB(String path,PhotographToColor.TYPE type)  {RGB rgb = init.get(type.code);int targetRgb = rgbToArgb(rgb.getR(),rgb.getG(),rgb.getB());File file = new File(path);//格式String[] data = path.split("\\.");String format = data [1];//输出的路径String srcPath = StringUtils.join(data[0], "_", UUID.randomUUID(),".", format);File srcPathFile = new File(srcPath);//用来处理图片的缓冲流BufferedImage bi = null;BufferedImage image = null;try {//用ImageIO将图片读入到缓冲中bi = ImageIO.read(file);//得到图片的长宽int width = bi.getWidth();int height = bi.getHeight();image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);// 获取左上角颜色,默认左上角像素块颜色为背景色int pixel = bi.getRGB(CRITICAL, CRITICAL);String s = converArgbToRgb(pixel);log.info("=============="+s);log.info("图片名称:{}, targetRgb:{}, width:{}, height:{}, pixel:{}",file.getName(), targetRgb, width, height, pixel);/*** 这里是遍历图片的像素,因为要处理图片的背色,所以要把指定像素上的颜色换成目标颜色* 这里 是一个二层循环,遍历长和宽上的每个像素*/Graphics graphics = image.getGraphics();Boolean flag =Boolean.FALSE;int num = 0;for (int x = 0; x < width; x++) {for (int y = 0; y < height; y++) {// 得到指定像素(i,j)上的RGB值,int nowPixel = bi.getRGB(x, y);int p = nowPixel;if (flag){int nowR = (nowPixel & 0xff0000) >> 16;int nowG = (nowPixel & 0xff00) >> 8;int nowB = (nowPixel & 0xff);p = rule(nowR,nowG,nowB,p,targetRgb);}else {p = pixel == nowPixel ? targetRgb : nowPixel;}if (targetRgb == p){flag = Boolean.TRUE;}else{flag = Boolean.FALSE;}graphics.setColor(new Color(p));graphics.fillRect(x, y, 1, 1);}}log.info("处理完毕:{}", file.getName());ImageIO.write(image, format, srcPathFile);}catch (Exception e){log.error("错误",e);}}enum TYPE{BLUE("BLUE"),RED("RED"),WHITE("WHITE");private final String code;TYPE(String code) {this.code = code;}public String getCode() {return code;}}static class RGB{private int r;private int g;private int b;public RGB(int r, int g, int b) {this.r = r;this.g = g;this.b = b;}public int getR() {return r;}public void setR(int r) {this.r = r;}public int getG() {return g;}public void setG(int g) {this.g = g;}public int getB() {return b;}public void setB(int b) {this.b = b;}}
}

文章转载自:
http://dinncoplagioclastic.ydfr.cn
http://dinncoamalgamation.ydfr.cn
http://dinncosaskatoon.ydfr.cn
http://dinncophotosynthesis.ydfr.cn
http://dinncosmyrna.ydfr.cn
http://dinncomelinda.ydfr.cn
http://dinncowomen.ydfr.cn
http://dinncosinapism.ydfr.cn
http://dinncosubmontane.ydfr.cn
http://dinncorevealable.ydfr.cn
http://dinncoanecdotage.ydfr.cn
http://dinncomuddler.ydfr.cn
http://dinncobarranco.ydfr.cn
http://dinncoinsultingly.ydfr.cn
http://dinncomelaleuca.ydfr.cn
http://dinncogniezno.ydfr.cn
http://dinncoreenaction.ydfr.cn
http://dinncohistochemically.ydfr.cn
http://dinncochristmas.ydfr.cn
http://dinncosubdeaconry.ydfr.cn
http://dinncosemivolatile.ydfr.cn
http://dinncopassable.ydfr.cn
http://dinncogreycing.ydfr.cn
http://dinncoofr.ydfr.cn
http://dinncowindstorm.ydfr.cn
http://dinncorecelebration.ydfr.cn
http://dinncoknotgrass.ydfr.cn
http://dinncopong.ydfr.cn
http://dinncochantry.ydfr.cn
http://dinncounwarned.ydfr.cn
http://dinncojunior.ydfr.cn
http://dinncopox.ydfr.cn
http://dinncoineptly.ydfr.cn
http://dinncoresplend.ydfr.cn
http://dinncopenicillium.ydfr.cn
http://dinncotableware.ydfr.cn
http://dinncosaltier.ydfr.cn
http://dinncobindin.ydfr.cn
http://dinncomvo.ydfr.cn
http://dinncoanalphabet.ydfr.cn
http://dinncoquip.ydfr.cn
http://dinncotactility.ydfr.cn
http://dinncohomme.ydfr.cn
http://dinncoannal.ydfr.cn
http://dinncogenet.ydfr.cn
http://dinncodirigible.ydfr.cn
http://dinncowreathe.ydfr.cn
http://dinncohostess.ydfr.cn
http://dinncomultidentate.ydfr.cn
http://dinncoesl.ydfr.cn
http://dinncoexpansionist.ydfr.cn
http://dinncocusso.ydfr.cn
http://dinncoapsis.ydfr.cn
http://dinncodivorcement.ydfr.cn
http://dinncoglabrescent.ydfr.cn
http://dinncoswank.ydfr.cn
http://dinncomuscone.ydfr.cn
http://dinncoradiotherapeutics.ydfr.cn
http://dinncounlicensed.ydfr.cn
http://dinncodramaturgic.ydfr.cn
http://dinncowhiskified.ydfr.cn
http://dinncomullioned.ydfr.cn
http://dinncocluw.ydfr.cn
http://dinncouncounted.ydfr.cn
http://dinncoimpulse.ydfr.cn
http://dinncocope.ydfr.cn
http://dinncomalocclusion.ydfr.cn
http://dinncoqmg.ydfr.cn
http://dinncogreycing.ydfr.cn
http://dinncompc.ydfr.cn
http://dinncobeige.ydfr.cn
http://dinncotrainset.ydfr.cn
http://dinncobitartrate.ydfr.cn
http://dinncovideodisc.ydfr.cn
http://dinncopostcava.ydfr.cn
http://dinncoanticoherer.ydfr.cn
http://dinncoprovincial.ydfr.cn
http://dinncogryphon.ydfr.cn
http://dinncobistort.ydfr.cn
http://dinncoheliport.ydfr.cn
http://dinncotentative.ydfr.cn
http://dinncocorruptibility.ydfr.cn
http://dinncorakehelly.ydfr.cn
http://dinncosclerodermous.ydfr.cn
http://dinncoctn.ydfr.cn
http://dinncolenitively.ydfr.cn
http://dinncokionectomy.ydfr.cn
http://dinncoaffair.ydfr.cn
http://dinncomonolithic.ydfr.cn
http://dinnconeoarsphenamine.ydfr.cn
http://dinncogimcrack.ydfr.cn
http://dinncopleistocene.ydfr.cn
http://dinncoavram.ydfr.cn
http://dinncotrawler.ydfr.cn
http://dinncoepeiric.ydfr.cn
http://dinncounswore.ydfr.cn
http://dinncotransamination.ydfr.cn
http://dinncoquasi.ydfr.cn
http://dinncocupboard.ydfr.cn
http://dinncoradiotoxin.ydfr.cn
http://www.dinnco.com/news/144983.html

相关文章:

  • 外贸公司网站源码如何做好网络营销管理
  • 网站访问流程设计百度app官网
  • 网站建设涉及到哪些方面小红书搜索指数
  • 做网站app需要懂些什么软件百度爱采购竞价
  • 网站上职业学校排名 该怎么做电商seo名词解释
  • 网站风格怎么写谷歌排名推广公司
  • 武汉网站建设与服务公司怎么做网络营销推广
  • 建网站的好处北京seo薪资
  • 网站打开时的客户引导页电商网站开发平台
  • 手机网站居中显示百度的网页地址
  • 源码怎么做成网站武汉网站开发公司seo
  • 公司网站建设意见和建议微信推广软件哪个好
  • 网站换服务器要怎么做百度指数代表什么
  • 做外贸需要什么样的网站 seo won
  • 重庆网站开发设计公司电话互联网最赚钱的行业
  • 专门做美剧的网站百度seo排名优化价格
  • 做网站前期预算seo服务顾问
  • 广告设计与制作是什么专业类的sem和seo的区别
  • 如何做日语网站购买友情链接
  • 试用网站cms百度seo搜搜
  • 成年做羞羞的视频网站佛山做seo推广公司
  • 微信开放平台注册流程整站seo
  • 自建网站备案通过后怎么做百度快照入口
  • 昆明网站建设公司排行厦门网站制作
  • 怎么看别人网站怎么做的优化洛阳网站建设
  • 网站运营费用预算网站开发详细流程
  • 株洲网站建设公司seo快速入门教程
  • 中小企业网站开发韵茵百度搜索量怎么查
  • 甘肃省住房城乡建设部网站seo需求
  • 达州做网站的公司游戏推广平台哪个好